summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/cube.c
diff options
context:
space:
mode:
authorquinn <quinn@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-01-31 18:08:04 +0000
committerquinn <quinn@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-01-31 18:08:04 +0000
commit372608443273c5f15b2f4f14c2e3a78329719038 (patch)
treeea86e9c6adc2c3fcd40924cb072b08f4a7b314ba /beryl-plugins/src/cube.c
parentec58f7a227597b8692f83de0f12725a2298ad2d1 (diff)
downloadmarex-dev-372608443273c5f15b2f4f14c2e3a78329719038.tar.gz
marex-dev-372608443273c5f15b2f4f14c2e3a78329719038.tar.bz2
cube:
* add cap drawing for non-4-sided * still doesn't solve transparency but that's not as big of an issue git-svn-id: file:///beryl/trunk@3488 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/cube.c')
-rw-r--r--beryl-plugins/src/cube.c88
1 files changed, 51 insertions, 37 deletions
diff --git a/beryl-plugins/src/cube.c b/beryl-plugins/src/cube.c
index d9b795b..8417970 100644
--- a/beryl-plugins/src/cube.c
+++ b/beryl-plugins/src/cube.c
@@ -1945,14 +1945,15 @@ cubeDrawCubeCap(CompScreen * s, int hsize, int arrayOffset,
CUBE_SCREEN(s);
- if ( cs->invert == 1)
+ if (cs->invert == 1)
cubeCap = capOutside;
- else if ( cs->invert != 1)
+ else if (cs->invert != 1)
cubeCap = capInside;
else
cubeCap = NULL;
- if (cubeCap && cubeCap->texture.name && s->hsize == 4)
+ glDrawArrays(GL_TRIANGLE_FAN, arrayOffset, cs->nvertices >> 1);
+ /*if (cubeCap && cubeCap->texture.name && s->hsize == 4)
{
if (opacity != OPAQUE)
{
@@ -1961,21 +1962,20 @@ cubeDrawCubeCap(CompScreen * s, int hsize, int arrayOffset,
}
enableTexture(s, &cubeCap->texture, COMP_TEXTURE_FILTER_GOOD);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- /* as GL expects the texture coords with offset, but our
- texture coord array is 0-based, we have to subtract the offset here */
+ // as GL expects the texture coords with offset, but our
+ // texture coord array is 0-based, we have to subtract the offset here
glTexCoordPointer(2, GL_FLOAT, 0, cubeCap->tc - (arrayOffset << 1));
glDrawArrays(GL_TRIANGLE_FAN, arrayOffset, cs->nvertices >> 1);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
disableTexture(s, &cubeCap->texture);
screenTexEnvMode(s, GL_REPLACE);
- }
- else if (cubeCap && cubeCap->texture.name && s->hsize > 4)
+ }*/
+ if (cubeCap && cubeCap->texture.name)
{
//screenTexEnvMode(s, GL_REPLACE);
enableTexture(s, &cubeCap->texture, COMP_TEXTURE_FILTER_GOOD);
- glBegin(GL_QUADS);
int centerx = *cs->vertices;
int centery = *(cs->vertices+1);
int centerz = *(cs->vertices+2);
@@ -1985,18 +1985,40 @@ cubeDrawCubeCap(CompScreen * s, int hsize, int arrayOffset,
{
glColor4us(0xffff, 0xffff, 0xffff, opacity);
}
- glVertex3f(centerx-0.35,centery+0.5,centerz+0.35);
- glVertex3f(centerx-0.35,centery+0.5,centerz-0.35);
- glVertex3f(centerx+0.35, centery+0.5, centerz-0.35);
- glVertex3f(centerx+0.35,centery+0.5,centerz+0.35);
+ GLfloat x1,y1,x2,y2;
+ x1 = cubeCap->tc[4];
+ x2 = cubeCap->tc[2];
+ y1 = cubeCap->tc[3];
+ y2 = cubeCap->tc[9];
+
+ glBegin(GL_QUADS);
+ if (arrayOffset)
+ centery-=1;
+ if (arrayOffset)
+ {
+ glTexCoord2f(x1,y1);
+ glVertex3f(centerx-0.5,centery+0.5,centerz+0.5);
+ glTexCoord2f(x1,y2);
+ glVertex3f(centerx-0.5,centery+0.5,centerz-0.5);
+ glTexCoord2f(x2,y2);
+ glVertex3f(centerx+0.5, centery+0.5, centerz-0.5);
+ glTexCoord2f(x2,y1);
+ glVertex3f(centerx+0.5,centery+0.5,centerz+0.5);
+ }
+ else
+ {
+ glTexCoord2f(x2,y2);
+ glVertex3f(centerx+0.5,centery+0.5,centerz+0.5);
+ glTexCoord2f(x2,y1);
+ glVertex3f(centerx+0.5, centery+0.5, centerz-0.5);
+ glTexCoord2f(x1,y1);
+ glVertex3f(centerx-0.5,centery+0.5,centerz-0.5);
+ glTexCoord2f(x1,y2);
+ glVertex3f(centerx-0.5,centery+0.5,centerz+0.5);
+ }
glEnd();
disableTexture(s, &cubeCap->texture);
-
- }
- else
- {
- glDrawArrays(GL_TRIANGLE_FAN, arrayOffset, cs->nvertices >> 1);
}
}
@@ -2375,35 +2397,31 @@ cubePaintTransformedScreen(CompScreen * s,
glVertexPointer(3, GL_FLOAT, 0, cs->vertices);
- if (hsize != 4 && cs->invert != 1)
- glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
+ //if (hsize != 4 && cs->invert != 1)
+ // glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
- if (hsize == 4)
- {
- glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
+ glRotatef(360.0f/(float)hsize, 0.0f, 1.0f, 0.0f);
if (cs->rotateImages)
{
- if (soa.xRotate > 45)
- glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
+ if (soa.xRotate > (360.0f/(float)hsize)/2.0f)
+ glRotatef(-360.0f/(float)hsize, 0.0f, 1.0f, 0.0f);
}
else if (cs->neverRotateImages)
{
- glRotatef(rotations * 90.0f, 0.0f, 1.0f, 0.0f);
+ glRotatef(rotations * (360.0f/(float)hsize), 0.0f, 1.0f, 0.0f);
float previousRotation = IPCS_GetFloat(IPCS_OBJECT(s),
cs->
previousRotationAtom);
if (cs->invert != 1)
previousRotation = -previousRotation;
- glRotatef(previousRotation * 90.0f, 0.0f, 1.0f, 0.0f);
+ glRotatef(previousRotation * (360.0f/(float)hsize), 0.0f, 1.0f, 0.0f);
}
else
{
- glRotatef(rotations * 90.0f, 0.0f, 1.0f, 0.0f);
+ glRotatef(rotations *(360.0f/(float)hsize), 0.0f, 1.0f, 0.0f);
}
- }
-
if (glIsEnabled(GL_CULL_FACE)
&& (cs->desktopOpacity != OPAQUE || s->berylDesktopManaged) && cs->invert == 1)
{
@@ -2422,16 +2440,14 @@ cubePaintTransformedScreen(CompScreen * s,
if (capsReversed())
{
glNormal3f(0.0, -1.0, 0.0);
- if (hsize == 4)
- glRotatef(270.0f, 0.0f, 1.0f, 0.0f);
+ glRotatef(360.0f-(360.0f/(float)hsize), 0.0f, 1.0f, 0.0f);
cubeDrawCubeCap(s, hsize,
cs->nvertices >> 1,
&cs->cubeCapBottom,
&cs->cubeCapTop, cs->desktopOpacity);
glNormal3f(0.0, -1.0, 0.0);
- if (hsize == 4)
- glRotatef(-270.0f, 0.0f, 1.0f, 0.0f);
+ //glRotatef(-360.0f+(360.0f/(float)hsize), 0.0f, 1.0f, 0.0f);
cubeDrawCubeCap(s, hsize, 0,
&cs->cubeCapTop,
&cs->cubeCapBottom, cs->desktopOpacity);
@@ -2443,8 +2459,7 @@ cubePaintTransformedScreen(CompScreen * s,
&cs->cubeCapTop,
&cs->cubeCapBottom, cs->desktopOpacity);
- if (hsize == 4)
- glRotatef(270.0f, 0.0f, 1.0f, 0.0f);
+ glRotatef(360.0f-(360.0f/(float)hsize), 0.0f, 1.0f, 0.0f);
glNormal3f(0.0, 1.0, 0.0);
cubeDrawCubeCap(s, hsize,
cs->nvertices >> 1,
@@ -2458,8 +2473,7 @@ cubePaintTransformedScreen(CompScreen * s,
cubeDrawCubeCap(s, hsize, 0, &cs->cubeCapTop,
&cs->cubeCapBottom, cs->desktopOpacity);
- if (hsize == 4)
- glRotatef(270.0f, 0.0f, 1.0f, 0.0f);
+ glRotatef(360.0f-(360.0f/(float)hsize), 0.0f, 1.0f, 0.0f);
glNormal3f(0.0, 1.0, 0.0);
cubeDrawCubeCap(s, hsize, cs->nvertices >> 1,
&cs->cubeCapBottom,