GL debug improvements #626

This commit is contained in:
Emux 2019-01-23 10:20:37 +02:00
parent cae68ffec9
commit 8c2f788069
No known key found for this signature in database
GPG Key ID: 64ED9980896038C3
2 changed files with 20 additions and 1 deletions

View File

@ -177,6 +177,25 @@ public class GLUtils {
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.checkGlErrors(getClass().getName() + ": finish").contains(GL.OUT_OF_MEMORY)) {
if (GLUtils.checkGlOutOfMemory(getClass().getName() + ": finish")) {
BufferObject.checkBufferUsage(true);
// FIXME also throw out some textures etc
}