kRogue
10-19-2011, 04:19 AM
Hunting down GL errors is.. painful. Worse the return values from glGetError() are at times not very informative.
Here is an idea: an error object:
/*
new tokens
*/
#define GL_SUCCEED 0xXXXX
#define GL_FAIL 0xXXXX
#define GL_ERROR_MESSAGE 0xXXXX
#define GL_ERROR_CODE 0xXXXX
/*
if there is an error, returns a non-zero integer
giving the name of an error object. If there is no
GL-error then returns 0.
*/
GLuint glGetErrorObject(void);
/*
Deletes an error object as returned by glGetErrorObject.
If an invalid object is passed, returns GL_FAIL, otherwise
delete the passed error object and returns GL_SUCCEED.
*/
GLenum glDeleteErrorObject(GLuint);
/*
query a property of an error object. If the property name, pname,
is valid, write the value of the property to v and return GL_SUCCEED.
If the property does not exist, return GL_FAIL and the contents of v are
unaffected, otherwise.
*/
GLenum glQueryErrorObject[][](GLuint error_object, GLenum pname, GLtype *v);
/*
query a string property of the error object.
Returns GL_SUCCEED is property exists and is a string,
otherwise returns GL_FAIL and does not affect the contents
pointed to by errorMessage or length.
\param errorMessage buffer to which to write the string
\param bufSize size of buffer pointed to by errorMessage
\param length, if NON-null write to length the size
of the string being queried
\param error_object Error object to query
\param pname property string to query
*/
GLenum glQueryErrorObjectString(GLuint error_object, GLenum pname,
GLsizei bufSize, GLsizei *length,
GLchar *errorMessage);
/*
1) How do glGetErrorObject and glGetError interact?
Answer: calling glGetErrorObject removes the error
from GL as does glGetError.
2) Why not use the debug ARB extension?
Answer: a number of systems use macros to query GL errors
immediately after a GL call to get line and file information of
the GL error. The ARB debug extension does not expose a simple
direct method for a C program to get the line and file of the
offending GL calls.
3) Why do the functions return a success code?
Answer: it is bad taste to generate an error while querying an error.
4) What are the base properties proposed?
Answer: For now atleast:
GL_ERROR_CODE is the error code ala glGetError
GL_ERROR_MESSAGE is an implementation dependent string to articulate the error
This proposal is written so that other error information
can be added, even warning messages.
*/
Here is an idea: an error object:
/*
new tokens
*/
#define GL_SUCCEED 0xXXXX
#define GL_FAIL 0xXXXX
#define GL_ERROR_MESSAGE 0xXXXX
#define GL_ERROR_CODE 0xXXXX
/*
if there is an error, returns a non-zero integer
giving the name of an error object. If there is no
GL-error then returns 0.
*/
GLuint glGetErrorObject(void);
/*
Deletes an error object as returned by glGetErrorObject.
If an invalid object is passed, returns GL_FAIL, otherwise
delete the passed error object and returns GL_SUCCEED.
*/
GLenum glDeleteErrorObject(GLuint);
/*
query a property of an error object. If the property name, pname,
is valid, write the value of the property to v and return GL_SUCCEED.
If the property does not exist, return GL_FAIL and the contents of v are
unaffected, otherwise.
*/
GLenum glQueryErrorObject[][](GLuint error_object, GLenum pname, GLtype *v);
/*
query a string property of the error object.
Returns GL_SUCCEED is property exists and is a string,
otherwise returns GL_FAIL and does not affect the contents
pointed to by errorMessage or length.
\param errorMessage buffer to which to write the string
\param bufSize size of buffer pointed to by errorMessage
\param length, if NON-null write to length the size
of the string being queried
\param error_object Error object to query
\param pname property string to query
*/
GLenum glQueryErrorObjectString(GLuint error_object, GLenum pname,
GLsizei bufSize, GLsizei *length,
GLchar *errorMessage);
/*
1) How do glGetErrorObject and glGetError interact?
Answer: calling glGetErrorObject removes the error
from GL as does glGetError.
2) Why not use the debug ARB extension?
Answer: a number of systems use macros to query GL errors
immediately after a GL call to get line and file information of
the GL error. The ARB debug extension does not expose a simple
direct method for a C program to get the line and file of the
offending GL calls.
3) Why do the functions return a success code?
Answer: it is bad taste to generate an error while querying an error.
4) What are the base properties proposed?
Answer: For now atleast:
GL_ERROR_CODE is the error code ala glGetError
GL_ERROR_MESSAGE is an implementation dependent string to articulate the error
This proposal is written so that other error information
can be added, even warning messages.
*/