texture memory management
You know how when you use glTexImage2d you use up some texture memory? How does OpenGL know when to free this? And, is there a way to free it manually?
Thanks.
mike
http://www.coolgroups.com/
Very nice. If the program exits and you don't call that function does the texture memory get freed?
mike
http://www.coolgroups.com/
mike
http://www.coolgroups.com/
Quote:
You know how when you use glTexImage2d you use up some texture memory?
GL takes care to allocate and free memory. When you call glTexImage you reload the texture onto the current texture.
Quote:
How does OpenGL know when to free this?
When you reload a new texture onto an existing one
When you delete texture objects ( see DeleteTextures() )
When the rendering context is destroyed (application exit)
Quote:
And, is there a way to free it manually?
see DeleteTextures()
You should take care of the deallocation when you create texture objects ( via GenTextures )
A typical pseudo-code skeleton is this
Setup
now it's safe to delete your image from client memory because GL has its own
Use
Release
for the details see some tutorials/reference
Setup
GLuint id;glGenTextures(1, &id) glBindTexture(id)glTexImage2D(...)
now it's safe to delete your image from client memory because GL has its own
Use
glBindTexture(id)
Release
glDeleteTextures(1, &id);
for the details see some tutorials/reference
Quote:Original post by blizzard999
A typical pseudo-code skeleton is this
SetupGLuint id;glGenTextures(1, &id) glBindTexture(id)glTexImage2D(...)
now it's safe to delete your image from client memory because GL has its own
UseglBindTexture(id)
ReleaseglDeleteTextures(1, &id);
for the details see some tutorials/reference
you could use a fixed size buffer to load your textures iteratively move the texture to VRAM and load the next texture instead of allocating a ton buffers for the textures and deleting them again
should avoid a little bit of memory fragmentation
Theres no good reason why it would, because you make and delete the data one after the other, and you are making a few assumptions about the size and useage patterns of the texture data in that situation, you might need to keep the data around for some reason and you need to known in advance the size of the largest texture you are going to be loading at any given moment.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement