I cannot seem to find a simple tutorial to address what I suspect is an overly easy problem:
I have a square built from a triangle strip. I want to map an image to it (game sprite). Everything is 2d, and lighting is not being used.
I have found tutorials addressing 3d objects with lighting, but they are addressing vastly more complicated scenarios.
How do I go about this?
In GLES 2.0, the
fixed-function pipelinehas been replaced with programmableshaders. This means that you no longer can simply “enable” textures on your objects, but have to create the implementation yourself. Generally you will need to have atexture-coordinateattribute for the 2d-texture space of your geometry as well as a texture sampler.Here is a simple example of a vertex and fragment shader using textures:
Vertex shader:
Fragment shader:
Then, before drawing you will have to bind the texture. If you only use one texture each drawing call then it is as simple as that.
For more code examples on loading and using textures, take a look at the GLES20 sample project in the Android Api-demos