Search code examples
opengl-eslibgdxopengl-es-2.0opengl-es-3.0

Error: Symbol defined with different precision in vertex and fragment shaders


I'm developing a game using LibGDX. In one screen of my game I simply draw some circles. For that I'm using the Circle java class from this GitHub repository in order to make the circle anti-aliased.

https://github.com/Dych/Smooth-circle/blob/master/core/src/gdx/example/Circle.java

It's working just fine on the desktop and on the Android emulator, but when I try to run it on my Android phone (Nexus 5), it just crashes and shows the following message:

com.badlogic.gdx.utils.GdxRuntimeException: --From Vertex Shader:
                                                                    Error: Symbol u_projTrans defined with different precision in vertex and fragment shaders.
                                                                    --From Fragment Shader:
                                                                    Error: Symbol u_projTrans defined with different precision in vertex and fragment shaders.

Could you help me with it? Thank you.


Solution

  • Your fragment shader use a #def to define a precision, if your devise use GL_ES or not.

    But the same #def doesn't exist in your vertex shader, so the precision may not be the same between your vertex shader and your fragment shader (that's explain your error).

    Just add in your vertex shader to fix the issue.

    #ifdef GL_ES
    precision mediump float;
    #endif