log shader code on error

This commit is contained in:
Bixilon 2023-05-25 16:03:19 +02:00
parent 29838bd5d3
commit 3f30134896
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 6 additions and 2 deletions

View File

@ -12,7 +12,10 @@
*/ */
package de.bixilon.minosoft.gui.rendering.exceptions package de.bixilon.minosoft.gui.rendering.exceptions
import de.bixilon.minosoft.config.StaticConfiguration
class ShaderLoadingException : Exception { class ShaderLoadingException : Exception {
constructor() constructor()
constructor(message: String) : super(message) constructor(message: String) : super(message)
constructor(message: String, code: String) : super(message + if (StaticConfiguration.DEBUG_MODE) "\n\n\n" + code else "")
} }

View File

@ -53,12 +53,13 @@ class OpenGLNativeShader(
throw ShaderLoadingException() throw ShaderLoadingException()
} }
glShaderSource(program, code.code) val glsl = code.code
glShaderSource(program, glsl)
glCompileShader(program) glCompileShader(program)
if (glGetShaderi(program, GL_COMPILE_STATUS) == GL_FALSE) { if (glGetShaderi(program, GL_COMPILE_STATUS) == GL_FALSE) {
throw ShaderLoadingException(getShaderInfoLog(program)) throw ShaderLoadingException(getShaderInfoLog(program), glsl)
} }
return program return program