rendered paste bodydiff --git a/3d.c b/3d.c
index 27b670f..a83c6bc 100644
--- a/3d.c
+++ b/3d.c
@@ -85,6 +85,8 @@ typedef struct _tdScreen
float basicScale;
float maxDepth;
+
+ CompTransform bTransform;
} tdScreen;
#define GET_TD_DISPLAY(d) \
@@ -190,6 +192,12 @@ static Bool tdPaintWindow (CompWindow *w,
Region region,
unsigned int mask);
+#define MULTMV(m, v, w) { \
+w[0] = m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3]; \
+w[1] = m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3]; \
+w[2] = m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3]; \
+w[3] = m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3]; }
+
static Bool
tdPaintWindowWithDepth (CompWindow *w,
const WindowPaintAttrib *attrib,
@@ -197,13 +205,13 @@ tdPaintWindowWithDepth (CompWindow *w,
Region region,
unsigned int mask)
{
- Bool wasCulled;
- Bool status;
- int wx, wy, wx2, wy2, ww, wh;
- int bevel;
- float wwidth;
- CompTransform wTransform = *transform;
+ Bool wasCulled;
+ Bool status;
+ int wx, wy, wx2, wy2, ww, wh;
+ int bevel;
CompScreen *s = w->screen;
+ GLdouble point[4];
+ GLdouble tPoint[4];
TD_SCREEN (s);
@@ -218,7 +226,6 @@ tdPaintWindowWithDepth (CompWindow *w,
ww = wx2 - wx;
wh = wy2 - wy;
- wwidth = -(tdGetWidth (s)) / 30;
bevel = tdGetBevel (s);
if (ww && wh && !(mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK))
@@ -229,15 +236,16 @@ tdPaintWindowWithDepth (CompWindow *w,
{
glEnable (GL_CULL_FACE);
glCullFace (GL_FRONT);
-
- matrixTranslate (&wTransform, 0.0f, 0.0f, wwidth);
- UNWRAP (tds, s, paintWindow);
- status = (*s->paintWindow) (w, attrib, &wTransform, region,
+ glPushMatrix ();
+ glLoadMatrixf (tds->bTransform.m);
+
+ UNWRAP (tds, s, paintWindow);
+ status = (*s->paintWindow) (w, attrib, &tds->bTransform, region,
mask | PAINT_WINDOW_TRANSFORMED_MASK);
WRAP (tds, s, paintWindow, tdPaintWindow);
- matrixTranslate (&wTransform, 0.0f, 0.0f, -wwidth);
+ glPopMatrix ();
}
else
{
@@ -245,14 +253,15 @@ tdPaintWindowWithDepth (CompWindow *w,
glCullFace (GL_BACK);
UNWRAP (tds, s, paintWindow);
- status = (*s->paintWindow) (w, attrib, &wTransform, region, mask);
+ status = (*s->paintWindow) (w, attrib, transform, region, mask);
WRAP (tds, s, paintWindow, tdPaintWindow);
}
/* Paint window depth. */
glPushMatrix ();
- glLoadMatrixf (wTransform.m);
-
+ //glLoadMatrixf (transform->m);
+ glLoadIdentity ();
+
glDisable (GL_CULL_FACE);
glEnable (GL_BLEND);
@@ -262,33 +271,149 @@ tdPaintWindowWithDepth (CompWindow *w,
#define DOBEVEL(corner) (tdGetBevel##corner (s) ? bevel : 0)
/* Top */
+ point[0] = wx + DOBEVEL (Topleft);
+ point[1] = wy + 0.01;
+ point[2] = 0.0;
+ point[3] = 1.0;
+
+ MULTMV (transform->m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ point[0] = wx + ww - DOBEVEL (Topright);
+
+ MULTMV (transform->m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ point[0] = wx + ww - DOBEVEL (Topright);
+
+ MULTMV (tds->bTransform.m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ point[0] = wx + DOBEVEL (Topleft);
+
+ MULTMV (tds->bTransform.m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ /* Bottom */
+ point[0] = wx + DOBEVEL (Topleft);
+ point[1] = wy + wh - 0.01;
+ point[2] = 0.0;
+ point[3] = 1.0;
+
+ MULTMV (transform->m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ point[0] = wx + ww - DOBEVEL (Topright);
+
+ MULTMV (transform->m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ point[0] = wx + ww - DOBEVEL (Topright);
+
+ MULTMV (tds->bTransform.m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ point[0] = wx + DOBEVEL (Topleft);
+
+ MULTMV (tds->bTransform.m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ /* Left */
+ point[0] = wx + 0.01;
+ point[1] = wy + DOBEVEL (Topleft);
+ point[2] = 0.0;
+ point[3] = 1.0;
+
+ MULTMV (transform->m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ point[1] = wy + wh - DOBEVEL (Bottomleft);
+
+ MULTMV (transform->m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ point[1] = wy + wh - DOBEVEL (Bottomleft);
+
+ MULTMV (tds->bTransform.m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ point[1] = wy + DOBEVEL (Topleft);
+
+ MULTMV (tds->bTransform.m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ /* Right */
+ point[0] = wx + ww - 0.01;
+ point[1] = wy + DOBEVEL (Topleft);
+ point[2] = 0.0;
+ point[3] = 1.0;
+
+ MULTMV (transform->m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ point[1] = wy + wh - DOBEVEL (Bottomleft);
+
+ MULTMV (transform->m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ point[1] = wy + wh - DOBEVEL (Bottomleft);
+
+ MULTMV (tds->bTransform.m, point, tPoint);
+ glVertex4dv (tPoint);
+
+ point[1] = wy + DOBEVEL (Topleft);
+
+ MULTMV (tds->bTransform.m, point, tPoint);
+ glVertex4dv (tPoint);
+
+
+#if 0
+ /* Top */
glVertex3f (wx + DOBEVEL (Topleft), wy, 0);
glVertex3f (wx + ww - DOBEVEL (Topright), wy, 0);
- glVertex3f (wx + ww - DOBEVEL (Topright), wy, wwidth);
- glVertex3f (wx + DOBEVEL (Topleft), wy, wwidth);
+
+ //glPushMatrix ();
+ //glLoadMatrixf (tds->bTransform.m);
+ glTranslatef (0.0,0.0,-0.1);
+ glVertex3f (wx + ww - DOBEVEL (Topright), wy, 0);
+ glVertex3f (wx + DOBEVEL (Topleft), wy, 0);
+ //glPopMatrix ();
/* Bottom */
glVertex3f (wx + DOBEVEL (Bottomleft), wy + wh, 0);
glVertex3f (wx + ww - DOBEVEL (Bottomright), wy + wh, 0);
- glVertex3f (wx + ww - DOBEVEL (Bottomright), wy + wh, wwidth);
- glVertex3f (wx + DOBEVEL (Bottomleft), wy + wh, wwidth);
+
+ glPushMatrix ();
+ glLoadMatrixf (tds->bTransform.m);
+ glVertex3f (wx + ww - DOBEVEL (Bottomright), wy + wh, 0);
+ glVertex3f (wx + DOBEVEL (Bottomleft), wy + wh, 0);
+ glPopMatrix ();
glColor4f (0.70f, 0.70f, 0.70f, w->paint.opacity / OPAQUE);
/* Left */
glVertex3f (wx, wy + DOBEVEL (Topleft), 0);
glVertex3f (wx, wy + wh - DOBEVEL (Bottomleft), 0);
- glVertex3f (wx, wy + wh - DOBEVEL (Bottomleft), wwidth);
- glVertex3f (wx, wy + DOBEVEL (Topleft), wwidth);
+
+ glPushMatrix ();
+ glLoadMatrixf (tds->bTransform.m);
+ glVertex3f (wx, wy + wh - DOBEVEL (Bottomleft), 0);
+ glVertex3f (wx, wy + DOBEVEL (Topleft), 0);
+ glPopMatrix ();
/* Right */
glVertex3f (wx + ww, wy + DOBEVEL (Topright), 0);
glVertex3f (wx + ww, wy + wh - DOBEVEL (Bottomright), 0);
- glVertex3f (wx + ww, wy + wh - DOBEVEL (Bottomright), wwidth);
- glVertex3f (wx + ww, wy + DOBEVEL (Topright), wwidth);
+
+ glPushMatrix ();
+ glLoadMatrixf (tds->bTransform.m);
+ glVertex3f (wx + ww, wy + wh - DOBEVEL (Bottomright), 0);
+ glVertex3f (wx + ww, wy + DOBEVEL (Topright), 0);
+ glPopMatrix ();
glColor4f (0.95f, 0.95f, 0.95f, w->paint.opacity / OPAQUE);
+
/* Top left bevel */
if (tdGetBevelTopleft (s))
{
@@ -367,7 +492,7 @@ tdPaintWindowWithDepth (CompWindow *w,
glVertex3f (wx + ww, wy + bevel, 0);
glVertex3f (wx + ww, wy + bevel, wwidth);
}
-
+#endif
glEnd ();
glPopMatrix ();
@@ -376,14 +501,15 @@ tdPaintWindowWithDepth (CompWindow *w,
glEnable (GL_CULL_FACE);
glCullFace (GL_FRONT);
- matrixTranslate (&wTransform, 0.0f, 0.0f, wwidth);
+ glPushMatrix ();
+ glLoadMatrixf (tds->bTransform.m);
- UNWRAP (tds, s, paintWindow);
- status = (*s->paintWindow) (w, attrib, &wTransform, region,
+ UNWRAP (tds, s, paintWindow);
+ status = (*s->paintWindow) (w, attrib, &tds->bTransform, region,
mask | PAINT_WINDOW_TRANSFORMED_MASK);
WRAP(tds, s, paintWindow, tdPaintWindow);
- matrixTranslate(&wTransform, 0.0f, 0.0f, -wwidth);
+ glPopMatrix ();
}
else
{
@@ -391,7 +517,7 @@ tdPaintWindowWithDepth (CompWindow *w,
glCullFace (GL_BACK);
UNWRAP(tds, s, paintWindow);
- status = (*s->paintWindow) (w, attrib, &wTransform, region, mask);
+ status = (*s->paintWindow) (w, attrib, transform, region, mask);
WRAP (tds, s, paintWindow, tdPaintWindow);
}
}
@@ -511,11 +637,15 @@ tdPostPaintViewport (CompScreen *s,
CompWindow *firstFTB = NULL;
CompWindow *w;
CompWalker walk;
+ float wDepth;
float vPoints[3][3] = {{ -0.5, 0.0, (cs->invert * cs->distance)},
{ 0.0, 0.5, (cs->invert * cs->distance)},
{ 0.0, 0.0, (cs->invert * cs->distance)}};
+ wDepth = -MIN((tdGetWidth (s)) / 30, (1.0 - tds->basicScale) /
+ tds->maxDepth);
+
/* all non 3d windows first */
tds->first = NULL;
tds->last = NULL;
@@ -601,6 +731,14 @@ tdPostPaintViewport (CompScreen *s,
tds->currentScale = tds->basicScale +
(tdw->depth * ((1.0 - tds->basicScale) /
tds->maxDepth));
+
+ tds->currentScale += wDepth;
+ tds->bTransform = sTransform;
+ (*s->applyScreenTransform) (s, sAttrib, output, &tds->bTransform);
+ tds->currentScale -= wDepth;
+
+ transformToScreenSpace (s, output, -sAttrib->zTranslate,
+ &tds->bTransform);
(*s->applyScreenTransform) (s, sAttrib, output, &mTransform);
(*s->enableOutputClipping) (s, &mTransform, region, output);