[cogl/gles] Fixes for building for GLES 1 using floats

* This adds GLfixed -> GLfloat conversion
* redefines cogl_wrap_glBlahx macros as glBlahf
* Other misc fixes (mostly corresponding to cogl/gl equivalents)
This commit is contained in:
Robert Bragg 2009-01-08 22:56:17 +00:00
parent f658d8b5cf
commit de27da0e5b
6 changed files with 133 additions and 12 deletions

View File

@ -272,34 +272,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 */
#define cogl_wrap_glClearColorx glClearColorx
#define cogl_wrap_glClearColorx glClearColor
#define cogl_wrap_glDrawArrays glDrawArrays
#define cogl_wrap_glPushMatrix glPushMatrix
#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_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_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_glColor4x glColor4f
#define cogl_wrap_glClipPlanex glClipPlanef
#define cogl_wrap_glGetIntegerv glGetIntegerv
#define cogl_wrap_glGetFixedv glGetFixedv
#define cogl_wrap_glFogx glFogx
#define cogl_wrap_glFogxv glFogxv
#define cogl_wrap_glFogx glFogf
#define cogl_wrap_glFogxv glFogfv
#define cogl_wrap_glTexParameteri glTexParameteri
/* The extra third parameter of the bind texture wrapper isn't needed

View File

@ -0,0 +1,13 @@
diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h
index 265da78..2e61121 100644
--- a/clutter/cogl/gles/cogl-gles2-wrapper.h
+++ b/clutter/cogl/gles/cogl-gles2-wrapper.h
@@ -297,7 +297,7 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program);
#define cogl_wrap_glColor4x glColor4f
#define cogl_wrap_glClipPlanex glClipPlanef
#define cogl_wrap_glGetIntegerv glGetIntegerv
-#define cogl_wrap_glGetFixedv glGetFixedv
+#define cogl_wrap_glGetFixedv glGetFloatv
#define cogl_wrap_glFogx glFogf
#define cogl_wrap_glFogxv glFogfv
#define cogl_wrap_glTexParameteri glTexParameteri

View File

@ -0,0 +1,12 @@
diff --git a/clutter/cogl/gles/cogl-primitives.c b/clutter/cogl/gles/cogl-primitives.c
index 901fa5d..d8fe121 100644
--- a/clutter/cogl/gles/cogl-primitives.c
+++ b/clutter/cogl/gles/cogl-primitives.c
@@ -34,6 +34,7 @@
#include <string.h>
#include <gmodule.h>
+#include <math.h>
#define _COGL_MAX_BEZ_RECURSE_DEPTH 16

View File

@ -0,0 +1,30 @@
diff --git a/clutter/cogl/gles/cogl-texture.c b/clutter/cogl/gles/cogl-texture.c
index fb628b0..85bfc2b 100644
--- a/clutter/cogl/gles/cogl-texture.c
+++ b/clutter/cogl/gles/cogl-texture.c
@@ -39,6 +39,7 @@
#include <string.h>
#include <stdlib.h>
+#include <math.h>
#define glVertexPointer cogl_wrap_glVertexPointer
#define glTexCoordPointer cogl_wrap_glTexCoordPointer
@@ -767,7 +768,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex,
guint wx, wy;
src = source_bmp->data
- + (src_y + (y_iter.intersect_start)
+ + (src_y + ((int)y_iter.intersect_start)
- dst_y)
* source_bmp->rowstride
+ (src_x + x_span->start + x_span->size - x_span->waste
@@ -812,7 +813,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex,
guint copy_width;
src = source_bmp->data
- + (src_x + (x_iter.intersect_start)
+ + (src_x + ((int)x_iter.intersect_start)
- dst_x)
* bpp
+ (src_y + y_span->start + y_span->size - y_span->waste

View File

@ -0,0 +1,60 @@
diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c
index 422d8b6..16cf666 100644
--- a/clutter/cogl/gles/cogl.c
+++ b/clutter/cogl/gles/cogl.c
@@ -37,6 +37,7 @@
#include "cogl-context.h"
#include "cogl-gles2-wrapper.h"
+#include <math.h>
/* GL error to string conversion */
#if COGL_DEBUG
@@ -365,9 +366,8 @@ set_clip_plane (GLint plane_num,
/* Calculate the angle between the axes and the line crossing the
two points */
- angle = (atan2f (vertex_b[1] - vertex_a[1] *
- vertex_b[0] - vertex_a[0]),
- COGL_RADIANS_TO_DEGREES);
+ angle = atan2f (vertex_b[1] - vertex_a[1],
+ vertex_b[0] - vertex_a[0]) * (180.0/G_PI);
GE( cogl_wrap_glPushMatrix () );
/* Load the identity matrix and multiply by the reverse of the
@@ -558,15 +558,13 @@ cogl_perspective (float fovy,
* 2) When working with small numbers, we can are loosing significant
* precision
*/
- ymax = (zNear *
- (sinf (fovy_rad_half) /
- cosf (fovy_rad_half)));
+ ymax = (zNear * (sinf (fovy_rad_half) / cosf (fovy_rad_half)));
xmax = (ymax * aspect);
x = (zNear / xmax);
y = (zNear / ymax);
c = (-(zFar + zNear) / ( zFar - zNear));
- d = (-((2 * zFar * zNear)) / (zFar - zNear));
+ d = (-(2 * zFar) * zNear) / (zFar - zNear);
#define M(row,col) m[col*4+row]
M(0,0) = x;
@@ -671,13 +669,13 @@ cogl_setup_viewport (guint w,
if (fovy != 60.0)
{
float fovy_rad = (fovy * G_PI) / 180;
-
- z_camera = (sinf (fovy_rad) /
- cosf (fovy_rad)) >> 1;
+
+ z_camera = (sinf (fovy_rad) / cosf (fovy_rad)) / 2;
}
- GE( cogl_wrap_glTranslatex (-1 << 15, -1 << 15, -z_camera) );
+
+ GE( cogl_wrap_glTranslatex (-0.5f, -0.5f, -z_camera) );
GE( cogl_wrap_glScalex ( 1.0 / width,
-1.0 / height,

View File

@ -31,6 +31,8 @@ find ./clutter -iname '*.[ch]' -exec sed -i -r 's|COGL_FIXED_DIV (.*),|\1 /|g' {
# A fix due to the assumptions used above
sed -i 's/#define DET2X(a,b,c,d).*/#define DET2X(a,b,c,d) ((a * d) - (b * c))/g' ./clutter/clutter-actor.c
find ./clutter/cogl/gles -iname '*.[ch]' -exec sed -i 's/GLfixed/GLfloat/g' {} \;
#we get some redundant brackets like this, but C's automatic type promotion
#works out fine for most cases...
find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_INT//g' {} \;
@ -144,6 +146,10 @@ patch -p1<fixed-to-float-patches/gl-cogl.c
patch -p1<fixed-to-float-patches/cogl-pango-render.c.0.patch
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/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-primitives.c.0.patch
patch -p1<fixed-to-float-patches/gles-cogl-texture.c.0.patch
#XXX: COGL_PANGO_UNIT_TO_FIXED