How use two or more attribute in the vertex shader? What am I doing wrong?

I have this vertex shader:


uniform mat4 u_Matrix;

attribute vec4 v_Position;
attribute vec4 v_Position1;

attribute vec2 a_texCoord;
attribute vec2 a_texCoord1;

varying vec2 v_texCoord;
varying vec2 v_texCoord1;


void main() {
    gl_Position = u_Matrix * v_Position * v_Position1; /*I guess that this is not possible.*/
    v_texCoord = a_texCoord;
    v_texCoord1 = a_texCoord1;
}

And this fragment shader:


precision mediump float;

varying vec2 v_texCoord;
varying vec2 v_texCoord2;


uniform sampler2D u_texture;
uniform sampler2D u_texture2;

vec4 col1;
vec4 col2;

void main() {
    col1 = texture2D(u_texture, v_texCoord);
    col2 = texture2D(u_texture2, v_texCoord2);
    gl_FragColor = col1 + col2;
}

What I want is to have two or more arrays of data and UV coordinates, and pass each one independently to the same program (vertex and fragment shader). Obviously I’m doing something wrong in the shaders, because when I run the app a black screen is shown instead of the textures.

Take a look at the names of your “varyings”, first in your vertex shader and then in your fragment shader. Why don’t they match?

You can query the result of your glCompileShader and glLinkProgram calls to get the errors the compiler and/or linker hit. See:

[ul]
[li]Shader_Compilation#Shader_error_handling [/li][/ul]
int the GL wiki.