2014-09-29 02:40:41 +00:00
|
|
|
/* KallistiGL for KallistiOS ##version##
|
|
|
|
|
|
|
|
libgl/gl-error.c
|
|
|
|
Copyright (C) 2014 Josh Pearson
|
2016-01-04 03:23:32 +00:00
|
|
|
Copyright (C) 2016 Lawrence Sebald
|
2017-07-22 20:00:33 +00:00
|
|
|
* Copyright (C) 2017 Luke Benstead
|
2014-09-29 02:40:41 +00:00
|
|
|
|
|
|
|
KOS Open GL State Machine Error Code Implementation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2021-04-09 15:24:47 +00:00
|
|
|
#include "private.h"
|
|
|
|
|
2021-09-13 09:29:04 +00:00
|
|
|
GLenum LAST_ERROR = GL_NO_ERROR;
|
|
|
|
char ERROR_FUNCTION[64] = { '\0' };
|
2014-09-29 02:40:41 +00:00
|
|
|
|
2016-01-04 03:23:32 +00:00
|
|
|
/* Quoth the GL Spec:
|
|
|
|
When an error occurs, the error flag is set to the appropriate error code
|
|
|
|
value. No other errors are recorded until glGetError is called, the error
|
|
|
|
code is returned, and the flag is reset to GL_NO_ERROR.
|
|
|
|
|
|
|
|
So, we only record an error here if the error code is currently unset.
|
|
|
|
Nothing in the spec requires recording multiple error flags, although it is
|
|
|
|
allowed by the spec. We take the easy way out for now. */
|
|
|
|
|
|
|
|
|
|
|
|
GLenum glGetError(void) {
|
2021-09-13 09:29:04 +00:00
|
|
|
GLenum rv = LAST_ERROR;
|
2017-07-22 20:00:33 +00:00
|
|
|
_glKosResetError();
|
2016-01-04 03:23:32 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
const GLubyte *gluErrorString(GLenum error) {
|
|
|
|
switch(error) {
|
|
|
|
case GL_NO_ERROR:
|
|
|
|
return (GLubyte *)"no error";
|
|
|
|
|
|
|
|
case GL_INVALID_ENUM:
|
|
|
|
return (GLubyte *)"invalid enumerant";
|
|
|
|
|
|
|
|
case GL_INVALID_OPERATION:
|
|
|
|
return (GLubyte *)"invalid operation";
|
|
|
|
|
|
|
|
case GL_INVALID_VALUE:
|
|
|
|
return (GLubyte *)"invalid value";
|
|
|
|
|
|
|
|
case GL_OUT_OF_MEMORY:
|
|
|
|
return (GLubyte *)"out of memory";
|
|
|
|
|
|
|
|
default:
|
|
|
|
return (GLubyte *)"unknown error";
|
|
|
|
}
|
|
|
|
}
|