I’m just getting started with OpenGL ES 2.0, what I’d like to do is create some simple 2D output. Given a resolution of 480×800, how can I draw a background texture?
[My development environment is Java / Android, so examples directly relating to that would be best, but other languages would be fine.]
Even though you’re on Android, I created an iPhone sample application that does this for frames of video coming in. You can download the code for this sample from here. I have a writeup about this application, which does color-based object tracking using live video, that you can read here.
In this application, I draw two triangles to generate a rectangle, then texture that using the following coordinates:
To pass through the video frame as a texture, I use a simple program with the following vertex shader:
and the following fragment shader:
Drawing is a simple matter of using the right program:
setting the texture uniform:
setting the attributes:
and then drawing the triangles: