From 39444955694ca6b28920544e7c5fd02b14311196 Mon Sep 17 00:00:00 2001 From: Tomas Frydrych Date: Thu, 29 Mar 2007 11:30:30 +0000 Subject: [PATCH] fixed bug in fovy angle degree -> rad conversion, added glMultMatrixx() code --- ChangeLog | 9 ++++++++- clutter/clutter-stage.c | 34 +++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3dcb7700..53ea3c299 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-03-29 Tomas Frydrych + + * clutter/clutter-stage.c: + (perspective): fixed degree -> rad conversion for fovy angle + (perspectivex): fixed degree -> rad conversion for fovy angle, + added code for gle glMultMatrixx(). + 2007-03-29 Tomas Frydrych * configure.ac: fixed typo @@ -7,7 +14,7 @@ (clutter_tani): fast implementation of tan() (clutter_qmulx): improved-precission fixed point multiply - * clutter/clutter-state.c: + * clutter/clutter-stage.c: (perspectivex): fixed point implementaiton of perspective() (_clutter_stage_sync_viewport): (clutter_stage_get_actor_at_pos): diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 3e30d7c0c..13d6c82f0 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -49,6 +49,7 @@ #include #define FIXED_PERSPECTIVE +#undef USING_GLES G_DEFINE_ABSTRACT_TYPE (ClutterStage, clutter_stage, CLUTTER_TYPE_GROUP); @@ -665,7 +666,7 @@ perspective (GLfloat fovy, { GLfloat xmin, xmax, ymin, ymax; - ymax = zNear * tan (fovy * M_PI / 180.0); + ymax = zNear * tan (fovy * M_PI / 360.0); ymin = -ymax; xmin = ymin * aspect; xmax = ymax * aspect; @@ -687,8 +688,13 @@ perspectivex (ClutterAngle fovy, { ClutterFixed xmax, ymax; ClutterFixed x, y, c, d; - GLfloat m[16]; +#ifndef USING_GLES + GLfloat m[16]; +#else + GLfixed m[16]; +#endif + memset (&m[0], 0, sizeof (m)); /* @@ -700,7 +706,7 @@ perspectivex (ClutterAngle fovy, * 2) When working with small numbers, we can are loosing significant * precision, hence we use clutter_qmulx() here, not the fast macro. */ - ymax = clutter_qmulx (zNear, clutter_tani (fovy)); + ymax = clutter_qmulx (zNear, clutter_tani (fovy >> 1)); xmax = clutter_qmulx (ymax, aspect); x = CFX_DIV (zNear, xmax); @@ -709,14 +715,24 @@ perspectivex (ClutterAngle fovy, d = CFX_DIV (-(clutter_qmulx (2*zFar, zNear)), (zFar - zNear)); #define M(row,col) m[col*4+row] +#ifndef USING_GLES M(0,0) = CLUTTER_FIXED_TO_FLOAT (x); M(1,1) = CLUTTER_FIXED_TO_FLOAT (y); M(2,2) = CLUTTER_FIXED_TO_FLOAT (c); M(2,3) = CLUTTER_FIXED_TO_FLOAT (d); M(3,2) = -1.0F; -#undef M - + glMultMatrixf (m); +#else + M(0,0) = x; + M(1,1) = y; + M(2,2) = c; + M(2,3) = d; + M(3,2) = 1 + ~CFX_ONE; + + glMultMatrixx (m); +#endif +#undef M } #endif @@ -739,9 +755,9 @@ _clutter_stage_sync_viewport (ClutterStage *stage) glLoadIdentity (); #ifndef FIXED_PERSPECTIVE - perspective (30.0f, 1.0f, 0.1f, 100.0f); + perspective (60.0f, 1.0f, 0.1f, 100.0f); #else - perspectivex (85, /* 30 degrees */ + perspectivex (171, /* 60 degrees */ CFX_ONE, CLUTTER_FLOAT_TO_FIXED (0.1), CLUTTER_FLOAT_TO_FIXED (100.0)); @@ -802,9 +818,9 @@ clutter_stage_get_actor_at_pos (ClutterStage *stage, glScalef (view[2], -view[3], 1.0); #ifndef FIXED_PERSPECTIVE - perspective (30.0f, 1.0f, 0.1f, 100.0f); + perspective (60.0f, 1.0f, 0.1f, 100.0f); #else - perspectivex (85, /* 30 degrees */ + perspectivex (171, /* 60 degrees */ CFX_ONE, CLUTTER_FLOAT_TO_FIXED (0.1), CLUTTER_FLOAT_TO_FIXED (100.0));