[fusion-commits] Animation plugin: Changes to 'master' (6d5e713382aa7d60e39b7f99ea6f3b5edfbed88a)
cornelius at server.beryl-project.org
cornelius at server.beryl-project.org
Sat Jul 21 06:09:44 CEST 2007
New commits:
commit 6d5e713382aa7d60e39b7f99ea6f3b5edfbed88a
Author: Erkin Bahceci <erkinbah at gmail.com>
Date: Sat Jul 21 00:08:02 2007 -0400
Add window-centered perspective correction to polygon engine.
animation-internal.h | 9 ++++++++-
domino.c | 2 +-
explode3d.c | 2 +-
glide.c | 2 +-
leafspread.c | 2 +-
polygon.c | 21 +++++++++++++++++----
6 files changed, 29 insertions(+), 9 deletions(-)
Modified: fusion/plugins/animation/animation-internal.h
===================================================================
--- fusion/plugins/animation/animation-internal.h
+++ fusion/plugins/animation/animation-internal.h
@@ -117,6 +117,13 @@ typedef struct _Clip4Polygons // Rectangular clips
// ordered as p1.v1.x, p1.v1.y, p1.v2.x, p1.v2.y, p2.v1.x, p2.v1.y, ...
} Clip4Polygons;
+typedef enum
+{
+ CorrectPerspectiveNone = 0,
+ CorrectPerspectivePolygon,
+ CorrectPerspectiveWindow
+} CorrectPerspective;
+
typedef struct _PolygonSet // Polygon objects with same thickness
{
int nClips; // Rect. clips collected in AddWindowGeometries
@@ -128,7 +135,7 @@ typedef struct _PolygonSet // Polygon objects with same thickness
Bool doDepthTest; // whether depth testing should be used in the effect
Bool doLighting; // whether lighting should be used in the effect
- Bool correctPerspective; // Whether perspective look should be neutralized
+ CorrectPerspective correctPerspective;
PolygonObject *polygons; // The polygons in this set
int nPolygons;
float thickness; // Window thickness (depth along z axis)
Modified: fusion/plugins/animation/domino.c
===================================================================
--- fusion/plugins/animation/domino.c
+++ fusion/plugins/animation/domino.c
@@ -264,5 +264,5 @@ void fxDomino3DInit(CompScreen * s, CompWindow * w)
free(riseTimeRandSeed);
pset->doDepthTest = TRUE;
pset->doLighting = TRUE;
- pset->correctPerspective = TRUE;
+ pset->correctPerspective = CorrectPerspectivePolygon;
}
Modified: fusion/plugins/animation/explode3d.c
===================================================================
--- fusion/plugins/animation/explode3d.c
+++ fusion/plugins/animation/explode3d.c
@@ -98,7 +98,7 @@ void fxExplode3DInit(CompScreen * s, CompWindow * w)
pset->allFadeDuration = 0.3f;
pset->doDepthTest = TRUE;
pset->doLighting = TRUE;
- pset->correctPerspective = TRUE;
+ pset->correctPerspective = CorrectPerspectivePolygon;
pset->backAndSidesFadeDur = 0.2f;
}
Modified: fusion/plugins/animation/glide.c
===================================================================
--- fusion/plugins/animation/glide.c
+++ fusion/plugins/animation/glide.c
@@ -268,7 +268,7 @@ void fxGlideInit(CompScreen * s, CompWindow * w)
pset->allFadeDuration = 1.0f;
pset->backAndSidesFadeDur = 0.2f;
pset->doLighting = TRUE;
- pset->correctPerspective = TRUE;
+ pset->correctPerspective = CorrectPerspectivePolygon;
}
void fxGlidePrePaintWindow(CompScreen *s,
Modified: fusion/plugins/animation/leafspread.c
===================================================================
--- fusion/plugins/animation/leafspread.c
+++ fusion/plugins/animation/leafspread.c
@@ -93,5 +93,5 @@ void fxLeafSpread3DInit(CompScreen * s, CompWindow * w)
}
pset->doDepthTest = TRUE;
pset->doLighting = TRUE;
- pset->correctPerspective = TRUE;
+ pset->correctPerspective = CorrectPerspectivePolygon;
}
Modified: fusion/plugins/animation/polygon.c
===================================================================
--- fusion/plugins/animation/polygon.c
+++ fusion/plugins/animation/polygon.c
@@ -1345,12 +1345,25 @@ void polygonsDrawCustomGeometry(CompScreen * s, CompWindow * w)
glPushMatrix();
- if (pset->correctPerspective)
+ if (pset->correctPerspective != CorrectPerspectiveNone)
{
- // Correct perspective appearance by skewing
+ Point center;
- GLfloat skewx = -((p->centerPos.x - s->width / 2) * 1.15);
- GLfloat skewy = -((p->centerPos.y - s->height / 2) * 1.15);
+ if (pset->correctPerspective == CorrectPerspectivePolygon)
+ {
+ // use polygon's center
+ center.x = p->centerPos.x;
+ center.y = p->centerPos.y;
+ }
+ else // CorrectPerspectiveWindow
+ {
+ // use window's center
+ center.x = WIN_X(w) + WIN_W(w) / 2;
+ center.y = WIN_Y(w) + WIN_H(w) / 2;
+ }
+ // Correct perspective appearance by skewing
+ GLfloat skewx = -((center.x - s->width / 2) * 1.15);
+ GLfloat skewy = -((center.y - s->height / 2) * 1.15);
// column-major order
GLfloat skewMat[16] =
More information about the commits
mailing list