* clutter/cogl/gl/cogl.c (error_string):

* clutter/cogl/gles/cogl.c (error_string): Rename to
	_cogl_error_string and remove the static scoping so that it can be
	called in cogl-texture etc.

	* clutter/cogl/gl/cogl-texture.c (cogl_texture_new_from_foreign):
	* clutter/cogl/gles/cogl-texture.c (cogl_texture_new_from_foreign):
	GE(*) can't be used to wrap around calls that use the return
	value.

	* clutter/cogl/gl/cogl-texture.c (_cogl_texture_quad_sw)
	(_cogl_texture_quad_hw, cogl_texture_polygon): Remove GE(*)
	wrapper around calls in the middle of a glBegin/glEnd pair which
	otherwise always generate an error because glGetError can only be
	called outside of the pair.

	* clutter/cogl/gl/cogl-internal.h: Include stdio.h when definig
	COGL_DEBUG and declare a prototype for _cogl_error_string.

	* clutter/cogl/gles/cogl-internal.h: Match GE(*) macro to GL
	version.
This commit is contained in:
Neil Roberts 2008-05-21 13:20:33 +00:00
parent 9f5a8edc64
commit f9e43c440b
7 changed files with 81 additions and 42 deletions

View File

@ -1,3 +1,27 @@
2008-05-21 Neil Roberts <neil@o-hand.com>
* clutter/cogl/gl/cogl.c (error_string):
* clutter/cogl/gles/cogl.c (error_string): Rename to
_cogl_error_string and remove the static scoping so that it can be
called in cogl-texture etc.
* clutter/cogl/gl/cogl-texture.c (cogl_texture_new_from_foreign):
* clutter/cogl/gles/cogl-texture.c (cogl_texture_new_from_foreign):
GE(*) can't be used to wrap around calls that use the return
value.
* clutter/cogl/gl/cogl-texture.c (_cogl_texture_quad_sw)
(_cogl_texture_quad_hw, cogl_texture_polygon): Remove GE(*)
wrapper around calls in the middle of a glBegin/glEnd pair which
otherwise always generate an error because glGetError can only be
called outside of the pair.
* clutter/cogl/gl/cogl-internal.h: Include stdio.h when definig
COGL_DEBUG and declare a prototype for _cogl_error_string.
* clutter/cogl/gles/cogl-internal.h: Match GE(*) macro to GL
version.
2008-05-21 Ivan Leben <ivan@o-hand.com>
* clutter/cogl/gles/cogl-texture.c:

View File

@ -29,18 +29,26 @@
#define COGL_DEBUG 0
#if COGL_DEBUG
#include <stdio.h>
const char *_cogl_error_string(GLenum errorCode);
#define GE(x...) G_STMT_START { \
GLenum err; \
(x); \
while ((err = glGetError()) != GL_NO_ERROR) { \
fprintf(stderr, "glError: %s caught at %s:%u\n", \
(char *)error_string(err), \
(char *)_cogl_error_string(err), \
__FILE__, __LINE__); \
} \
} G_STMT_END
#else
#else /* COGL_DEBUG */
#define GE(x) (x);
#endif
#endif /* COGL_DEBUG */
#define COGL_ENABLE_BLEND (1<<1)
#define COGL_ENABLE_TEXTURE_2D (1<<2)

View File

@ -1235,7 +1235,7 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
return COGL_INVALID_HANDLE;
/* Make sure it is a valid GL texture object */
gl_istexture = GE( glIsTexture (gl_handle) );
gl_istexture = glIsTexture (gl_handle);
if (gl_istexture == GL_FALSE)
return COGL_INVALID_HANDLE;
@ -1863,21 +1863,21 @@ _cogl_texture_quad_sw (CoglTexture *tex,
#define CFX_F CLUTTER_FIXED_TO_FLOAT
/* Draw textured quad */
GE( glBegin (GL_QUADS) );
glBegin (GL_QUADS);
GE( glTexCoord2f (CFX_F(slice_tx1), CFX_F(slice_ty1)) );
GE( glVertex2f (CFX_F(slice_qx1), CFX_F(slice_qy1)) );
glTexCoord2f (CFX_F(slice_tx1), CFX_F(slice_ty1));
glVertex2f (CFX_F(slice_qx1), CFX_F(slice_qy1));
GE( glTexCoord2f (CFX_F(slice_tx2), CFX_F(slice_ty1)) );
GE( glVertex2f (CFX_F(slice_qx2), CFX_F(slice_qy1)) );
glTexCoord2f (CFX_F(slice_tx2), CFX_F(slice_ty1));
glVertex2f (CFX_F(slice_qx2), CFX_F(slice_qy1));
GE( glTexCoord2f (CFX_F(slice_tx2), CFX_F(slice_ty2)) );
GE( glVertex2f (CFX_F(slice_qx2), CFX_F(slice_qy2)) );
glTexCoord2f (CFX_F(slice_tx2), CFX_F(slice_ty2));
glVertex2f (CFX_F(slice_qx2), CFX_F(slice_qy2));
GE( glTexCoord2f (CFX_F(slice_tx1), CFX_F(slice_ty2)) );
GE( glVertex2f (CFX_F(slice_qx1), CFX_F(slice_qy2)) );
glTexCoord2f (CFX_F(slice_tx1), CFX_F(slice_ty2));
glVertex2f (CFX_F(slice_qx1), CFX_F(slice_qy2));
glEnd ();
GE( glEnd () );
#undef CFX_F
}
@ -1946,21 +1946,21 @@ _cogl_texture_quad_hw (CoglTexture *tex,
#define CFX_F(x) CLUTTER_FIXED_TO_FLOAT(x)
/* Draw textured quad */
GE( glBegin (GL_QUADS) );
glBegin (GL_QUADS);
GE( glTexCoord2f (CFX_F(tx1), CFX_F(ty1)) );
GE( glVertex2f (CFX_F(x1), CFX_F(y1)) );
glTexCoord2f (CFX_F(tx1), CFX_F(ty1));
glVertex2f (CFX_F(x1), CFX_F(y1));
GE( glTexCoord2f (CFX_F(tx2), CFX_F(ty1)) );
GE( glVertex2f (CFX_F(x2), CFX_F(y1)) );
glTexCoord2f (CFX_F(tx2), CFX_F(ty1));
glVertex2f (CFX_F(x2), CFX_F(y1));
GE( glTexCoord2f (CFX_F(tx2), CFX_F(ty2)) );
GE( glVertex2f (CFX_F(x2), CFX_F(y2)) );
glTexCoord2f (CFX_F(tx2), CFX_F(ty2));
glVertex2f (CFX_F(x2), CFX_F(y2));
GE( glTexCoord2f (CFX_F(tx1), CFX_F(ty2)) );
GE( glVertex2f (CFX_F(x1), CFX_F(y2)) );
glTexCoord2f (CFX_F(tx1), CFX_F(ty2));
glVertex2f (CFX_F(x1), CFX_F(y2));
glEnd ();
GE( glEnd () );
#undef CFX_F
}
@ -2122,7 +2122,7 @@ cogl_texture_polygon (CoglHandle handle,
GE( glBindTexture (tex->gl_target, gl_handle) );
GE( glBegin (GL_TRIANGLE_FAN) );
glBegin (GL_TRIANGLE_FAN);
for (vnum = 0; vnum < n_vertices; vnum++)
{
@ -2146,11 +2146,11 @@ cogl_texture_polygon (CoglHandle handle,
ty *= y_span->size;
}
GE( glTexCoord2f (tx, ty) );
glTexCoord2f (tx, ty);
GE( glVertex3f (CLUTTER_FIXED_TO_FLOAT (vertices[vnum].x),
glVertex3f (CLUTTER_FIXED_TO_FLOAT (vertices[vnum].x),
CLUTTER_FIXED_TO_FLOAT (vertices[vnum].y),
CLUTTER_FIXED_TO_FLOAT (vertices[vnum].z)) );
CLUTTER_FIXED_TO_FLOAT (vertices[vnum].z));
}
GE( glEnd () );

View File

@ -66,8 +66,8 @@ static const struct token_string Errors[] = {
{ ~0, NULL }
};
static const char*
error_string(GLenum errorCode)
const char*
_cogl_error_string(GLenum errorCode)
{
int i;
for (i = 0; Errors[i].String; i++) {

View File

@ -29,19 +29,26 @@
#define COGL_DEBUG 0
#if COGL_DEBUG
#define GE(x...) { \
#include <stdio.h>
const char *_cogl_error_string(GLenum errorCode);
#define GE(x...) G_STMT_START { \
GLenum err; \
(x); \
fprintf(stderr, "%s\n", #x); \
while ((err = glGetError()) != GL_NO_ERROR) { \
fprintf(stderr, "glError: %s caught at %s:%u\n", \
(char *)error_string(err), \
(char *)_cogl_error_string(err), \
__FILE__, __LINE__); \
} \
}
#else
} G_STMT_END
#else /* COGL_DEBUG */
#define GE(x) (x);
#endif
#endif /* COGL_DEBUG */
#define COGL_ENABLE_BLEND (1<<1)
#define COGL_ENABLE_TEXTURE_2D (1<<2)

View File

@ -1248,7 +1248,7 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
return COGL_INVALID_HANDLE;
/* Make sure it is a valid GL texture object */
gl_istexture = GE( glIsTexture (gl_handle) );
gl_istexture = glIsTexture (gl_handle);
if (gl_istexture == GL_FALSE)
return COGL_INVALID_HANDLE;

View File

@ -59,8 +59,8 @@ static const struct token_string Errors[] = {
{ ~0, NULL }
};
static const char*
error_string(GLenum errorCode)
const char*
_cogl_error_string(GLenum errorCode)
{
int i;
for (i = 0; Errors[i].String; i++) {