The iPhone SDK has an example of using ES 2.0 with a set of (Vertex & Fragment) GLSL shaders to render a varying colored box. Is there an example out there on how to render a simple texture using this API? I basically want to take a quad, and draw a texture onto it.
The old ES 1.1 API’s don’t work at all anymore, so I’m needing a bit of help getting started. Most shader references talk mainly about advanced shading topics, but I’m really unsure about how to tell the shader to use the bound texture, and how to reference the UV’s.
There’s a nice tutorial on this in the web site to go with the book OpenGL ES 2 The examples from the book are all at http://www.opengles-book.com.
Chapter 9, Simple_Texture2D does exactly what you want. It sets up a shader that samples a texture, initializes it, and shades the triangles using the texture.
The shader program is close to:
and you set it up thusly:
But see the actual code, from the links I gave above, to really see the example.