Multiple textures



A scene can have multiple textures. A game that uses multiple textures within any one particular scene is known as a "multitextured" game and has become prevalent in the gaming industry due to the good visual quality it provides.

When multiple textures are used, we need to define each texture before each part of the scene is drawn. Multiple textures, however, can result in long load times if the textured images are large. To avoid long load times, we use OpenGL’s "texture objects". Texture objects are similar to display lists (which are compiled lists of functions and commands and when called, is faster in execution than a manually called list of single commands) in that both have a single number to identify them. The difference between display lists and texture objects is that while display lists can have any drawing calls, texture objects only have texture information. By having such a trait, texture objects allow a 3D hardware to load – and keep - multiple textures into memory instead of having to load them every time. OpenGL will automatically keep the most recent texture objects used in memory. The only problem with this is when the amount of textures (in MBs) exceed the amount of memory on a 3D hardware. In such cases, OpenGL allows another function that lets us determine and specify which textures are the most important ones. This is done by using the glPrioritizeTextures function. Using this function, each texture object is given a number (0.0 to 1.0) and each of these numbers have a priority, with 1.0 being the highest priority. Note that in games, scenes are forever changing – a texture object given the highest priority number of 1.0 may not actually be guaranteed to be kept in memory but it will definitely be available if needed when and if sufficient memory is available.


In summary



In this part of the introduction to the OpenGL Application Programming Interface (API), we have introduced in brief (and in simple terms) the concept behind one of the most important parts of the 3D rendering process – Texture Mapping. Texture Mapping, and all that it encompasses, has more to do with improving the visuals of any one game rather than performance when it comes to the OpenGL rasterization pipeline. In very basic terms, it is all about adding realism.




  • Discuss this article at Beyond3D's forum