Redefining Textures

Graphics cards have a limited amount of memory in which to hold texture data (typically between 16 & 128 megabytes).

Very long sequences of images, such as from captured video, can exceed that size.

In such a case, it's more efficient to create a single texture, and redefine it on the fly, than to create many textures in advance. When using this method, the image data for the texture is constantly downloaded from main memory to the graphics card, whenever the texture changes.

Example: anim-falls.cpp

With the libdms library, this is done by calling Texture2D::setImage() and Texture2D::define() each time.
Note: previously this would not work well in libdms, because it would cause a memory leak, and eventually use up all the system memory. This has now been fixed.

In straight OpenGL, you can call glTexImage2D() with new data, any time the target texture is bound.



This approach can also be used with completely dynamic textures - ones that are not preloaded at all. This could be textures using images that the program creates in real time, or using live video input (from a digitizer or from the network).





next