From 18378fe180d2bf64631efa9a6ce99e4d770b793d Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 16 Jan 2009 12:16:28 +0000 Subject: [PATCH] [fixed-to-float.sh] Use float names for the GLES2 wrappers For example cogl_wrap_glFrustumx -> cogl_wrap_glFrustumf. The wrappers get #defined to the float versions anyway but it helps avoid some confusion. The conversion is done using a regular expression in the upgrade script. Some of the patches had to be updated to apply cleanly. --- .../gles-cogl-gles2-wrapper.c.0.patch | 2 +- .../gles-cogl-gles2-wrapper.h.0.patch | 52 +++++++++---------- fixed-to-float-patches/gles-cogl.c.0.patch | 15 ++---- ...move_cogl_apis_taking_fixed_params.0.patch | 10 ++-- fixed-to-float.sh | 7 +++ 5 files changed, 42 insertions(+), 44 deletions(-) diff --git a/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch b/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch index 127ff886f..2268e56a3 100644 --- a/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch +++ b/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch @@ -22,7 +22,7 @@ index b2e19eb..a7800c5 100644 } void --cogl_wrap_glColor4x (GLclampx r, GLclampx g, GLclampx b, GLclampx a) +-cogl_wrap_glColor4f (GLclampx r, GLclampx g, GLclampx b, GLclampx a) +cogl_wrap_glColor4f (GLclampf r, GLclampf g, GLclampf b, GLclampf a) { - glVertexAttrib4f (COGL_GLES2_WRAPPER_COLOR_ATTRIB, diff --git a/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch b/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch index 5bd7c72f1..46d78114e 100644 --- a/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch +++ b/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch @@ -1,5 +1,5 @@ diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h -index ad741be..561cb66 100644 +index cb700cc..f126993 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.h +++ b/clutter/cogl/gles/cogl-gles2-wrapper.h @@ -203,8 +203,6 @@ struct _CoglGles2WrapperShader @@ -15,17 +15,17 @@ index ad741be..561cb66 100644 void cogl_wrap_glAlphaFunc (GLenum func, GLclampf ref); --void cogl_wrap_glColor4x (GLclampx r, GLclampx g, GLclampx b, GLclampx a); +-void cogl_wrap_glColor4f (GLclampx r, GLclampx g, GLclampx b, GLclampx a); +void cogl_wrap_glColor4f (GLclampf r, GLclampf g, GLclampf b, GLclampf a); - void cogl_wrap_glClipPlanex (GLenum plane, GLfloat *equation); + void cogl_wrap_glClipPlanef (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); + void cogl_wrap_glFogf (GLenum pname, GLfloat param); + void cogl_wrap_glFogfv (GLenum pname, const GLfloat *params); @@ -273,35 +271,34 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); /* If we're not using GL ES 2 then just use the GL functions directly */ @@ -37,40 +37,40 @@ index ad741be..561cb66 100644 #define cogl_wrap_glPopMatrix glPopMatrix #define cogl_wrap_glMatrixMode glMatrixMode #define cogl_wrap_glLoadIdentity glLoadIdentity --#define cogl_wrap_glMultMatrixx glMultMatrixx --#define cogl_wrap_glFrustumx glFrustumx --#define cogl_wrap_glScalex glScalex --#define cogl_wrap_glTranslatex glTranslatex --#define cogl_wrap_glRotatex glRotatex --#define cogl_wrap_glOrthox glOrthox -+#define cogl_wrap_glMultMatrixx glMultMatrixf -+#define cogl_wrap_glFrustumx glFrustumf -+#define cogl_wrap_glScalex glScalef -+#define cogl_wrap_glTranslatex glTranslatef -+#define cogl_wrap_glRotatex glRotatef -+#define cogl_wrap_glOrthox glOrthof +-#define cogl_wrap_glMultMatrixf glMultMatrixx +-#define cogl_wrap_glFrustumf glFrustumx +-#define cogl_wrap_glScalef glScalex +-#define cogl_wrap_glTranslatef glTranslatex +-#define cogl_wrap_glRotatef glRotatex +-#define cogl_wrap_glOrthof glOrthox ++#define cogl_wrap_glMultMatrixf glMultMatrixf ++#define cogl_wrap_glFrustumf glFrustumf ++#define cogl_wrap_glScalef glScalef ++#define cogl_wrap_glTranslatef glTranslatef ++#define cogl_wrap_glRotatef glRotatef ++#define cogl_wrap_glOrthof glOrthof #define cogl_wrap_glEnable glEnable #define cogl_wrap_glDisable glDisable #define cogl_wrap_glTexCoordPointer glTexCoordPointer #define cogl_wrap_glVertexPointer glVertexPointer #define cogl_wrap_glColorPointer glColorPointer #define cogl_wrap_glNormalPointer glNormalPointer --#define cogl_wrap_glTexEnvx glTexEnvx -+#define cogl_wrap_glTexEnvx glTexEnvf +-#define cogl_wrap_glTexEnvf glTexEnvx ++#define cogl_wrap_glTexEnvf glTexEnvf #define cogl_wrap_glEnableClientState glEnableClientState #define cogl_wrap_glDisableClientState glDisableClientState #define cogl_wrap_glAlphaFunc glAlphaFunc --#define cogl_wrap_glColor4x glColor4x --#define cogl_wrap_glClipPlanex glClipPlanex +-#define cogl_wrap_glColor4f glColor4x +-#define cogl_wrap_glClipPlanef glClipPlanex +#define cogl_wrap_glColor4f glColor4f -+#define cogl_wrap_glClipPlanex glClipPlanef ++#define cogl_wrap_glClipPlanef glClipPlanef #define cogl_wrap_glGetIntegerv glGetIntegerv -#define cogl_wrap_glGetFixedv glGetFixedv --#define cogl_wrap_glFogx glFogx --#define cogl_wrap_glFogxv glFogxv +-#define cogl_wrap_glFogf glFogx +-#define cogl_wrap_glFogfv glFogxv +#define cogl_wrap_glGetFloatv glGetFloatv -+#define cogl_wrap_glFogx glFogf -+#define cogl_wrap_glFogxv glFogfv ++#define cogl_wrap_glFogf glFogf ++#define cogl_wrap_glFogfv glFogfv #define cogl_wrap_glTexParameteri glTexParameteri /* The extra third parameter of the bind texture wrapper isn't needed diff --git a/fixed-to-float-patches/gles-cogl.c.0.patch b/fixed-to-float-patches/gles-cogl.c.0.patch index 37662d0be..cd7d442e6 100644 --- a/fixed-to-float-patches/gles-cogl.c.0.patch +++ b/fixed-to-float-patches/gles-cogl.c.0.patch @@ -25,15 +25,6 @@ index 422d8b6..cb7aa8e 100644 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); cogl_wrap_glDisable (GL_LIGHTING); -@@ -315,7 +316,7 @@ cogl_set_source_color (const CoglColor *color) - - #else - /* conversion can cause issues with picking on some gles implementations */ -- GE( cogl_wrap_glColor4x (cogl_color_get_red (color), -+ GE( cogl_wrap_glColor4f (cogl_color_get_red (color), - cogl_color_get_green (color), - cogl_color_get_blue (color), - cogl_color_get_alpha (color)) ); @@ -365,9 +366,8 @@ set_clip_plane (GLint plane_num, /* Calculate the angle between the axes and the line crossing the @@ -87,11 +78,11 @@ index 422d8b6..cb7aa8e 100644 } -- GE( cogl_wrap_glTranslatex (-1 << 15, -1 << 15, -z_camera) ); +- GE( cogl_wrap_glTranslatef (-1 << 15, -1 << 15, -z_camera) ); + -+ GE( cogl_wrap_glTranslatex (-0.5f, -0.5f, -z_camera) ); ++ GE( cogl_wrap_glTranslatef (-0.5f, -0.5f, -z_camera) ); - GE( cogl_wrap_glScalex ( 1.0 / width, + GE( cogl_wrap_glScalef ( 1.0 / width, -1.0 / height, @@ -737,13 +735,13 @@ cogl_features_available (CoglFeatureFlags features) void diff --git a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch index 7a84920ed..3afceaf72 100644 --- a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch +++ b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch @@ -522,14 +522,14 @@ index aa4e4fc..e835085 100644 -cogl_translatex (float x, float y, float z) +cogl_translate (float x, float y, float z) { - GE( cogl_wrap_glTranslatex (x, y, z) ); + GE( cogl_wrap_glTranslatef (x, y, z) ); } void -cogl_translate (gint x, gint y, gint z) +cogl_rotate (float angle, float x, float y, float z) { -- GE( cogl_wrap_glTranslatex ((float)(x), +- GE( cogl_wrap_glTranslatef ((float)(x), - (float)(y), - (float)(z)) ); -} @@ -540,17 +540,17 @@ index aa4e4fc..e835085 100644 - float y, - float z) -{ -- GE( cogl_wrap_glRotatex (angle,x,y,z) ); +- GE( cogl_wrap_glRotatef (angle,x,y,z) ); -} - -void -cogl_rotate (gint angle, gint x, gint y, gint z) -{ -- GE( cogl_wrap_glRotatex ((float)(angle), +- GE( cogl_wrap_glRotatef ((float)(angle), - (float)(x), - (float)(y), - (float)(z)) ); -+ GE( cogl_wrap_glRotatex (angle, x, y, z) ); ++ GE( cogl_wrap_glRotatef (angle, x, y, z) ); } static inline gboolean diff --git a/fixed-to-float.sh b/fixed-to-float.sh index b3eb48f85..feaa2b6ea 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -118,6 +118,13 @@ git-checkout clutter/cogl/cogl-fixed.h clutter/cogl/common/cogl-fixed.c find ./clutter -iname '*.[ch]' ! -iname 'clutter-fixed.h' -exec sed -i 's/ClutterAngle/float/g' {} \; +# use the floating point names for GL ES functions instead of the +# fixed. These get #define'd to the float versions in one of the +# patches anyway but the names should be fixed up to avoid confusion +find ./clutter/cogl -iname '*.[ch]' -exec perl -p -i -e \ +'s/\b(cogl_wrap_(?:glMultMatrix|glFrustum|glScale|glTranslate +|glRotate|glOrtho|glTexEnv|glClipPlane|glFog|glColor4))x(v?)\b/$1f$2/gx' {} \; + echo "Cogl API to remove/replace with float versions:" find ./clutter/ -iname '*.c' -exec grep '^cogl_[a-zA-Z_]*x ' {} \; | cut -d' ' -f1|grep -v 'box$'|grep -v 'matrix$' echo "Clutter API to remove/replace with float versions:"