rlCheckErrors (#1321)

* rlglCheckErrors

* rlglCheckErrors LOG_WARNING

* rename to rlCheckErrors; improve messages; revert core.c
This commit is contained in:
seanpringle 2020-07-30 20:50:20 +10:00 committed by GitHub
parent 9c2ff464b0
commit 1d895616f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 40 additions and 0 deletions

View File

@ -519,6 +519,7 @@ RLAPI unsigned int rlLoadAttribBuffer(unsigned int vaoId, int shaderLoc, void *b
RLAPI void rlglInit(int width, int height); // Initialize rlgl (buffers, shaders, textures, states)
RLAPI void rlglClose(void); // De-inititialize rlgl (buffers, shaders, textures)
RLAPI void rlglDraw(void); // Update and draw default internal buffers
RLAPI void rlCheckErrors(void); // Check and log OpenGL error codes
RLAPI int rlGetVersion(void); // Returns current OpenGL version
RLAPI bool rlCheckBufferLimit(int vCount); // Check internal buffer overflow for a given number of vertex
@ -1794,6 +1795,45 @@ void rlglDraw(void)
#endif
}
// Check and log OpenGL error codes
void rlCheckErrors() {
#if defined(GRAPHICS_API_OPENGL_21) || defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
int check = 1;
while (check) {
const GLenum err = glGetError();
switch (err) {
case GL_NO_ERROR:
check = 0;
break;
case 0x0500: // GL_INVALID_ENUM:
TRACELOG(LOG_WARNING, "GL: Error detected: GL_INVALID_ENUM");
break;
case 0x0501: //GL_INVALID_VALUE:
TRACELOG(LOG_WARNING, "GL: Error detected: GL_INVALID_VALUE");
break;
case 0x0502: //GL_INVALID_OPERATION:
TRACELOG(LOG_WARNING, "GL: Error detected: GL_INVALID_OPERATION");
break;
case 0x0503: // GL_STACK_OVERFLOW:
TRACELOG(LOG_WARNING, "GL: Error detected: GL_STACK_OVERFLOW");
break;
case 0x0504: // GL_STACK_UNDERFLOW:
TRACELOG(LOG_WARNING, "GL: Error detected: GL_STACK_UNDERFLOW");
break;
case 0x0505: // GL_OUT_OF_MEMORY:
TRACELOG(LOG_WARNING, "GL: Error detected: GL_OUT_OF_MEMORY");
break;
case 0x0506: // GL_INVALID_FRAMEBUFFER_OPERATION:
TRACELOG(LOG_WARNING, "GL: Error detected: GL_INVALID_FRAMEBUFFER_OPERATION");
break;
default:
TRACELOG(LOG_WARNING, "GL: Error detected: unknown error code %x", err);
break;
}
}
#endif
}
// Returns current OpenGL version
int rlGetVersion(void)
{