Clear glErrors instead of crashing when initializing GLES3
This commit is contained in:
@ -399,40 +399,46 @@ void RasterizerGLES3::make_current() {
|
||||
void RasterizerGLES3::register_config() {
|
||||
}
|
||||
|
||||
// returns NULL if no error, or an error string
|
||||
const char *RasterizerGLES3::gl_check_for_error(bool p_print_error) {
|
||||
GLenum err = glGetError();
|
||||
|
||||
const char *err_string = nullptr;
|
||||
|
||||
switch (err) {
|
||||
default: {
|
||||
// not recognised
|
||||
} break;
|
||||
case GL_NO_ERROR: {
|
||||
} break;
|
||||
case GL_INVALID_ENUM: {
|
||||
err_string = "GL_INVALID_ENUM";
|
||||
} break;
|
||||
case GL_INVALID_VALUE: {
|
||||
err_string = "GL_INVALID_VALUE";
|
||||
} break;
|
||||
case GL_INVALID_OPERATION: {
|
||||
err_string = "GL_INVALID_OPERATION";
|
||||
} break;
|
||||
case GL_INVALID_FRAMEBUFFER_OPERATION: {
|
||||
err_string = "GL_INVALID_FRAMEBUFFER_OPERATION";
|
||||
} break;
|
||||
case GL_OUT_OF_MEMORY: {
|
||||
err_string = "GL_OUT_OF_MEMORY";
|
||||
} break;
|
||||
bool RasterizerGLES3::gl_check_errors() {
|
||||
bool error_found = false;
|
||||
GLenum error = glGetError();
|
||||
while (error != GL_NO_ERROR) {
|
||||
switch (error) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
case GL_INVALID_ENUM: {
|
||||
WARN_PRINT("GL_INVALID_ENUM: An unacceptable value is specified for an enumerated argument.");
|
||||
} break;
|
||||
case GL_INVALID_VALUE: {
|
||||
WARN_PRINT("GL_INVALID_VALUE: A numeric argument is out of range.");
|
||||
} break;
|
||||
case GL_INVALID_OPERATION: {
|
||||
WARN_PRINT("GL_INVALID_OPERATION: The specified operation is not allowed in the current state.");
|
||||
} break;
|
||||
case GL_INVALID_FRAMEBUFFER_OPERATION: {
|
||||
WARN_PRINT("GL_INVALID_FRAMEBUFFER_OPERATION: The framebuffer object is not complete.");
|
||||
} break;
|
||||
#endif // DEBUG_ENABLED
|
||||
case GL_OUT_OF_MEMORY: {
|
||||
ERR_PRINT("GL_OUT_OF_MEMORY: There is not enough memory left to execute the command. The state of the GL is undefined.");
|
||||
} break;
|
||||
// GL_STACK_UNDERFLOW and GL_STACK_OVERFLOW are undefined in GLES2/gl2.h, which is used when not using GLAD.
|
||||
//case GL_STACK_UNDERFLOW: {
|
||||
// ERR_PRINT("GL_STACK_UNDERFLOW: An attempt has been made to perform an operation that would cause an internal stack to underflow.");
|
||||
//} break;
|
||||
//case GL_STACK_OVERFLOW: {
|
||||
// ERR_PRINT("GL_STACK_OVERFLOW: An attempt has been made to perform an operation that would cause an internal stack to overflow.");
|
||||
//} break;
|
||||
default: {
|
||||
#ifdef DEBUG_ENABLED
|
||||
ERR_PRINT("Unrecognized GLError");
|
||||
#endif // DEBUG_ENABLED
|
||||
} break;
|
||||
}
|
||||
error_found = true;
|
||||
error = glGetError();
|
||||
}
|
||||
|
||||
if (p_print_error && err_string) {
|
||||
print_line(err_string);
|
||||
}
|
||||
|
||||
return err_string;
|
||||
return error_found;
|
||||
}
|
||||
|
||||
RasterizerGLES3::RasterizerGLES3() {
|
||||
|
||||
Reference in New Issue
Block a user