Sign in to follow this  
NicoG

glIsTexture fails always

Recommended Posts

I am confused. Please note: I am using GLEW (newest version) while programming my stuff. And from now to then my Texture-Class is not working anymore after changing to FreeImage and doing a complete Rebuild. Behold this small code:
GLuint m_texture = 0;
glGenTexture(1, &m_texture);

if (glIsTexture(m_texture))
{
glBindTexture(GL_TEXTURE_2D, m_texture);
}
If I remove the glIsTexture() everything works as it should. I can bind and unbind the Textures and use them as normal.. thats weird. So in simple: glIsTexture() ALWAYS fails. regards

Share this post


Link to post
Share on other sites
glGenTexture does nothing more than returning an unused texture name and marking them as "used" for internal prupose only (in the sense that calling it again will not return the same name). The return value is, per definition, not a texture name yet. A texture name becomes used when glBindTexture is called on it for the first time.

So glIsTexture doesn't return true until you have bound it for the first time, thereby making the name a texture object.

Share this post


Link to post
Share on other sites
Thanks for your reply.
Here is what I do with more detail:

dtTextureGL::LoadTexture()
{
if (glIsTexture(m_texture))
{
glDeleteTextures(1, &m_texture);
}
glGenTextures(1, &m_textures);
glBindTexture(GL_TEXTURE_2D, m_texture);
// Set Mipmaps, Data and Options etc...
[.......]
glBindTexture(GL_TEXTURE_2D, 0);
}

dtTextureGL::BindTexture()
{
if (glIsTexture(m_texture))
{
glBindTexture(GL_TEXTURE_2D, m_texture);
}
}

dtTextureGL::UnbindTexture()
{
glBindTexture(GL_TEXTURE_2D, 0);
}


So, when calling BindTexture() in the Application or LoadTexture a second Time, the Texture is ready to use. So glIsTexture should return GL_TRUE or not?
regards

Share this post


Link to post
Share on other sites
There is no need to use glIsTexture at all. Just check to see if m_texture is non-zero

dtTextureGL::BindTexture()
{
if(m_texture)
{
glBindTexture(GL_TEXTURE_2D, m_texture);
}
}





[Edited by - V-man on July 28, 2008 6:01:45 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by V-man
There is no need to use glIsTexture at all. Just check to see if m_texture is non-zero
*** Source Snippet Removed ***


Damn, sometimes the world is so easy.. thanks bud. :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this