add checkGLError
This commit is contained in:
parent
1fe30cc71f
commit
db1b050d59
32
checkGLError/checkGLError.cc
Normal file
32
checkGLError/checkGLError.cc
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "checkGLError.h"
|
||||
|
||||
#define checkGLErrorCase(e) \
|
||||
case (e): sprintf(msg, #e); break
|
||||
|
||||
GLenum _checkGLError(const char *fname, int lineno)
|
||||
{
|
||||
char msg[40];
|
||||
GLenum e;
|
||||
|
||||
sprintf(msg, "Unknown");
|
||||
e = glGetError();
|
||||
switch (e)
|
||||
{
|
||||
checkGLErrorCase(GL_NO_ERROR);
|
||||
checkGLErrorCase(GL_INVALID_ENUM);
|
||||
checkGLErrorCase(GL_INVALID_VALUE);
|
||||
checkGLErrorCase(GL_INVALID_OPERATION);
|
||||
checkGLErrorCase(GL_STACK_OVERFLOW);
|
||||
checkGLErrorCase(GL_STACK_UNDERFLOW);
|
||||
checkGLErrorCase(GL_OUT_OF_MEMORY);
|
||||
checkGLErrorCase(GL_TABLE_TOO_LARGE);
|
||||
}
|
||||
|
||||
if (e != GL_NO_ERROR)
|
||||
fprintf(stderr, "GL error %s at %s:%d\n", msg, fname, lineno);
|
||||
|
||||
return e;
|
||||
}
|
12
checkGLError/checkGLError.h
Normal file
12
checkGLError/checkGLError.h
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
#ifndef CHECKGLERROR_H
|
||||
#define CHECKGLERROR_H
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
#define checkGLError() _checkGLError(__FILE__, __LINE__)
|
||||
#define GL_CHECK(x) ({x; checkGLError();})
|
||||
|
||||
GLenum _checkGLError(const char *fname, int lineno);
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user