GL debug improvements (#636)

This commit is contained in:
Gustl22 2019-01-23 21:56:10 +01:00 committed by Emux
parent 25c75a009d
commit 11a5d841f9
No known key found for this signature in database
GPG Key ID: 64ED9980896038C3
2 changed files with 23 additions and 22 deletions

View File

@ -159,6 +159,26 @@ public class GLUtils {
}
}
/**
* Check GL error.
* See: https://www.khronos.org/opengl/wiki/OpenGL_Error
*
* @param op the operation which should be debugged
* @param id the error to be found
* @return true if error was found
*/
public static boolean checkGlError(String op, int id) {
boolean hasError = false;
int error; // GL.NO_ERROR
while ((error = gl.getError()) != GL.NO_ERROR) {
log.error(op + ": \tglError " + getGlErrorString(error) + " (" + error + ")");
// throw new RuntimeException(op + ": glError " + error);
if (error == id)
hasError = true;
}
return hasError;
}
/**
* Check GL errors.
* See: https://www.khronos.org/opengl/wiki/OpenGL_Error
@ -167,35 +187,16 @@ public class GLUtils {
* @return the OpenGL error codes
*/
public static List<Integer> checkGlErrors(String op) {
int error; // GL.NO_ERROR
List<Integer> errors = new ArrayList<>();
int error; // GL.NO_ERROR
while ((error = gl.getError()) != GL.NO_ERROR) {
log.error(op + ": \tglError " + getGlErrorString(error) + " (" + error + ")");
errors.add(error);
// throw new RuntimeException(op + ": glError " + error);
errors.add(error);
}
return errors;
}
/**
* Check GL out of memory.
* See: https://www.khronos.org/opengl/wiki/OpenGL_Error
*
* @param op the operation which should be debugged
* @return true if out of memory
*/
public static boolean checkGlOutOfMemory(String op) {
int error; // GL.NO_ERROR
boolean oom = false;
while ((error = gl.getError()) != GL.NO_ERROR) {
log.error(op + ": \tglError " + getGlErrorString(error) + " (" + error + ")");
// throw new RuntimeException(op + ": glError " + error);
if (error == GL.OUT_OF_MEMORY)
oom = true;
}
return oom;
}
/**
* @param error the error code of OpenGL
* @return the error code as string

View File

@ -160,7 +160,7 @@ public class MapRenderer {
GLUtils.checkGlError(renderer.getClass().getName());
}
if (GLUtils.checkGlOutOfMemory(getClass().getName() + ": finish")) {
if (GLUtils.checkGlError(getClass().getName() + ": finish", GL.OUT_OF_MEMORY)) {
BufferObject.checkBufferUsage(true);
// FIXME also throw out some textures etc
}