[fixed-to-float-patches] Fix some of the matrix getters and setters
The GL versions of get_modelview_matrix, get_projection_matrix and get_viewport were using glGetDoublev and then converting them to floats, but it might as well just call glGetFloatv directly. The GL ES versions were using glGetFixedv but this was being replaced with glGetFloatv by the #define in the GLES 2 wrappers. The patch also replaces the glGetFixedv wrapper with glGetFloatv. Previously this was calling cogl_gles2_float_array_to_fixed which actually converted to float. That function has been removed and memcpy is used instead.
This commit is contained in:
parent
66afd41868
commit
ea1d9f5522
@ -1,5 +1,5 @@
|
|||||||
diff --git a/clutter/cogl/gl/cogl.c b/clutter/cogl/gl/cogl.c
|
diff --git a/clutter/cogl/gl/cogl.c b/clutter/cogl/gl/cogl.c
|
||||||
index 7b61b63..5100a08 100644
|
index 7b61b63..d815e3b 100644
|
||||||
--- a/clutter/cogl/gl/cogl.c
|
--- a/clutter/cogl/gl/cogl.c
|
||||||
+++ b/clutter/cogl/gl/cogl.c
|
+++ b/clutter/cogl/gl/cogl.c
|
||||||
@@ -211,17 +211,17 @@ cogl_pop_matrix (void)
|
@@ -211,17 +211,17 @@ cogl_pop_matrix (void)
|
||||||
@ -93,3 +93,80 @@ index 7b61b63..5100a08 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
GE( glTranslatef (-0.5f, -0.5f, -z_camera) );
|
GE( glTranslatef (-0.5f, -0.5f, -z_camera) );
|
||||||
|
@@ -1166,73 +1160,19 @@ cogl_features_available (CoglFeatureFlags features)
|
||||||
|
void
|
||||||
|
cogl_get_modelview_matrix (float m[16])
|
||||||
|
{
|
||||||
|
- GLdouble md[16];
|
||||||
|
-
|
||||||
|
- glGetDoublev(GL_MODELVIEW_MATRIX, &md[0]);
|
||||||
|
-
|
||||||
|
-#define M(m,row,col) m[col*4+row]
|
||||||
|
- M(m,0,0) = (M(md,0,0));
|
||||||
|
- M(m,0,1) = (M(md,0,1));
|
||||||
|
- M(m,0,2) = (M(md,0,2));
|
||||||
|
- M(m,0,3) = (M(md,0,3));
|
||||||
|
-
|
||||||
|
- M(m,1,0) = (M(md,1,0));
|
||||||
|
- M(m,1,1) = (M(md,1,1));
|
||||||
|
- M(m,1,2) = (M(md,1,2));
|
||||||
|
- M(m,1,3) = (M(md,1,3));
|
||||||
|
-
|
||||||
|
- M(m,2,0) = (M(md,2,0));
|
||||||
|
- M(m,2,1) = (M(md,2,1));
|
||||||
|
- M(m,2,2) = (M(md,2,2));
|
||||||
|
- M(m,2,3) = (M(md,2,3));
|
||||||
|
-
|
||||||
|
- M(m,3,0) = (M(md,3,0));
|
||||||
|
- M(m,3,1) = (M(md,3,1));
|
||||||
|
- M(m,3,2) = (M(md,3,2));
|
||||||
|
- M(m,3,3) = (M(md,3,3));
|
||||||
|
-#undef M
|
||||||
|
+ glGetFloatv (GL_MODELVIEW_MATRIX, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_get_projection_matrix (float m[16])
|
||||||
|
{
|
||||||
|
- GLdouble md[16];
|
||||||
|
-
|
||||||
|
- glGetDoublev(GL_PROJECTION_MATRIX, &md[0]);
|
||||||
|
-
|
||||||
|
-#define M(m,row,col) m[col*4+row]
|
||||||
|
- M(m,0,0) = (M(md,0,0));
|
||||||
|
- M(m,0,1) = (M(md,0,1));
|
||||||
|
- M(m,0,2) = (M(md,0,2));
|
||||||
|
- M(m,0,3) = (M(md,0,3));
|
||||||
|
-
|
||||||
|
- M(m,1,0) = (M(md,1,0));
|
||||||
|
- M(m,1,1) = (M(md,1,1));
|
||||||
|
- M(m,1,2) = (M(md,1,2));
|
||||||
|
- M(m,1,3) = (M(md,1,3));
|
||||||
|
-
|
||||||
|
- M(m,2,0) = (M(md,2,0));
|
||||||
|
- M(m,2,1) = (M(md,2,1));
|
||||||
|
- M(m,2,2) = (M(md,2,2));
|
||||||
|
- M(m,2,3) = (M(md,2,3));
|
||||||
|
-
|
||||||
|
- M(m,3,0) = (M(md,3,0));
|
||||||
|
- M(m,3,1) = (M(md,3,1));
|
||||||
|
- M(m,3,2) = (M(md,3,2));
|
||||||
|
- M(m,3,3) = (M(md,3,3));
|
||||||
|
-#undef M
|
||||||
|
+ glGetFloatv (GL_PROJECTION_MATRIX, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_get_viewport (float v[4])
|
||||||
|
{
|
||||||
|
- GLdouble vd[4];
|
||||||
|
- glGetDoublev(GL_VIEWPORT, &vd[0]);
|
||||||
|
-
|
||||||
|
- v[0] = (vd[0]);
|
||||||
|
- v[1] = (vd[1]);
|
||||||
|
- v[2] = (vd[2]);
|
||||||
|
- v[3] = (vd[3]);
|
||||||
|
+ glGetFloatv (GL_VIEWPORT, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
58
fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch
Normal file
58
fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.c b/clutter/cogl/gles/cogl-gles2-wrapper.c
|
||||||
|
index 859c895..8a2fd24 100644
|
||||||
|
--- a/clutter/cogl/gles/cogl-gles2-wrapper.c
|
||||||
|
+++ b/clutter/cogl/gles/cogl-gles2-wrapper.c
|
||||||
|
@@ -1142,15 +1142,6 @@ cogl_wrap_glClipPlanex (GLenum plane, GLfloat *equation)
|
||||||
|
/* FIXME */
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void
|
||||||
|
-cogl_gles2_float_array_to_fixed (int size,
|
||||||
|
- const GLfloat *floats,
|
||||||
|
- GLfloat *fixeds)
|
||||||
|
-{
|
||||||
|
- while (size-- > 0)
|
||||||
|
- *(fixeds++) = (*(floats++));
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
void
|
||||||
|
cogl_wrap_glGetIntegerv (GLenum pname, GLint *params)
|
||||||
|
{
|
||||||
|
@@ -1169,31 +1160,24 @@ cogl_wrap_glGetIntegerv (GLenum pname, GLint *params)
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
-cogl_wrap_glGetFixedv (GLenum pname, GLfloat *params)
|
||||||
|
+cogl_wrap_glGetFloatv (GLenum pname, GLfloat *params)
|
||||||
|
{
|
||||||
|
_COGL_GET_GLES2_WRAPPER (w, NO_RETVAL);
|
||||||
|
|
||||||
|
switch (pname)
|
||||||
|
{
|
||||||
|
case GL_MODELVIEW_MATRIX:
|
||||||
|
- cogl_gles2_float_array_to_fixed (16, w->modelview_stack
|
||||||
|
- + w->modelview_stack_pos * 16,
|
||||||
|
- params);
|
||||||
|
+ memcpy (params, w->modelview_stack + w->modelview_stack_pos * 16,
|
||||||
|
+ sizeof (GLfloat) * 16);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_PROJECTION_MATRIX:
|
||||||
|
- cogl_gles2_float_array_to_fixed (16, w->projection_stack
|
||||||
|
- + w->projection_stack_pos * 16,
|
||||||
|
- params);
|
||||||
|
+ memcpy (params, w->projection_stack + w->projection_stack_pos * 16,
|
||||||
|
+ sizeof (GLfloat) * 16);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_VIEWPORT:
|
||||||
|
- {
|
||||||
|
- GLfloat v[4];
|
||||||
|
-
|
||||||
|
- glGetFloatv (GL_VIEWPORT, v);
|
||||||
|
- cogl_gles2_float_array_to_fixed (4, v, params);
|
||||||
|
- }
|
||||||
|
+ glGetFloatv (GL_VIEWPORT, params);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,22 @@
|
|||||||
diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h
|
diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h
|
||||||
index 265da78..2e61121 100644
|
index 265da78..2493b81 100644
|
||||||
--- a/clutter/cogl/gles/cogl-gles2-wrapper.h
|
--- a/clutter/cogl/gles/cogl-gles2-wrapper.h
|
||||||
+++ b/clutter/cogl/gles/cogl-gles2-wrapper.h
|
+++ b/clutter/cogl/gles/cogl-gles2-wrapper.h
|
||||||
|
@@ -244,7 +244,7 @@ void cogl_wrap_glColor4x (GLclampx r, GLclampx g, GLclampx b, GLclampx a);
|
||||||
|
void cogl_wrap_glClipPlanex (GLenum plane, GLfloat *equation);
|
||||||
|
|
||||||
|
void cogl_wrap_glGetIntegerv (GLenum pname, GLint *params);
|
||||||
|
-void cogl_wrap_glGetFixedv (GLenum pname, GLfloat *params);
|
||||||
|
+void cogl_wrap_glGetFloatv (GLenum pname, GLfloat *params);
|
||||||
|
|
||||||
|
void cogl_wrap_glFogx (GLenum pname, GLfloat param);
|
||||||
|
void cogl_wrap_glFogxv (GLenum pname, const GLfloat *params);
|
||||||
@@ -297,7 +297,7 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program);
|
@@ -297,7 +297,7 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program);
|
||||||
#define cogl_wrap_glColor4x glColor4f
|
#define cogl_wrap_glColor4x glColor4f
|
||||||
#define cogl_wrap_glClipPlanex glClipPlanef
|
#define cogl_wrap_glClipPlanex glClipPlanef
|
||||||
#define cogl_wrap_glGetIntegerv glGetIntegerv
|
#define cogl_wrap_glGetIntegerv glGetIntegerv
|
||||||
-#define cogl_wrap_glGetFixedv glGetFixedv
|
-#define cogl_wrap_glGetFixedv glGetFixedv
|
||||||
+#define cogl_wrap_glGetFixedv glGetFloatv
|
+#define cogl_wrap_glGetFloatv glGetFloatv
|
||||||
#define cogl_wrap_glFogx glFogf
|
#define cogl_wrap_glFogx glFogf
|
||||||
#define cogl_wrap_glFogxv glFogfv
|
#define cogl_wrap_glFogxv glFogfv
|
||||||
#define cogl_wrap_glTexParameteri glTexParameteri
|
#define cogl_wrap_glTexParameteri glTexParameteri
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c
|
diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c
|
||||||
index 422d8b6..16cf666 100644
|
index 422d8b6..aa4e4fc 100644
|
||||||
--- a/clutter/cogl/gles/cogl.c
|
--- a/clutter/cogl/gles/cogl.c
|
||||||
+++ b/clutter/cogl/gles/cogl.c
|
+++ b/clutter/cogl/gles/cogl.c
|
||||||
@@ -37,6 +37,7 @@
|
@@ -37,6 +37,7 @@
|
||||||
@ -22,6 +22,17 @@ index 422d8b6..16cf666 100644
|
|||||||
|
|
||||||
GE( cogl_wrap_glPushMatrix () );
|
GE( cogl_wrap_glPushMatrix () );
|
||||||
/* Load the identity matrix and multiply by the reverse of the
|
/* Load the identity matrix and multiply by the reverse of the
|
||||||
|
@@ -405,8 +405,8 @@ _cogl_set_clip_planes (float x_offset,
|
||||||
|
float vertex_br[4] = { x_offset + width, y_offset + height,
|
||||||
|
0, 1.0 };
|
||||||
|
|
||||||
|
- GE( cogl_wrap_glGetFixedv (GL_MODELVIEW_MATRIX, modelview) );
|
||||||
|
- GE( cogl_wrap_glGetFixedv (GL_PROJECTION_MATRIX, projection) );
|
||||||
|
+ GE( cogl_wrap_glGetFloatv (GL_MODELVIEW_MATRIX, modelview) );
|
||||||
|
+ GE( cogl_wrap_glGetFloatv (GL_PROJECTION_MATRIX, projection) );
|
||||||
|
|
||||||
|
project_vertex (modelview, projection, vertex_tl);
|
||||||
|
project_vertex (modelview, projection, vertex_tr);
|
||||||
@@ -558,15 +558,13 @@ cogl_perspective (float fovy,
|
@@ -558,15 +558,13 @@ cogl_perspective (float fovy,
|
||||||
* 2) When working with small numbers, we can are loosing significant
|
* 2) When working with small numbers, we can are loosing significant
|
||||||
* precision
|
* precision
|
||||||
@ -58,3 +69,19 @@ index 422d8b6..16cf666 100644
|
|||||||
|
|
||||||
GE( cogl_wrap_glScalex ( 1.0 / width,
|
GE( cogl_wrap_glScalex ( 1.0 / width,
|
||||||
-1.0 / height,
|
-1.0 / height,
|
||||||
|
@@ -737,13 +735,13 @@ cogl_features_available (CoglFeatureFlags features)
|
||||||
|
void
|
||||||
|
cogl_get_modelview_matrix (float m[16])
|
||||||
|
{
|
||||||
|
- cogl_wrap_glGetFixedv(GL_MODELVIEW_MATRIX, &m[0]);
|
||||||
|
+ cogl_wrap_glGetFloatv (GL_MODELVIEW_MATRIX, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_get_projection_matrix (float m[16])
|
||||||
|
{
|
||||||
|
- cogl_wrap_glGetFixedv(GL_PROJECTION_MATRIX, &m[0]);
|
||||||
|
+ cogl_wrap_glGetFloatv (GL_PROJECTION_MATRIX, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@ -148,6 +148,7 @@ patch -p1<fixed-to-float-patches/cogl-primitives.c.0.patch
|
|||||||
patch -p1<fixed-to-float-patches/gl-cogl-primitives.c.0.patch
|
patch -p1<fixed-to-float-patches/gl-cogl-primitives.c.0.patch
|
||||||
patch -p1<fixed-to-float-patches/gles-cogl.c.0.patch
|
patch -p1<fixed-to-float-patches/gles-cogl.c.0.patch
|
||||||
patch -p1<fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch
|
patch -p1<fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch
|
||||||
|
patch -p1<fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch
|
||||||
patch -p1<fixed-to-float-patches/gles-cogl-primitives.c.0.patch
|
patch -p1<fixed-to-float-patches/gles-cogl-primitives.c.0.patch
|
||||||
patch -p1<fixed-to-float-patches/gles-cogl-texture.c.0.patch
|
patch -p1<fixed-to-float-patches/gles-cogl-texture.c.0.patch
|
||||||
patch -p1<fixed-to-float-patches/cogl.h.in.0.patch
|
patch -p1<fixed-to-float-patches/cogl.h.in.0.patch
|
||||||
|
Loading…
Reference in New Issue
Block a user