All pastes #709211 Raw Edit

Anonymous

public text v1 · immutable
#709211 ·published 2007-09-24 13:46 UTC
rendered paste body
diff --git a/3d.c b/3d.c
index 27b670f..30d1a3f 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,13 @@ static Bool tdPaintWindow (CompWindow              *w,
 			   Region                  region,
 			   unsigned int            mask);
 
+#define MULTMV(m, v) { \
+float v0 = m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3]; \
+float v1 = m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3]; \
+float v2 = m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3]; \
+float v3 = m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3]; \
+v[0] = v0; v[1] = v1; v[2] = v2; v[3] = v3; }
+
 static Bool
 tdPaintWindowWithDepth (CompWindow              *w,
 		     	const WindowPaintAttrib *attrib,
@@ -197,13 +206,12 @@ 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];
 
     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);
 
@@ -261,34 +270,90 @@ tdPaintWindowWithDepth (CompWindow              *w,
 
 #define DOBEVEL(corner) (tdGetBevel##corner (s) ? bevel : 0)
 
+	point[0] = wx + DOBEVEL (Topleft);
+	point[1] = wy;
+	point[2] = 0.0;
+	point[3] = 1.0;
+
+	MULTMV (transform->m, point);
+
+	glVertex4dv (point);
+
+	point[0] = wx + ww - DOBEVEL (Topright);
+	point[1] = wy;
+	point[2] = 0.0;
+	point[3] = 1.0;
+
+	MULTMV (transform->m, point);
+
+	glVertex4dv (point);
+
+	point[0] = wx + ww - DOBEVEL (Topright);
+	point[1] = wy;
+	point[2] = 0.0;
+	point[3] = 1.0;
+
+	MULTMV (tds->bTransform.m, point);
+
+	glVertex4dv (point);
+
+	point[0] = wx + DOBEVEL (Topleft);
+	point[1] = wy;
+	point[2] = 0.0;
+	point[3] = 1.0;
+
+	MULTMV (tds->bTransform.m, point);
+
+	glVertex4dv (point);
+
+	
+#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 +432,7 @@ tdPaintWindowWithDepth (CompWindow              *w,
 	    glVertex3f (wx + ww, wy + bevel, 0);
 	    glVertex3f (wx + ww, wy + bevel, wwidth);
 	}
-
+#endif
 	glEnd ();
 	glPopMatrix ();
 
@@ -376,14 +441,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 +457,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 +577,14 @@ 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 = -(tdGetWidth (s)) / 30;
+
 	/* all non 3d windows first */
 	tds->first = NULL;
 	tds->last = NULL;
@@ -601,6 +670,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);