Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage.drawDebug does not work in combination with GL3 due to ShapeRenderer shader not being compliant #7349

Open
LobbyDivinus opened this issue Feb 22, 2024 · 2 comments

Comments

@LobbyDivinus
Copy link

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.

@crykn
Copy link
Member

crykn commented Feb 23, 2024

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.

@LobbyDivinus
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants