Stage.drawDebug does not work in combination with GL3 due to ShapeRenderer shader not being compliant
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 25.4k
- Forks
- 6.5k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 5
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce with Lwjgl3ApplicationConfiguration using GL30 emulation and Stage.isDebugAll, then trace Stage.drawDebug through ShapeRenderer and ImmediateModeRenderer20.createDefaultShader. Compare the shader failure in the reported stack trace with the GL3 requirements and verify that debug drawing no longer crashes under this configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100