Using Textures With GLSL Shaders for iOS With OpenGL ES 2
-
24-10-2019 - |
Question
This information doesn't exist on Google somehow.
I need to transfer texture coordinates to my shader programs but ATTRIB_TEXCOORD doesn't exist. What do I do with glVertexAttribPointer?
Thank you.
Solution
Given a shader program and the name of the texture attribute (in this example the attribute is named “textureCoords”) you get the index like this:
int a_texture = glGetAttribLocation(program, "textureCoords");
and then use a_texture in glVertexAttribPointer like this:
glVertexAttribPointer(a_texture, 2, GL_FLOAT, 0, 0, textureVertices);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow