summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/cube.c
diff options
context:
space:
mode:
authoronestone <onestone@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-13 00:43:33 +0000
committeronestone <onestone@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-13 00:43:33 +0000
commit0ab00e046951ad9b6263c8fb0ede3effa86d222d (patch)
treeaf3675da1e41d63d136e72824326d2a0c358bb7b /beryl-plugins/src/cube.c
parent104ed8ebe6ebeed3e48c8b1269a23e36928aacc8 (diff)
downloadmarex-dev-0ab00e046951ad9b6263c8fb0ede3effa86d222d.tar.gz
marex-dev-0ab00e046951ad9b6263c8fb0ede3effa86d222d.tar.bz2
beryl-(core|plugins): moved matrix transformations out of gl (David Reveman)
- group not ported yet - blurfx has bugs but this will be fixed in a rewrite all other plugins should work git-svn-id: file:///beryl/trunk@4005 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/cube.c')
-rw-r--r--beryl-plugins/src/cube.c111
1 files changed, 58 insertions, 53 deletions
diff --git a/beryl-plugins/src/cube.c b/beryl-plugins/src/cube.c
index 8654ca4..36436f4 100644
--- a/beryl-plugins/src/cube.c
+++ b/beryl-plugins/src/cube.c
@@ -1690,6 +1690,7 @@ static void cubePreparePaintScreen(CompScreen * s, int msSinceLastPaint)
static Bool
cubePaintScreen(CompScreen * s,
const ScreenPaintAttrib * sAttrib,
+ const CompTransform *transform,
Region region, int output, unsigned int mask)
{
Bool status;
@@ -1747,14 +1748,17 @@ cubePaintScreen(CompScreen * s,
}
UNWRAP(cs, s, paintScreen);
- status = (*s->paintScreen) (s, sAttrib, region, output, mask);
+ status = (*s->paintScreen) (s, sAttrib, transform, region, output, mask);
WRAP(cs, s, paintScreen, cubePaintScreen);
if (!cs->finalPaint)
{
- glPushMatrix();
+ CompTransform sTransform = *transform;
+ transformToScreenSpace (s, output, -DEFAULT_Z_CAMERA, &sTransform);
+
+ glPushMatrix ();
+ glLoadMatrixf (sTransform.m);
- prepareXCoords(s, output, -DEFAULT_Z_CAMERA);
cs->finalPaint=TRUE;
CompWindow * w;
for (w=s->reverseWindows;w;w=w->prev)
@@ -1763,7 +1767,7 @@ cubePaintScreen(CompScreen * s,
w->attrib.override_redirect) &&
(w->mapNum && w->attrib.map_state == IsViewable && !(w->minimized) && !(w->state & CompWindowStateHiddenMask)))
{
- s->paintWindow(w,&w->paint,getInfiniteRegion(),0);
+ s->paintWindow(w,&w->paint,&sTransform,getInfiniteRegion(),0);
}
}
glPopMatrix();
@@ -1796,26 +1800,24 @@ typedef struct _CubeFacePaint
static void
paintReversed(CompScreen * s,
const ScreenPaintAttrib * sA,
+ const CompTransform *transform,
int output, int xMove, CubeFacePaint * face)
{
CUBE_SCREEN(s);
- float pm[16];
- float mvm[16];
+ CompTransform mTransform = *transform;
+
float mvp[16];
- glPushMatrix(); //Get the matrices.
// inputzoom should not scale here
cs->paintingCaps = TRUE;
- (s->applyScreenTransform) (s, sA, output);
- prepareXCoords(s, output, -sA->zTranslate);
- cs->paintingCaps = FALSE;
- glGetFloatv(GL_MODELVIEW_MATRIX, mvm);
- glGetFloatv(GL_PROJECTION_MATRIX, pm);
+ (s->applyScreenTransform) (s, sA, output, &mTransform);
- MULTM(pm, mvm, mvp);
+ transformToScreenSpace (s, output, -sA->zTranslate, &mTransform);
- glPopMatrix();
+ cs->paintingCaps = FALSE;
+
+ MULTM(s->projection, mTransform.m, mvp);
float pntA[4] = { s->outputDev[output].region.extents.x1,
s->outputDev[output].region.extents.y1, 0, 1
@@ -1864,16 +1866,12 @@ paintReversed(CompScreen * s,
}
}
-static Bool capsReversed(void)
+static Bool capsReversed(CompScreen * s,
+ const CompTransform *transform)
{
- float pm[16];
- float mvm[16];
float mvp[16];
- glGetFloatv(GL_MODELVIEW_MATRIX, mvm);
- glGetFloatv(GL_PROJECTION_MATRIX, pm);
-
- MULTM(pm, mvm, mvp);
+ MULTM(s->projection, transform->m, mvp);
float pntA[4] = { 0.0, 0.5, 0.0, 1 };
@@ -1898,6 +1896,7 @@ static Bool capsReversed(void)
static void
cubeMoveViewportAndPaint(CompScreen * s,
const ScreenPaintAttrib * sAttrib,
+ const CompTransform * transform,
int output, unsigned int mask, int dx)
{
CUBE_SCREEN(s);
@@ -1940,7 +1939,7 @@ cubeMoveViewportAndPaint(CompScreen * s,
cs->noManaged = TRUE;
moveScreenViewport(s, -dView, 0, FALSE);
- (*s->paintTransformedScreen) (s, sAttrib,
+ (*s->paintTransformedScreen) (s, sAttrib, transform,
&s->outputDev[output].region,
output, mask);
moveScreenViewport(s, dView, 0, FALSE);
@@ -1953,7 +1952,8 @@ cubeMoveViewportAndPaint(CompScreen * s,
(cs->desktopOpacity != OPAQUE || s->berylDesktopManaged))
cs->noManaged = TRUE;
moveScreenViewport(s, dx, 0, FALSE);
- (*s->paintTransformedScreen) (s, sAttrib, &s->region, output, mask);
+ (*s->paintTransformedScreen) (s, sAttrib, transform, &s->region,
+ output, mask);
moveScreenViewport(s, -dx, 0, FALSE);
}
cs->finalPaint=save;
@@ -1965,7 +1965,7 @@ cubeDrawCubeCap(CompScreen * s, int hsize, int arrayOffset,
CubeCapInfo * capOutside, CubeCapInfo * capInside,
unsigned short opacity)
{
-
+
CubeCapInfo *cubeCap;
CUBE_SCREEN(s);
@@ -1996,7 +1996,7 @@ cubeDrawCubeCap(CompScreen * s, int hsize, int arrayOffset,
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
disableTexture(s, &cubeCap->texture);
screenTexEnvMode(s, GL_REPLACE);
-
+
}
else */if (cubeCap && cubeCap->texture.name)
{
@@ -2005,7 +2005,7 @@ cubeDrawCubeCap(CompScreen * s, int hsize, int arrayOffset,
int centerx = *cs->vertices;
int centery = *(cs->vertices+1);
int centerz = *(cs->vertices+2);
-
+
glColor4f(1.0,1.0,1.0,1.0);
if (opacity != OPAQUE)
{
@@ -2043,7 +2043,7 @@ cubeDrawCubeCap(CompScreen * s, int hsize, int arrayOffset,
glTexCoord2f(x1,y2);
glVertex3f(centerx-0.5,centery+0.5,centerz+0.5);
}
-
+
glEnd();
disableTexture(s, &cubeCap->texture);
}
@@ -2052,6 +2052,7 @@ cubeDrawCubeCap(CompScreen * s, int hsize, int arrayOffset,
static void
cubePaintTransformedScreen(CompScreen * s,
const ScreenPaintAttrib * sAttrib,
+ const CompTransform * transform,
Region region, int output, unsigned int mask)
{
ScreenPaintAttrib sa = *sAttrib;
@@ -2251,7 +2252,7 @@ cubePaintTransformedScreen(CompScreen * s,
for (i = 0; i < hsize; i++)
{
- paintReversed(s, &sa, output, xMove, &faces[fc]);
+ paintReversed(s, &sa, transform, output, xMove, &faces[fc]);
fc++;
sa.yRotate -= 360.0f / size;
@@ -2265,14 +2266,14 @@ cubePaintTransformedScreen(CompScreen * s,
{
xMove = cs->xrotations;
- paintReversed(s, &sa, output, xMove, &faces[fc]);
+ paintReversed(s, &sa, transform, output, xMove, &faces[fc]);
fc++;
xMove++;
}
sa.yRotate -= 360.0f / size;
- paintReversed(s, &sa, output, xMove, &faces[fc]);
+ paintReversed(s, &sa, transform, output, xMove, &faces[fc]);
fc++;
}
sa.yRotate = yRotSav;
@@ -2305,7 +2306,7 @@ cubePaintTransformedScreen(CompScreen * s,
for (i = 0; i < hsize; i++)
{
- paintReversed(s, &sa, output, xMove, &faces[fc]);
+ paintReversed(s, &sa, transform, output, xMove, &faces[fc]);
fc++;
sa.yRotate += 360.0f / size;
@@ -2314,20 +2315,20 @@ cubePaintTransformedScreen(CompScreen * s,
}
else
{
- paintReversed(s, &sa, output, xMove, &faces[fc]);
+ paintReversed(s, &sa, transform, output, xMove, &faces[fc]);
fc++;
sa.yRotate += 360.0f / size;
xMove = -cs->xrotations;
- paintReversed(s, &sa, output, xMove, &faces[fc]);
+ paintReversed(s, &sa, transform, output, xMove, &faces[fc]);
fc++;
sa.yRotate += 360.0f / size;
xMove = 1 - cs->xrotations;
- paintReversed(s, &sa, output, xMove, &faces[fc]);
+ paintReversed(s, &sa, transform, output, xMove, &faces[fc]);
fc++;
}
}
@@ -2382,7 +2383,7 @@ cubePaintTransformedScreen(CompScreen * s,
}
}
faces[found].painted = TRUE;
- cubeMoveViewportAndPaint(s, &faces[found].sa,
+ cubeMoveViewportAndPaint(s, &faces[found].sa, transform,
output, newMask, faces[found].xMove);
}
@@ -2410,23 +2411,26 @@ cubePaintTransformedScreen(CompScreen * s,
glColor4us(cs->color[0], cs->color[1], cs->color[2],
cs->desktopOpacity);
- glPushMatrix();
+ CompTransform sTransform = *transform;
if (sAttrib->xRotate > 0.0f)
{
sa.yRotate += 360.0f / size;
- (s->applyScreenTransform) (s, &soa, output);
- glTranslatef(cs->outputXOffset, -cs->outputYOffset, 0.0f);
- glScalef(cs->outputXScale, cs->outputYScale, 1.0f);
+ (s->applyScreenTransform) (s, &soa, output, &sTransform);
+ matrixTranslate(&sTransform, cs->outputXOffset, -cs->outputYOffset, 0.0f);
+ matrixScale(&sTransform, cs->outputXScale, cs->outputYScale, 1.0f);
sa.yRotate -= 360.0f / size;
}
else
{
- (s->applyScreenTransform) (s, &soa, output);
- glTranslatef(cs->outputXOffset, -cs->outputYOffset, 0.0f);
- glScalef(cs->outputXScale, cs->outputYScale, 1.0f);
+ (s->applyScreenTransform) (s, &soa, output, &sTransform);
+ matrixTranslate(&sTransform, cs->outputXOffset, -cs->outputYOffset, 0.0f);
+ matrixScale(&sTransform, cs->outputXScale, cs->outputYScale, 1.0f);
}
+ glPushMatrix();
+ glLoadMatrixf(sTransform.m);
+
glVertexPointer(3, GL_FLOAT, 0, cs->vertices);
//if (hsize != 4 && cs->invert != 1)
@@ -2469,7 +2473,7 @@ cubePaintTransformedScreen(CompScreen * s,
if (cs->invert == 1)
{
- if (capsReversed())
+ if (capsReversed(s,&sTransform))
{
glNormal3f(0.0, -1.0, 0.0);
glRotatef(360.0f-(360.0f/(float)hsize), 0.0f, 1.0f, 0.0f);
@@ -2563,7 +2567,7 @@ cubePaintTransformedScreen(CompScreen * s,
}
}
faces[found].painted = TRUE;
- cubeMoveViewportAndPaint(s, &faces[found].sa, output,
+ cubeMoveViewportAndPaint(s, &faces[found].sa, transform, output,
newMask, faces[found].xMove);
}
@@ -2578,20 +2582,20 @@ cubePaintTransformedScreen(CompScreen * s,
static void
cubeApplyScreenTransform(CompScreen * s,
- const ScreenPaintAttrib * sAttrib, int output)
+ const ScreenPaintAttrib * sAttrib, int output,
+ CompTransform * transform)
{
CUBE_SCREEN(s);
-
- glTranslatef(cs->outputXOffset, -cs->outputYOffset, 0.0f);
- glScalef(cs->outputXScale, cs->outputYScale, 1.0f);
+ matrixTranslate(transform, cs->outputXOffset, -cs->outputYOffset, 0.0f);
+ matrixScale(transform, cs->outputXScale, cs->outputYScale, 1.0f);
UNWRAP(cs, s, applyScreenTransform);
- (*s->applyScreenTransform) (s, sAttrib, output);
+ (*s->applyScreenTransform) (s, sAttrib, output, transform);
WRAP(cs, s, applyScreenTransform, cubeApplyScreenTransform);
- glScalef(1.0f / cs->outputXScale, 1.0f / cs->outputYScale, 1.0f);
- glTranslatef(-cs->outputXOffset, cs->outputYOffset, 0.0f);
+ matrixScale(transform, 1.0f / cs->outputXScale, 1.0f / cs->outputYScale, 1.0f);
+ matrixTranslate(transform, -cs->outputXOffset, cs->outputYOffset, 0.0f);
}
static void
@@ -2639,6 +2643,7 @@ cubePaintBackground(CompScreen * s, Region region, unsigned int mask)
static Bool
cubePaintWindow(CompWindow * w,
const WindowPaintAttrib * attrib,
+ const CompTransform *transform,
Region region, unsigned int mask)
{
int status;
@@ -2666,7 +2671,7 @@ cubePaintWindow(CompWindow * w,
}
UNWRAP(cs, w->screen, paintWindow);
- status = (*w->screen->paintWindow) (w, &wa, region, mask);
+ status = (*w->screen->paintWindow) (w, &wa, transform, region, mask);
WRAP(cs, w->screen, paintWindow, cubePaintWindow);
return status;
@@ -2734,7 +2739,7 @@ cubeFold(CompDisplay * d,
for (s = d->screens; s; s = s->next)
{
CUBE_SCREEN(s);
-
+
IPCS_SetBool(IPCS_OBJECT(s),cs->unfoldedAtom, FALSE);
if (xid && s->root != xid)