1

I have been working on an app but I am getting to some errors I cant explain. these errors only appear on my oneplus 3 but not using the google nexus 6p genymotion emulator.

I have searched for hours but i couldn't find an awnser.

this is my compilation code:

public static int loadShader(int shaderType, String source){
    int shader = GLES20.glCreateShader(shaderType);
    if (shader != 0) {
        GLES20.glShaderSource(shader, source);
        GLES20.glCompileShader(shader);
        int[] compiled = new int[1];
        GLES20.glGetShaderiv(shader,GLES20.GL_COMPILE_STATUS, compiled,0);   
        if (compiled[0] == 0) {
            Log.e(TAG, "Could not compile shader " + shaderType + ":");
            Log.e(TAG, GLES20.glGetShaderInfoLog(shader));
            GLES20.glDeleteShader(shader);
            shader = 0;
        }
    }
    return shader;
}

my fragment shader:

precision mediump float;
uniform vec4 vColor;
void main() {
    gl_FragColor = vColor;
}

this is the error:

E/MyGLRenderer: Could not compile shader 35632:
E/MyGLRenderer: ERROR: 0:1: 'in' : Syntax error:  syntax error
                INTERNAL ERROR: no main() function!
                ERROR: 1 compilation errors.  No code generated.

1 Answer 1

1

I fixed it by first trying it on my old galaxy ace 2, fixed all the errors on that device and it all worked again. thing I changed:

  • added #verion 100%n
  • after reading shader file I put the 1 line string into String.Format(string) so the %n would be converted to a newline(compiler would complain about unknow characters behind version number)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.