tags:

views:

512

answers:

1

I am learning OpenGL and recently discovered about glGenTextures. Although several sites explain what it does, I feel forced to wonder how it behaves in terms of speed and, particularly, memory.

Exactly what should I consider when calling glGenTextures? Should I consider unloading and reloading textures for better speed? How many textures should a standard game need? What workarounds are there to get around any limitations memory and speed may bring?

+2  A: 

According to the manual, glGenTextures only allocates texture "names" (eg ids) with no "dimensionality". So you are not actually allocating texture memory as such, and the overhead here is negligible compared to actual texture memory allocation.

glTexImage will actually control the amount of texture memory used per texture. Your application's best usage of texture memory will depend on many factors: including the maximum working set of textures used per frame, the available dedicated texture memory of the hardware, and the bandwidth of texture memory.

As for your question about a typical game - what sort of game are you creating? Console games are starting to fill blu-ray disk capacity (I've worked on a PS3 title that was initially not projected to fit on blu-ray). A large portion of this space is textures. On the other hand, downloadable web games are much more constrained.

Essentially, you need to work with reasonable game design and come up with an estimate of: 1. The total textures used by your game. 2. The maximum textures used at any one time.

Then you need to look at your target hardware and decide how to make it all fit.

Here's a link to an old Game Developer article that should get you started: http://number-none.com/blow/papers/implementing_a_texture_caching_system.pdf

Justicle
Thanks for the link--interesting article!
Drew Hall