[Automatic fixed-to-float.sh change] Applies a number fixed to float patches

To deal with all the corner cases that couldn't be scripted a number of patches
were written for the remaining 10% of the effort.

Note: again no API changes were made in Clutter, only in Cogl.
This commit is contained in:
Robert Bragg 2009-01-20 16:20:54 +00:00
parent 3336359abb
commit 4e60f2f5b0
16 changed files with 171 additions and 396 deletions

View File

@ -68,7 +68,7 @@ void cogl_color_set_from_4d (CoglColor *dest,
gdouble alpha); gdouble alpha);
/** /**
* cogl_color_set_from_4x: * cogl_color_set_from_4f:
* @dest: return location for a #CoglColor * @dest: return location for a #CoglColor
* @red: value of the red channel, between 0 and %1.0 * @red: value of the red channel, between 0 and %1.0
* @green: value of the green channel, between 0 and %1.0 * @green: value of the green channel, between 0 and %1.0
@ -79,7 +79,7 @@ void cogl_color_set_from_4d (CoglColor *dest,
* *
* Since: 1.0 * Since: 1.0
*/ */
void cogl_color_set_from_4x (CoglColor *dest, void cogl_color_set_from_4f (CoglColor *dest,
float red, float red,
float green, float green,
float blue, float blue,
@ -248,7 +248,7 @@ float cogl_color_get_alpha (const CoglColor *color);
* Sets the source color using normalized values for each component. * Sets the source color using normalized values for each component.
* This color will be used for any subsequent drawing operation. * This color will be used for any subsequent drawing operation.
* *
* See also cogl_set_source_color4ub() and cogl_set_source_color4x() * See also cogl_set_source_color4ub() and cogl_set_source_color4f()
* if you already have the color components. * if you already have the color components.
* *
* Since: 1.0 * Since: 1.0
@ -276,7 +276,7 @@ void cogl_set_source_color4ub (guint8 red,
guint8 alpha); guint8 alpha);
/** /**
* cogl_set_source_color4x: * cogl_set_source_color4f:
* @red: value of the red channel, between 0 and %1.0 * @red: value of the red channel, between 0 and %1.0
* @green: value of the green channel, between 0 and %1.0 * @green: value of the green channel, between 0 and %1.0
* @blue: value of the blue channel, between 0 and %1.0 * @blue: value of the blue channel, between 0 and %1.0
@ -291,7 +291,7 @@ void cogl_set_source_color4ub (guint8 red,
* *
* Since: 1.0 * Since: 1.0
*/ */
void cogl_set_source_color4x (float red, void cogl_set_source_color4f (float red,
float green, float green,
float blue, float blue,
float alpha); float alpha);

View File

@ -455,6 +455,18 @@ G_BEGIN_DECLS
*/ */
CoglFixed cogl_fixed_sin (CoglFixed angle); CoglFixed cogl_fixed_sin (CoglFixed angle);
/**
* cogl_fixed_tan:
* @angle: a #CoglFixed number
*
* Computes the tangent of @angle.
*
* Return value: the tangent of the passed angle, in fixed point notation
*
* Since: 1.0
*/
CoglFixed cogl_fixed_tan (CoglFixed angle);
/** /**
* cogl_fixed_cos: * cogl_fixed_cos:
* @angle: a #CoglFixed number * @angle: a #CoglFixed number

View File

@ -60,21 +60,7 @@ G_BEGIN_DECLS
* Fills a rectangle at the given coordinates with the current * Fills a rectangle at the given coordinates with the current
* drawing color in a highly optimizied fashion. * drawing color in a highly optimizied fashion.
**/ **/
void cogl_rectangle (gint x, void cogl_rectangle (float x,
gint y,
guint width,
guint height);
/**
* cogl_rectanglex:
* @x: X coordinate of the top-left corner
* @y: Y coordinate of the top-left corner
* @width: Width of the rectangle
* @height: Height of the rectangle
*
* A fixed-point version of cogl_fast_fill_rectangle.
**/
void cogl_rectanglex (float x,
float y, float y,
float width, float width,
float height); float height);

View File

@ -231,7 +231,7 @@ void cogl_scale (float x,
float y); float y);
/** /**
* cogl_translatex: * cogl_translate:
* @x: Distance to translate along the x-axis * @x: Distance to translate along the x-axis
* @y: Distance to translate along the y-axis * @y: Distance to translate along the y-axis
* @z: Distance to translate along the z-axis * @z: Distance to translate along the z-axis
@ -239,26 +239,12 @@ void cogl_scale (float x,
* Multiplies the current model-view matrix by one that translates the * Multiplies the current model-view matrix by one that translates the
* model along all three axes according to the given values. * model along all three axes according to the given values.
*/ */
void cogl_translatex (float x, void cogl_translate (float x,
float y, float y,
float z); float z);
/** /**
* cogl_translate: * cogl_rotate:
* @x: Distance to translate along the x-axis
* @y: Distance to translate along the y-axis
* @z: Distance to translate along the z-axis
*
* Integer version of cogl_translatex(). Multiplies the current
* model-view matrix by one that translates the model along all three
* axes according to the given values.
*/
void cogl_translate (gint x,
gint y,
gint z);
/**
* cogl_rotatex:
* @angle: Angle in degrees to rotate. * @angle: Angle in degrees to rotate.
* @x: X-component of vertex to rotate around. * @x: X-component of vertex to rotate around.
* @y: Y-component of vertex to rotate around. * @y: Y-component of vertex to rotate around.
@ -270,26 +256,10 @@ void cogl_translate (gint x,
* degrees about the vertex (0, 0, 1) causes a small counter-clockwise * degrees about the vertex (0, 0, 1) causes a small counter-clockwise
* rotation. * rotation.
*/ */
void cogl_rotatex (float angle, void cogl_rotate (float angle,
gint x, float x,
gint y, float y,
gint z); float z);
/**
* cogl_rotate:
* @angle: Angle in degrees to rotate.
* @x: X-component of vertex to rotate around.
* @y: Y-component of vertex to rotate around.
* @z: Z-component of vertex to rotate around.
*
* Integer version of cogl_rotatex(). Multiplies the current
* model-view matrix by one that rotates the model around the vertex
* specified by @x, @y and @z.
*/
void cogl_rotate (gint angle,
gint x,
gint y,
gint z);
/** /**
* cogl_get_modelview_matrix: * cogl_get_modelview_matrix:

View File

@ -58,7 +58,7 @@ cogl_color_set_from_4d (CoglColor *dest,
} }
void void
cogl_color_set_from_4x (CoglColor *dest, cogl_color_set_from_4f (CoglColor *dest,
float red, float red,
float green, float green,
float blue, float blue,
@ -157,13 +157,13 @@ cogl_set_source_color4ub (guint8 red,
} }
void void
cogl_set_source_color4x (float red, cogl_set_source_color4f (float red,
float green, float green,
float blue, float blue,
float alpha) float alpha)
{ {
CoglColor c = { 0, }; CoglColor c = { 0, };
cogl_color_set_from_4x (&c, red, green, blue, alpha); cogl_color_set_from_4f (&c, red, green, blue, alpha);
cogl_set_source_color (&c); cogl_set_source_color (&c);
} }

View File

@ -481,6 +481,12 @@ cogl_angle_sin (CoglAngle angle)
return result; return result;
} }
CoglFixed
cogl_fixed_tan (CoglFixed angle)
{
return cogl_angle_tan (COGL_ANGLE_FROM_DEGX (angle));
}
CoglFixed CoglFixed
cogl_angle_tan (CoglAngle angle) cogl_angle_tan (CoglAngle angle)
{ {

View File

@ -33,6 +33,7 @@
#include <string.h> #include <string.h>
#include <gmodule.h> #include <gmodule.h>
#include <math.h>
#define _COGL_MAX_BEZ_RECURSE_DEPTH 16 #define _COGL_MAX_BEZ_RECURSE_DEPTH 16
@ -42,37 +43,21 @@ void _cogl_path_add_node (gboolean new_sub_path,
float y); float y);
void _cogl_path_fill_nodes (); void _cogl_path_fill_nodes ();
void _cogl_path_stroke_nodes (); void _cogl_path_stroke_nodes ();
void _cogl_rectangle (gint x, void _cogl_rectangle (float x,
gint y,
guint width,
guint height);
void _cogl_rectanglex (float x,
float y, float y,
float width, float width,
float height); float height);
void void
cogl_rectangle (gint x, cogl_rectangle (float x,
gint y,
guint width,
guint height)
{
cogl_clip_ensure ();
_cogl_rectangle (x, y, width, height);
}
void
cogl_rectanglex (float x,
float y, float y,
float width, float width,
float height) float height)
{ {
cogl_clip_ensure (); cogl_clip_ensure ();
_cogl_rectanglex (x, y, width, height); _cogl_rectangle (x, y, width, height);
} }
void void
cogl_path_fill (void) cogl_path_fill (void)
{ {

View File

@ -89,7 +89,7 @@ cogl_path_stroke
cogl_path_stroke_preserve cogl_path_stroke_preserve
cogl_set_source_color cogl_set_source_color
cogl_set_source_color4ub cogl_set_source_color4ub
cogl_set_source_color4x cogl_set_source_color4f
<SUBSECTION> <SUBSECTION>
cogl_rectangle cogl_rectangle
@ -257,7 +257,7 @@ cogl_color_copy
cogl_color_free cogl_color_free
cogl_color_set_from_4ub cogl_color_set_from_4ub
cogl_color_set_from_4d cogl_color_set_from_4d
cogl_color_set_from_4x cogl_color_set_from_4f
<SUBSECTION> <SUBSECTION>
cogl_color_get_red cogl_color_get_red

View File

@ -34,26 +34,12 @@
#include <string.h> #include <string.h>
#include <gmodule.h> #include <gmodule.h>
#include <math.h>
#define _COGL_MAX_BEZ_RECURSE_DEPTH 16 #define _COGL_MAX_BEZ_RECURSE_DEPTH 16
void void
_cogl_rectangle (gint x, _cogl_rectangle (float x,
gint y,
guint width,
guint height)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_enable (ctx->color_alpha < 255
? COGL_ENABLE_BLEND : 0);
GE( glRecti (x, y, x + width, y + height) );
}
void
_cogl_rectanglex (float x,
float y, float y,
float width, float width,
float height) float height)
@ -63,10 +49,7 @@ _cogl_rectanglex (float x,
cogl_enable (ctx->color_alpha < 255 cogl_enable (ctx->color_alpha < 255
? COGL_ENABLE_BLEND : 0); ? COGL_ENABLE_BLEND : 0);
GE( glRectf ( (x), GE( glRectf (x, y, x + width, y + height) );
(y),
(x + width),
(y + height)) );
} }
void void
@ -131,17 +114,15 @@ _cogl_path_stroke_nodes ()
static void static void
_cogl_path_get_bounds (floatVec2 nodes_min, _cogl_path_get_bounds (floatVec2 nodes_min,
floatVec2 nodes_max, floatVec2 nodes_max,
gint *bounds_x, float *bounds_x,
gint *bounds_y, float *bounds_y,
guint *bounds_w, float *bounds_w,
guint *bounds_h) float *bounds_h)
{ {
*bounds_x = floorf (nodes_min.x); *bounds_x = nodes_min.x;
*bounds_y = floorf (nodes_min.y); *bounds_y = nodes_min.y;
*bounds_w = ceilf (nodes_max.x *bounds_w = nodes_max.x - *bounds_x;
- (float)(*bounds_x)); *bounds_h = nodes_max.y - *bounds_y;
*bounds_h = ceilf (nodes_max.y
- (float)(*bounds_y));
} }
void void
@ -153,10 +134,10 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
{ {
guint path_start = 0; guint path_start = 0;
guint sub_path_num = 0; guint sub_path_num = 0;
gint bounds_x; float bounds_x;
gint bounds_y; float bounds_y;
guint bounds_w; float bounds_w;
guint bounds_h; float bounds_h;
_cogl_path_get_bounds (nodes_min, nodes_max, _cogl_path_get_bounds (nodes_min, nodes_max,
&bounds_x, &bounds_y, &bounds_w, &bounds_h); &bounds_x, &bounds_y, &bounds_w, &bounds_h);
@ -238,10 +219,10 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
void void
_cogl_path_fill_nodes () _cogl_path_fill_nodes ()
{ {
gint bounds_x; float bounds_x;
gint bounds_y; float bounds_y;
guint bounds_w; float bounds_w;
guint bounds_h; float bounds_h;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);

View File

@ -37,6 +37,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h>
/* /*
#define COGL_DEBUG 1 #define COGL_DEBUG 1
@ -555,7 +556,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex,
guint wx, wy; guint wx, wy;
src = source_bmp->data src = source_bmp->data
+ (src_y + (y_iter.intersect_start) + (src_y + ((int)y_iter.intersect_start)
- dst_y) - dst_y)
* source_bmp->rowstride * source_bmp->rowstride
+ (src_x + x_span->start + x_span->size - x_span->waste + (src_x + x_span->start + x_span->size - x_span->waste
@ -600,7 +601,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex,
guint copy_width; guint copy_width;
src = source_bmp->data src = source_bmp->data
+ (src_x + (x_iter.intersect_start) + (src_x + ((int)x_iter.intersect_start)
- dst_x) - dst_x)
* bpp * bpp
+ (src_y + y_span->start + y_span->size - y_span->waste + (src_y + y_span->start + y_span->size - y_span->waste

113
gl/cogl.c
View File

@ -211,38 +211,21 @@ cogl_pop_matrix (void)
void void
cogl_scale (float x, float y) cogl_scale (float x, float y)
{ {
glScaled ((double)(x), glScalef ((float)(x),
(double)(y), (float)(y),
1.0); 1.0);
} }
void void
cogl_translatex (float x, float y, float z) cogl_translate (float x, float y, float z)
{ {
glTranslated ((double)(x), glTranslatef (x, y, z);
(double)(y),
(double)(z));
} }
void void
cogl_translate (gint x, gint y, gint z) cogl_rotate (float angle, float x, float y, float z)
{ {
glTranslatef ((float)x, (float)y, (float)z); glRotatef (angle, x, y, z);
}
void
cogl_rotatex (float angle, gint x, gint y, gint z)
{
glRotated ((double)(angle),
(double)(x),
(double)(y),
(double)(z));
}
void
cogl_rotate (gint angle, gint x, gint y, gint z)
{
glRotatef ((float)angle, (float)x, (float)y, (float)z);
} }
static inline gboolean static inline gboolean
@ -645,17 +628,13 @@ cogl_perspective (float fovy,
* 2) When working with small numbers, we are loosing significant * 2) When working with small numbers, we are loosing significant
* precision * precision
*/ */
ymax = ymax = (zNear * (sinf (fovy_rad_half) / cosf (fovy_rad_half)));
(zNear *
(sinf (fovy_rad_half) /
cosf (fovy_rad_half)));
xmax = (ymax * aspect); xmax = (ymax * aspect);
x = (zNear / xmax); x = (zNear / xmax);
y = (zNear / ymax); y = (zNear / ymax);
c = (-(zFar + zNear) / ( zFar - zNear)); c = (-(zFar + zNear) / ( zFar - zNear));
d = cogl_fixed_mul_div (-(2 * zFar), zNear, (zFar - zNear)); d = (-(2 * zFar) * zNear) / (zFar - zNear);
#define M(row,col) m[col*4+row] #define M(row,col) m[col*4+row]
M(0,0) = (x); M(0,0) = (x);
@ -696,12 +675,12 @@ cogl_frustum (float left,
GE( glMatrixMode (GL_PROJECTION) ); GE( glMatrixMode (GL_PROJECTION) );
GE( glLoadIdentity () ); GE( glLoadIdentity () );
GE( glFrustum ((double)(left), GE( glFrustum ((GLdouble)(left),
(double)(right), (GLdouble)(right),
(double)(bottom), (GLdouble)(bottom),
(double)(top), (GLdouble)(top),
(double)(z_near), (GLdouble)(z_near),
(double)(z_far)) ); (GLdouble)(z_far)) );
GE( glMatrixMode (GL_MODELVIEW) ); GE( glMatrixMode (GL_MODELVIEW) );
@ -773,9 +752,7 @@ cogl_setup_viewport (guint width,
{ {
float fovy_rad = (fovy * G_PI) / 180; float fovy_rad = (fovy * G_PI) / 180;
z_camera = z_camera = ((sinf (fovy_rad) / cosf (fovy_rad)) / 2);
((sinf (fovy_rad) /
cosf (fovy_rad)) >> 1);
} }
GE( glTranslatef (-0.5f, -0.5f, -z_camera) ); GE( glTranslatef (-0.5f, -0.5f, -z_camera) );
@ -1166,73 +1143,19 @@ cogl_features_available (CoglFeatureFlags features)
void void
cogl_get_modelview_matrix (float m[16]) cogl_get_modelview_matrix (float m[16])
{ {
GLdouble md[16]; glGetFloatv (GL_MODELVIEW_MATRIX, m);
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
} }
void void
cogl_get_projection_matrix (float m[16]) cogl_get_projection_matrix (float m[16])
{ {
GLdouble md[16]; glGetFloatv (GL_PROJECTION_MATRIX, m);
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
} }
void void
cogl_get_viewport (float v[4]) cogl_get_viewport (float v[4])
{ {
GLdouble vd[4]; glGetFloatv (GL_VIEWPORT, v);
glGetDoublev(GL_VIEWPORT, &vd[0]);
v[0] = (vd[0]);
v[1] = (vd[1]);
v[2] = (vd[2]);
v[3] = (vd[3]);
} }
void void

View File

@ -514,15 +514,6 @@ cogl_gles2_wrapper_update_matrix (CoglGles2Wrapper *wrapper, GLenum matrix_num)
} }
} }
void
cogl_wrap_glClearColorx (GLclampx r, GLclampx g, GLclampx b, GLclampx a)
{
glClearColor ( (r),
(g),
(b),
(a));
}
void void
cogl_wrap_glPushMatrix () cogl_wrap_glPushMatrix ()
{ {
@ -1143,13 +1134,9 @@ cogl_wrap_glAlphaFunc (GLenum func, GLclampf ref)
} }
void void
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, glVertexAttrib4f (COGL_GLES2_WRAPPER_COLOR_ATTRIB, r, g, b, a);
(r),
(g),
(b),
(a));
} }
void void
@ -1158,15 +1145,6 @@ cogl_wrap_glClipPlanef (GLenum plane, GLfloat *equation)
/* FIXME */ /* FIXME */
} }
static void
cogl_gles2_float_array_to_fixed (int size,
const GLfloat *floats,
GLfloat *fixeds)
{
while (size-- > 0)
*(fixeds++) = (*(floats++));
}
void void
cogl_wrap_glGetIntegerv (GLenum pname, GLint *params) cogl_wrap_glGetIntegerv (GLenum pname, GLint *params)
{ {
@ -1185,31 +1163,24 @@ cogl_wrap_glGetIntegerv (GLenum pname, GLint *params)
} }
void void
cogl_wrap_glGetFixedv (GLenum pname, GLfloat *params) cogl_wrap_glGetFloatv (GLenum pname, GLfloat *params)
{ {
_COGL_GET_GLES2_WRAPPER (w, NO_RETVAL); _COGL_GET_GLES2_WRAPPER (w, NO_RETVAL);
switch (pname) switch (pname)
{ {
case GL_MODELVIEW_MATRIX: case GL_MODELVIEW_MATRIX:
cogl_gles2_float_array_to_fixed (16, w->modelview_stack memcpy (params, w->modelview_stack + w->modelview_stack_pos * 16,
+ w->modelview_stack_pos * 16, sizeof (GLfloat) * 16);
params);
break; break;
case GL_PROJECTION_MATRIX: case GL_PROJECTION_MATRIX:
cogl_gles2_float_array_to_fixed (16, w->projection_stack memcpy (params, w->projection_stack + w->projection_stack_pos * 16,
+ w->projection_stack_pos * 16, sizeof (GLfloat) * 16);
params);
break; break;
case GL_VIEWPORT: case GL_VIEWPORT:
{ glGetFloatv (GL_VIEWPORT, params);
GLfloat v[4];
glGetFloatv (GL_VIEWPORT, v);
cogl_gles2_float_array_to_fixed (4, v, params);
}
break; break;
} }
} }

View File

@ -203,8 +203,6 @@ struct _CoglGles2WrapperShader
void cogl_gles2_wrapper_init (CoglGles2Wrapper *wrapper); void cogl_gles2_wrapper_init (CoglGles2Wrapper *wrapper);
void cogl_gles2_wrapper_deinit (CoglGles2Wrapper *wrapper); void cogl_gles2_wrapper_deinit (CoglGles2Wrapper *wrapper);
void cogl_wrap_glClearColorx (GLclampx r, GLclampx g, GLclampx b, GLclampx a);
void cogl_wrap_glPushMatrix (); void cogl_wrap_glPushMatrix ();
void cogl_wrap_glPopMatrix (); void cogl_wrap_glPopMatrix ();
void cogl_wrap_glMatrixMode (GLenum mode); void cogl_wrap_glMatrixMode (GLenum mode);
@ -239,12 +237,12 @@ void cogl_wrap_glDisableClientState (GLenum array);
void cogl_wrap_glAlphaFunc (GLenum func, GLclampf ref); void cogl_wrap_glAlphaFunc (GLenum func, GLclampf ref);
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_glClipPlanef (GLenum plane, GLfloat *equation); void cogl_wrap_glClipPlanef (GLenum plane, GLfloat *equation);
void cogl_wrap_glGetIntegerv (GLenum pname, GLint *params); 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_glFogf (GLenum pname, GLfloat param); void cogl_wrap_glFogf (GLenum pname, GLfloat param);
void cogl_wrap_glFogfv (GLenum pname, const GLfloat *params); 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 /* If we're not using GL ES 2 then just use the GL functions
directly */ directly */
#define cogl_wrap_glClearColorx glClearColorx
#define cogl_wrap_glDrawArrays glDrawArrays #define cogl_wrap_glDrawArrays glDrawArrays
#define cogl_wrap_glDrawElements glDrawElements #define cogl_wrap_glDrawElements glDrawElements
#define cogl_wrap_glPushMatrix glPushMatrix #define cogl_wrap_glPushMatrix glPushMatrix
#define cogl_wrap_glPopMatrix glPopMatrix #define cogl_wrap_glPopMatrix glPopMatrix
#define cogl_wrap_glMatrixMode glMatrixMode #define cogl_wrap_glMatrixMode glMatrixMode
#define cogl_wrap_glLoadIdentity glLoadIdentity #define cogl_wrap_glLoadIdentity glLoadIdentity
#define cogl_wrap_glMultMatrixf glMultMatrixx #define cogl_wrap_glMultMatrixf glMultMatrixf
#define cogl_wrap_glFrustumf glFrustumx #define cogl_wrap_glFrustumf glFrustumf
#define cogl_wrap_glScalef glScalex #define cogl_wrap_glScalef glScalef
#define cogl_wrap_glTranslatef glTranslatex #define cogl_wrap_glTranslatef glTranslatef
#define cogl_wrap_glRotatef glRotatex #define cogl_wrap_glRotatef glRotatef
#define cogl_wrap_glOrthof glOrthox #define cogl_wrap_glOrthof glOrthof
#define cogl_wrap_glEnable glEnable #define cogl_wrap_glEnable glEnable
#define cogl_wrap_glDisable glDisable #define cogl_wrap_glDisable glDisable
#define cogl_wrap_glTexCoordPointer glTexCoordPointer #define cogl_wrap_glTexCoordPointer glTexCoordPointer
#define cogl_wrap_glVertexPointer glVertexPointer #define cogl_wrap_glVertexPointer glVertexPointer
#define cogl_wrap_glColorPointer glColorPointer #define cogl_wrap_glColorPointer glColorPointer
#define cogl_wrap_glNormalPointer glNormalPointer #define cogl_wrap_glNormalPointer glNormalPointer
#define cogl_wrap_glTexEnvf glTexEnvx #define cogl_wrap_glTexEnvf glTexEnvf
#define cogl_wrap_glEnableClientState glEnableClientState #define cogl_wrap_glEnableClientState glEnableClientState
#define cogl_wrap_glDisableClientState glDisableClientState #define cogl_wrap_glDisableClientState glDisableClientState
#define cogl_wrap_glAlphaFunc glAlphaFunc #define cogl_wrap_glAlphaFunc glAlphaFunc
#define cogl_wrap_glColor4f glColor4x #define cogl_wrap_glColor4f glColor4f
#define cogl_wrap_glClipPlanef glClipPlanex #define cogl_wrap_glClipPlanef glClipPlanef
#define cogl_wrap_glGetIntegerv glGetIntegerv #define cogl_wrap_glGetIntegerv glGetIntegerv
#define cogl_wrap_glGetFixedv glGetFixedv #define cogl_wrap_glGetFloatv glGetFloatv
#define cogl_wrap_glFogf glFogx #define cogl_wrap_glFogf glFogf
#define cogl_wrap_glFogfv glFogxv #define cogl_wrap_glFogfv glFogfv
#define cogl_wrap_glTexParameteri glTexParameteri #define cogl_wrap_glTexParameteri glTexParameteri
/* The extra third parameter of the bind texture wrapper isn't needed /* The extra third parameter of the bind texture wrapper isn't needed

View File

@ -34,59 +34,31 @@
#include <string.h> #include <string.h>
#include <gmodule.h> #include <gmodule.h>
#include <math.h>
#define _COGL_MAX_BEZ_RECURSE_DEPTH 16 #define _COGL_MAX_BEZ_RECURSE_DEPTH 16
void void
_cogl_rectangle (gint x, _cogl_rectangle (float x,
gint y, float y,
guint width, float width,
guint height) float height)
{ {
/* 32-bit integers are not supported as coord types GLfloat rect_verts[8] = {
in GLES . Fixed type has got 16 bits left of the (GLfloat) x, (GLfloat) y,
point which is equal to short anyway. */ (GLfloat) (x + width), (GLfloat) y,
(GLfloat) x, (GLfloat) (y + height),
GLshort rect_verts[8] = { (GLfloat) (x + width), (GLfloat) (y + height)
(GLshort) x, (GLshort) y,
(GLshort) (x + width), (GLshort) y,
(GLshort) x, (GLshort) (y + height),
(GLshort) (x + width), (GLshort) (y + height)
}; };
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_enable (COGL_ENABLE_VERTEX_ARRAY cogl_enable (COGL_ENABLE_VERTEX_ARRAY
| (ctx->color_alpha < 255 ? COGL_ENABLE_BLEND : 0)); | (ctx->color_alpha < 255 ? COGL_ENABLE_BLEND : 0));
GE ( cogl_wrap_glVertexPointer (2, GL_SHORT, 0, rect_verts ) ); GE ( cogl_wrap_glVertexPointer (2, GL_FLOAT, 0, rect_verts ) );
GE ( cogl_wrap_glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) ); GE ( cogl_wrap_glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) );
} }
void
_cogl_rectanglex (float x,
float y,
float width,
float height)
{
GLfloat rect_verts[8] = {
x, y,
x + width, y,
x, y + height,
x + width, y + height
};
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_enable (COGL_ENABLE_VERTEX_ARRAY
| (ctx->color_alpha < 255
? COGL_ENABLE_BLEND : 0));
GE( cogl_wrap_glVertexPointer (2, GL_FIXED, 0, rect_verts) );
GE( cogl_wrap_glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) );
}
void void
_cogl_path_add_node (gboolean new_sub_path, _cogl_path_add_node (gboolean new_sub_path,
float x, float x,
@ -149,17 +121,15 @@ _cogl_path_stroke_nodes ()
static void static void
_cogl_path_get_bounds (floatVec2 nodes_min, _cogl_path_get_bounds (floatVec2 nodes_min,
floatVec2 nodes_max, floatVec2 nodes_max,
gint *bounds_x, float *bounds_x,
gint *bounds_y, float *bounds_y,
guint *bounds_w, float *bounds_w,
guint *bounds_h) float *bounds_h)
{ {
*bounds_x = floorf (nodes_min.x); *bounds_x = nodes_min.x;
*bounds_y = floorf (nodes_min.y); *bounds_y = nodes_min.y;
*bounds_w = ceilf (nodes_max.x *bounds_w = nodes_max.x - *bounds_x;
- (float)(*bounds_x)); *bounds_h = nodes_max.y - *bounds_y;
*bounds_h = ceilf (nodes_max.y
- (float)(*bounds_y));
} }
static gint compare_ints (gconstpointer a, static gint compare_ints (gconstpointer a,
@ -177,10 +147,10 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
{ {
guint path_start = 0; guint path_start = 0;
guint sub_path_num = 0; guint sub_path_num = 0;
gint bounds_x; float bounds_x;
gint bounds_y; float bounds_y;
guint bounds_w; float bounds_w;
guint bounds_h; float bounds_h;
_cogl_path_get_bounds (nodes_min, nodes_max, _cogl_path_get_bounds (nodes_min, nodes_max,
&bounds_x, &bounds_y, &bounds_w, &bounds_h); &bounds_x, &bounds_y, &bounds_w, &bounds_h);
@ -244,12 +214,8 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
GE( cogl_wrap_glMatrixMode (GL_PROJECTION) ); GE( cogl_wrap_glMatrixMode (GL_PROJECTION) );
GE( cogl_wrap_glPushMatrix () ); GE( cogl_wrap_glPushMatrix () );
GE( cogl_wrap_glLoadIdentity () ); GE( cogl_wrap_glLoadIdentity () );
cogl_rectanglex (-1.0, -1.0, cogl_rectangle (-1.0, -1.0, 2, 2);
(float)(2), cogl_rectangle (-1.0, -1.0, 2, 2);
(float)(2));
cogl_rectanglex (-1.0, -1.0,
(float)(2),
(float)(2));
GE( cogl_wrap_glPopMatrix () ); GE( cogl_wrap_glPopMatrix () );
GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) );
GE( cogl_wrap_glPopMatrix () ); GE( cogl_wrap_glPopMatrix () );
@ -435,10 +401,10 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path,
void void
_cogl_path_fill_nodes () _cogl_path_fill_nodes ()
{ {
gint bounds_x; float bounds_x;
gint bounds_y; float bounds_y;
guint bounds_w; float bounds_w;
guint bounds_h; float bounds_h;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);

View File

@ -39,6 +39,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h>
#define glVertexPointer cogl_wrap_glVertexPointer #define glVertexPointer cogl_wrap_glVertexPointer
#define glTexCoordPointer cogl_wrap_glTexCoordPointer #define glTexCoordPointer cogl_wrap_glTexCoordPointer
@ -768,7 +769,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex,
guint wx, wy; guint wx, wy;
src = source_bmp->data src = source_bmp->data
+ (src_y + (y_iter.intersect_start) + (src_y + ((int)y_iter.intersect_start)
- dst_y) - dst_y)
* source_bmp->rowstride * source_bmp->rowstride
+ (src_x + x_span->start + x_span->size - x_span->waste + (src_x + x_span->start + x_span->size - x_span->waste
@ -813,7 +814,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex,
guint copy_width; guint copy_width;
src = source_bmp->data src = source_bmp->data
+ (src_x + (x_iter.intersect_start) + (src_x + ((int)x_iter.intersect_start)
- dst_x) - dst_x)
* bpp * bpp
+ (src_y + y_span->start + y_span->size - y_span->waste + (src_y + y_span->start + y_span->size - y_span->waste

View File

@ -37,6 +37,7 @@
#include "cogl-context.h" #include "cogl-context.h"
#include "cogl-gles2-wrapper.h" #include "cogl-gles2-wrapper.h"
#include <math.h>
/* GL error to string conversion */ /* GL error to string conversion */
#if COGL_DEBUG #if COGL_DEBUG
@ -92,7 +93,7 @@ cogl_paint_init (const CoglColor *color)
fprintf(stderr, "\n ============== Paint Start ================ \n"); fprintf(stderr, "\n ============== Paint Start ================ \n");
#endif #endif
cogl_wrap_glClearColorx (cogl_color_get_red (color), glClearColor (cogl_color_get_red (color),
cogl_color_get_green (color), cogl_color_get_green (color),
cogl_color_get_blue (color), cogl_color_get_blue (color),
0); 0);
@ -122,37 +123,17 @@ cogl_scale (float x, float y)
} }
void void
cogl_translatex (float x, float y, float z) cogl_translate (float x, float y, float z)
{ {
GE( cogl_wrap_glTranslatef (x, y, z) ); GE( cogl_wrap_glTranslatef (x, y, z) );
} }
void void
cogl_translate (gint x, gint y, gint z) cogl_rotate (float angle, float x, float y, float z)
{
GE( cogl_wrap_glTranslatef ((float)(x),
(float)(y),
(float)(z)) );
}
void
cogl_rotatex (float angle,
float x,
float y,
float z)
{ {
GE( cogl_wrap_glRotatef (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_glRotatef ((float)(angle),
(float)(x),
(float)(y),
(float)(z)) );
}
static inline gboolean static inline gboolean
cogl_toggle_flag (CoglContext *ctx, cogl_toggle_flag (CoglContext *ctx,
gulong new_flags, gulong new_flags,
@ -365,9 +346,8 @@ set_clip_plane (GLint plane_num,
/* Calculate the angle between the axes and the line crossing the /* Calculate the angle between the axes and the line crossing the
two points */ two points */
angle = (atan2f (vertex_b[1] - vertex_a[1] * angle = atan2f (vertex_b[1] - vertex_a[1],
vertex_b[0] - vertex_a[0]), vertex_b[0] - vertex_a[0]) * (180.0/G_PI);
COGL_RADIANS_TO_DEGREES);
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 +385,8 @@ _cogl_set_clip_planes (float x_offset,
float vertex_br[4] = { x_offset + width, y_offset + height, float vertex_br[4] = { x_offset + width, y_offset + height,
0, 1.0 }; 0, 1.0 };
GE( cogl_wrap_glGetFixedv (GL_MODELVIEW_MATRIX, modelview) ); GE( cogl_wrap_glGetFloatv (GL_MODELVIEW_MATRIX, modelview) );
GE( cogl_wrap_glGetFixedv (GL_PROJECTION_MATRIX, projection) ); GE( cogl_wrap_glGetFloatv (GL_PROJECTION_MATRIX, projection) );
project_vertex (modelview, projection, vertex_tl); project_vertex (modelview, projection, vertex_tl);
project_vertex (modelview, projection, vertex_tr); project_vertex (modelview, projection, vertex_tr);
@ -457,7 +437,7 @@ _cogl_add_stencil_clip (float x_offset,
GE( glStencilFunc (GL_NEVER, 0x1, 0x1) ); GE( glStencilFunc (GL_NEVER, 0x1, 0x1) );
GE( glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) ); GE( glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) );
cogl_rectanglex (x_offset, y_offset, width, height); cogl_rectangle (x_offset, y_offset, width, height);
} }
else else
{ {
@ -465,7 +445,7 @@ _cogl_add_stencil_clip (float x_offset,
rectangle */ rectangle */
GE( glStencilFunc (GL_NEVER, 0x1, 0x3) ); GE( glStencilFunc (GL_NEVER, 0x1, 0x3) );
GE( glStencilOp (GL_INCR, GL_INCR, GL_INCR) ); GE( glStencilOp (GL_INCR, GL_INCR, GL_INCR) );
cogl_rectanglex (x_offset, y_offset, width, height); cogl_rectangle (x_offset, y_offset, width, height);
/* Subtract one from all pixels in the stencil buffer so that /* Subtract one from all pixels in the stencil buffer so that
only pixels where both the original stencil buffer and the only pixels where both the original stencil buffer and the
@ -476,9 +456,7 @@ _cogl_add_stencil_clip (float x_offset,
GE( cogl_wrap_glMatrixMode (GL_PROJECTION) ); GE( cogl_wrap_glMatrixMode (GL_PROJECTION) );
GE( cogl_wrap_glPushMatrix () ); GE( cogl_wrap_glPushMatrix () );
GE( cogl_wrap_glLoadIdentity () ); GE( cogl_wrap_glLoadIdentity () );
cogl_rectanglex (-1.0, -1.0, cogl_rectangle (-1.0, -1.0, 2, 2);
(float)(2),
(float)(2));
GE( cogl_wrap_glPopMatrix () ); GE( cogl_wrap_glPopMatrix () );
GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) );
GE( cogl_wrap_glPopMatrix () ); GE( cogl_wrap_glPopMatrix () );
@ -558,15 +536,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
*/ */
ymax = (zNear * ymax = (zNear * (sinf (fovy_rad_half) / cosf (fovy_rad_half)));
(sinf (fovy_rad_half) /
cosf (fovy_rad_half)));
xmax = (ymax * aspect); xmax = (ymax * aspect);
x = (zNear / xmax); x = (zNear / xmax);
y = (zNear / ymax); y = (zNear / ymax);
c = (-(zFar + zNear) / ( zFar - zNear)); 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] #define M(row,col) m[col*4+row]
M(0,0) = x; M(0,0) = x;
@ -672,12 +648,12 @@ cogl_setup_viewport (guint w,
{ {
float fovy_rad = (fovy * G_PI) / 180; float fovy_rad = (fovy * G_PI) / 180;
z_camera = (sinf (fovy_rad) / z_camera = (sinf (fovy_rad) / cosf (fovy_rad)) / 2;
cosf (fovy_rad)) >> 1;
} }
GE( cogl_wrap_glTranslatef (-1 << 15, -1 << 15, -z_camera) );
GE( cogl_wrap_glTranslatef (-0.5f, -0.5f, -z_camera) );
GE( cogl_wrap_glScalef ( 1.0 / width, GE( cogl_wrap_glScalef ( 1.0 / width,
-1.0 / height, -1.0 / height,
@ -737,13 +713,13 @@ cogl_features_available (CoglFeatureFlags features)
void void
cogl_get_modelview_matrix (float m[16]) cogl_get_modelview_matrix (float m[16])
{ {
cogl_wrap_glGetFixedv(GL_MODELVIEW_MATRIX, &m[0]); cogl_wrap_glGetFloatv (GL_MODELVIEW_MATRIX, m);
} }
void void
cogl_get_projection_matrix (float m[16]) cogl_get_projection_matrix (float m[16])
{ {
cogl_wrap_glGetFixedv(GL_PROJECTION_MATRIX, &m[0]); cogl_wrap_glGetFloatv (GL_PROJECTION_MATRIX, m);
} }
void void