Skip to content
Advertisement

Problem with texture not showing in screen. OpenGL ES

I am newbie in opengl es 2 programming, I was trying to load a texture in png format in my test application. I used PNGDecoder to do this, but just the black rectangle and the line are show in the screen. What is wrong?

Renderer:

JavaScript

Fragment Shader:

JavaScript

Vertex Shader:

JavaScript

Square2D (is used to store vertex positions):

JavaScript

Advertisement

Answer

glVertexAttribPointer can be use in 2 ways. If a named buffer object is bound, then the last argument is treated as byte offset in the buffer objects data store. If no buffer is bound (0), then the last argument is a pointer to the array data.
Hence you have to bind no buffer (0), to the GL_ARRAY_BUFFER target, before you can specify the texture coordinate attribute:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement