* 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 091c79b9ae
commit eccd9399e5
6 changed files with 57 additions and 42 deletions

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), \
__FILE__, __LINE__); \
(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++) {