mutter/fixed-to-float-patches/gles-cogl.c.0.patch
Neil Roberts bef099ce40 [fixed-to-float-patches] Fix use of glClearColor and glColor under GLES 2
The wrapper for glClearColor was taking fixed arguments but was given
floating point values so it ended up always setting the clear color to
black. Now that GLES 1.1 is using the floating point version, there is
no need for the wrapper so both versions now just use glClearColor
directly.

A similar problem was happening for glColor but this does still need a
wrapper because it needs to set the vertex attribute.
2009-01-15 19:00:55 +00:00

112 lines
3.8 KiB
Diff

diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c
index 422d8b6..cb7aa8e 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
@@ -92,10 +93,10 @@ cogl_paint_init (const CoglColor *color)
fprintf(stderr, "\n ============== Paint Start ================ \n");
#endif
- cogl_wrap_glClearColorx (cogl_color_get_red (color),
- cogl_color_get_green (color),
- cogl_color_get_blue (color),
- 0);
+ glClearColor (cogl_color_get_red (color),
+ cogl_color_get_green (color),
+ cogl_color_get_blue (color),
+ 0);
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
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
@@ -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,
* 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,
@@ -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