Texture Mapping Wallpapering Made Easy

When we wrote Mr. Nom we loaded some bitmaps and directly drew them to the framebuffer—no rotation involved, just a little bit of scaling, which is pretty easy to achieve. In OpenGL ES we are mostly concerned with triangles, which can have any orientation or scale we want them to have. So how can we render bitmaps with OpenGL ES?

Easy, just load up the bitmap to OpenGL ES (and for that matter to the GPU, which has its own dedicated RAM), add a new attribute to each of our triangle's vertices, and tell OpenGL ES to render our triangle and apply the bitmap (also known as texture in OpenGL ES speak) to the triangle. Let's first look at what these new vertex attributes actually specify.

0 0

Post a comment