Search
lxdream.org :: lxdream :: r1150:1038800cecd8
lxdream 0.9.1
released Jun 29
Download Now
changeset1150:1038800cecd8
parent1149:da6124fceec6
child1151:e1848ca9b5b1
authornkeynes
dateThu Nov 11 17:51:37 2010 +1000 (9 years ago)
Add convenience gl_check_error() function
src/pvr2/glutil.c
src/pvr2/glutil.h
1.1 --- a/src/pvr2/glutil.c Wed Nov 10 08:37:42 2010 +1000
1.2 +++ b/src/pvr2/glutil.c Thu Nov 11 17:51:37 2010 +1000
1.3 @@ -167,3 +167,27 @@
1.4 display_driver->print_info(out);
1.5 }
1.6 }
1.7 +
1.8 +gboolean gl_check_error(const char *context)
1.9 +{
1.10 + GLint err = glGetError();
1.11 + if( err != 0 ) {
1.12 + const char *s;
1.13 + switch( err ) {
1.14 + case GL_INVALID_ENUM: s = "Invalid enum"; break;
1.15 + case GL_INVALID_VALUE: s = "Invalid value"; break;
1.16 + case GL_INVALID_OPERATION: s = "Invalid operation"; break;
1.17 + case GL_STACK_OVERFLOW: s = "Stack overflow"; break;
1.18 + case GL_STACK_UNDERFLOW: s = "Stack underflow"; break;
1.19 + case GL_OUT_OF_MEMORY: s = "Out of memory"; break;
1.20 + default: s = "Unknown error"; break;
1.21 + }
1.22 + if( context ) {
1.23 + WARN( "%s: GL error: %x (%s)\n", context, err, s );
1.24 + } else {
1.25 + WARN( "GL error: %x (%s)\n", err, s );
1.26 + }
1.27 + return TRUE;
1.28 + }
1.29 + return FALSE;
1.30 +}
2.1 --- a/src/pvr2/glutil.h Wed Nov 10 08:37:42 2010 +1000
2.2 +++ b/src/pvr2/glutil.h Thu Nov 11 17:51:37 2010 +1000
2.3 @@ -40,6 +40,12 @@
2.4 void glPrintInfo( FILE *out );
2.5
2.6 /**
2.7 + * Check for a GL error and print a message if there is one
2.8 + * @param context If not null, a string to be printed along side an error message
2.9 + * @return TRUE if there was an error, otherwise FALSE
2.10 + */
2.11 +gboolean gl_check_error( const char *context );
2.12 +/**
2.13 * Test if secondary color (GL_COLOR_SUM) is supported.
2.14 */
2.15 gboolean isGLSecondaryColorSupported();
.