Draw a 2D Image using OpenGL ES 2.0

人盡茶涼 提交于 2019-12-02 17:34:43
Strifex

"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.

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));

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.

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.

The solution could be as simple as Enabling mTextureCoord... before assigning the VertexAttribPointer;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!