libgdx
libgdx copied to clipboard
Stage.drawDebug does not work in combination with GL3 due to ShapeRenderer shader not being compliant
Issue details
When trying to draw UI debug stuff with OpenGL3 the application crashes due to the shape renderer not using GLES30 compliant GLSL syntax.
Reproduction steps/code
The configuration on Lwjgl3ApplicationConfiguration:
setOpenGLEmulation(Lwjgl3ApplicationConfiguration.GLEmulation.GL30, 3, 3)
I then enabled the debug drawing mode using:
stage.isDebugAll = isChecked
Version of libGDX and/or relevant dependencies
1.12.1
Stacktrace
Exception in thread "main" com.badlogic.gdx.utils.GdxRuntimeException: Error compiling shader: Vertex shader
ERROR: 0:1: '' : #version required and missing.
ERROR: 0:1: 'attribute' : syntax error: syntax error
Fragment shader:
ERROR: 0:1: '' : #version required and missing.
ERROR: 0:4: 'varying' : syntax error: syntax error
at com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20.createDefaultShader(ImmediateModeRenderer20.java:242)
at com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20.<init>(ImmediateModeRenderer20.java:55)
at com.badlogic.gdx.graphics.glutils.ShapeRenderer.<init>(ShapeRenderer.java:116)
at com.badlogic.gdx.graphics.glutils.ShapeRenderer.<init>(ShapeRenderer.java:111)
at com.badlogic.gdx.graphics.glutils.ShapeRenderer.<init>(ShapeRenderer.java:107)
at com.badlogic.gdx.scenes.scene2d.Stage.drawDebug(Stage.java:136)
at com.badlogic.gdx.scenes.scene2d.Stage.draw(Stage.java:131)
Potential solution
Like in other places it would be useful to somehow tell the Stage what ShapeRenderer to use. Right now the attribute Stage.debugShapes (of type ShapeRenderer) is private and has no non private accessors. To support lazy creation an overrideable makeDebugShapeRenderer() could be offered to override the default behavior on demand.
Does this happen on macOS or on another OS? In the case of the former, the root cause is #6897 with a possible fix over at #5960.
Yes, it seems to be a MacOS-only issue. Thank you for the insights.
I share your opinion that it would be nice if libGDX would work with GL30 on all platforms out of the box. However, making the stage's debug shape renderer customizable would be useful regardless of whether the default shader works.