I\'ve been struggling to draw a 2D image from jpg/png files using openGL ES 2.0 for Android. Everywhere I look the tutorials are for texturing 3D images so its been rough figuri
The solution could be as simple as Enabling mTextureCoord... before assigning the VertexAttribPointer;
"v_TexCoordinate = a_TexCoordinate" +
should have been
"v_TexCoordinate = a_TexCoordinate;" +
Apparently I forgot a semi-colon, now I realize just how much I rely on my IDE's to tell me when I mess up stupid things haha.
I would also change this in the shader
gl_Position = vPosition * uMVPMatrix;
to this
gl_Position = uMVPMatrix * vPosition;
it will make a difference when trying to translate the position of the image.
Try with following Texture coordinates:
final float[] cubeTextureCoordinateData =
{
0.5,-0.5,
0.5,0.5,
-0.5,0.5,
-0.5,-0.5
};
Its working. Thank you very much.
There is a mistake with variable vColor naming (or using) in fragmentShaderCode. Here your variable has name vColor:
uniform vec4 vColor;
and in this line it has name v_Color
gl_FragColor = (v_Color * texture2D(u_Texture, v_TexCoordinate));