engine flag for opengl error calls
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-25 09:34:07 -04:00
parent a21f3f0eeb
commit 5eb17cca85
3 changed files with 25 additions and 10 deletions

View File

@ -1980,6 +1980,9 @@ Lod emitter service checker function
Mesh profiling
Upgrade target framerate
(05/25/2025)
Flag to enable/disable opengl error checking calls

View File

@ -168,6 +168,11 @@ public class EngineState {
*/
public static boolean HEADLESS = false;
/**
* Controls whether we error check opengl calls or not
*/
public static boolean ERROR_CHECK_OPENGL = true;
}
}

View File

@ -860,10 +860,12 @@ public class RenderingEngine {
* Refer: https://docs.gl/gl4/glGetError
*/
public boolean checkError(){
int error = this.getError();
if(error != GL11.GL_NO_ERROR){
LoggerInterface.loggerRenderer.ERROR("checkError - " + getErrorInEnglish(error), new Exception("OpenGL Error"));
return true;
if(EngineState.EngineFlags.ERROR_CHECK_OPENGL){
int error = this.getError();
if(error != GL11.GL_NO_ERROR){
LoggerInterface.loggerRenderer.ERROR("checkError - " + getErrorInEnglish(error), new Exception("OpenGL Error"));
return true;
}
}
return false;
}
@ -873,10 +875,13 @@ public class RenderingEngine {
* @return The error code
*/
public int getError(){
int lastCode = GL11.glGetError();
int currentCode = lastCode;
while((currentCode = GL11.glGetError()) != GL11.GL_NO_ERROR){
lastCode = currentCode;
int lastCode = 0;
if(EngineState.EngineFlags.ERROR_CHECK_OPENGL){
lastCode = GL11.glGetError();
int currentCode = lastCode;
while((currentCode = GL11.glGetError()) != GL11.GL_NO_ERROR){
lastCode = currentCode;
}
}
return lastCode;
}
@ -887,8 +892,10 @@ public class RenderingEngine {
*/
public int getGLFWError(){
int lastCode = 0;
try (MemoryStack stack = MemoryStack.stackPush()){
lastCode = GLFW.glfwGetError(stack.callocPointer(1));
if(EngineState.EngineFlags.ERROR_CHECK_OPENGL){
try (MemoryStack stack = MemoryStack.stackPush()){
lastCode = GLFW.glfwGetError(stack.callocPointer(1));
}
}
return lastCode;
}