Skip to main content
gamedev.net
🔒 Locked

Unloading textures

Started by Marty666 Jan 9, 2004 at 9:39 AM 1 replies 400+ views
Original Post
Marty666
Marty666
Nehe''s texturemapping tutorial has a procedure: int LoadGLTextures() this loads a BMP file via some other procedure, then clears the memory after it''s loaded by openGL. The texture is never unloaded from openGL though. Isn''t that some kind of leak in video memory? What if i want to load loads of different textures one at a time and get rid of the ones i allready used, how do i get ''m out of my video memory then? Marty
_ /__ /|| | || MtY | ||_____|/Marty
orbano
orbano
For removing textures from memory:
void glDeleteTextures(
GLsizei n,
const GLuint *TextureNames
);
to upload:
get a pointer to you bmp image in supported formats like:
RGBRGBRGBRGB...
Generate a texture name, so you can refer to it later:
glGenTextures(1,&TextureName); (unsigned int TextureName)
glBindTexture(GL_TEXTURE_2D,TextureName); tell open gl if it is a 1D or 2D texture
set texture filter parameters:
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
and finally upload it to texture buffer (video memory)
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,Texture);

If you want more on these functions, goto www.msdn.com and search for the function name, you will find everything

"Knowledge is no more expensive than ignorance, and at least as satisfying." -Barrin
"Knowledge is no more expensive than ignorance, and at least as satisfying." -Barrin

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.