binding textures
i usually load textures during startup with a script like this:
LoadTGA(&textures[1], "textures/etna.tga");
glBindTexture(GL_TEXTURE_2D, textures[1].texID);
I want to "unbind" the current texture and load and bind a new one, so i call a function that does the same operation, just like this:
LoadTGA(&textures[1], "textures/etna_new.tga");
glBindTexture(GL_TEXTURE_2D, textures[1].texID);
but the new texture won''t work. I suppose there is a way to clear the texture buffer and fill it again
I found this line in gl.h
WINGDIAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
aparently it deletes the texture and from the looks of it you use it like this.
glDeleteTextures(GL_TEXTURE_2D, textures[1].texID);
Normaly you wouldn''t even start to care about deleting the textures just load a new one like this.
LoadTGA(&textures[2], "textures/etna_new.tga");
glBindTexture(GL_TEXTURE_2D, textures[2].texID);
WINGDIAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
aparently it deletes the texture and from the looks of it you use it like this.
glDeleteTextures(GL_TEXTURE_2D, textures[1].texID);
Normaly you wouldn''t even start to care about deleting the textures just load a new one like this.
LoadTGA(&textures[2], "textures/etna_new.tga");
glBindTexture(GL_TEXTURE_2D, textures[2].texID);
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
i use to load a new texture just clicking on a key, i.e:
if (keys[''X''])
{
keys[''X'']=FALSE;
LoadTGA(&textures[2], "textures/currentmap.tga");
}
but texture is not loaded/displayed on the object, while if i run the loadtga at startup (i.e. in the initgl() ) it does work...
if (keys[''X''])
{
keys[''X'']=FALSE;
LoadTGA(&textures[2], "textures/currentmap.tga");
}
but texture is not loaded/displayed on the object, while if i run the loadtga at startup (i.e. in the initgl() ) it does work...
i arrived to the point that i must load all my textures at startup, and switch the texture applied to one object like this:
if (texture_change==TRUE) glBindTexture(GL_TEXTURE_2D, textures[1].texID );
if (texture_change==FALSE) glBindTexture(GL_TEXTURE_2D, textures[2].texID );
but i''m sure there must be a way to load and apply texture at run-time ...
if (texture_change==TRUE) glBindTexture(GL_TEXTURE_2D, textures[1].texID );
if (texture_change==FALSE) glBindTexture(GL_TEXTURE_2D, textures[2].texID );
but i''m sure there must be a way to load and apply texture at run-time ...
also, if i try to delete a texture with:
glDeleteTextures(GL_TEXTURE_2D, textures[1].texID);
i get this compiler error:
error C2664: ''glDeleteTextures'' : cannot convert parameter 2 from ''unsigned int'' to ''const unsigned int *''
glDeleteTextures(GL_TEXTURE_2D, textures[1].texID);
i get this compiler error:
error C2664: ''glDeleteTextures'' : cannot convert parameter 2 from ''unsigned int'' to ''const unsigned int *''
Yes, infact that works, i forgot to point at the correct texture element. After deleting the texture, my teapot is grey again (i.e. no texture on it), so deleting the texture went ok. So i load a different tga file and i expect to see it on the teapot, but it keep to be still grey !?!
In practice this is the code:
glDeleteTextures(1, &textures[1].texID );
LoadTGA(&textures[1] , "textures/currentmap2.tga");
In the function that render the teapot, of course there is a line
glBindTexture(GL_TEXTURE_2D, textures[1].texID );
In practice this is the code:
glDeleteTextures(1, &textures[1].texID );
LoadTGA(&textures[1] , "textures/currentmap2.tga");
In the function that render the teapot, of course there is a line
glBindTexture(GL_TEXTURE_2D, textures[1].texID );
I also tried to modify nehe''s code of lesson 33, thinking my code was totally screwed up, but the result is the same: deleting a texture and loading a new one doesn''t work, or better, it just delete the texture from memory, but the new one is not loaded. Any idea ?
You still have to use glGenTextures (1, &textures[1].texID);
and setup your texture parameters again. Post all relevant code if that isn''t the problem.
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
and setup your texture parameters again. Post all relevant code if that isn''t the problem.
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement