I have three glsl attributes in my vertex shader
attribute highp vec4 Position; attribute mediump vec4 UV; attribute mediump vec3 Normal;
what im binding using
glBindAttribLocation(program, 0, "Position"); glBindAttribLocation(program, 1, "Normal"); glBindAttribLocation(program, 2, "UV");
However, I get an error
Could not find vertex shader attribute 'Normal' to match BindAttributeLocation request.
Why can he find the Position and UV attributes, but not the Normal attribute.
Any help would be greatly appreciated as I am rather confused.
Greetings
Edit: I have the same problem on Android OpenGLES20. I'll add an example code: the rest of the class is the official GLSurfaceView tutorial
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) { String mVertexShader = "uniform mat4 uMVPMatrix;\n " + "attribute vec4 aPosition;\n " + "attribute vec4 aNormal; \n " + //this is the line I added "attribute vec2 aTextureCoord;\n " + "varying vec2 vTextureCoord;\n " + "void main() {\n " + "gl_Position = uMVPMatrix * aPosition;\n" + " vTextureCoord = aTextureCoord;\n" + "}\n"; mProgram = createProgram(mVertexShader, mFragmentShader); // cf tutorial if (mProgram == 0) { return; } initShaderHandles(); //initializes the rest of the handles (cf tutorial) // my little additional code int maNormalHandle = GLES20.glGetAttribLocation(mProgram, "aNormal"); Log.d("ATTRIB LOCATION Normal: ", maNormalHandle + ""); checkGlError("glGetAttribLocation normal"); if (maNormalHandle == -1) { throw new RuntimeException( "Could not get attrib location for normal"); } // ...and we crash. }
source share