glIsTexture fails always

Started by
4 comments, last by NicoG 15 years, 9 months ago
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
If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/
Advertisement
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.
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
If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/
If you try to load a texture a second time with the same name, glIsTexture should return true, yes. Since it was previously loaded, it is also bound and created, so it then becomes a used name.
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]
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
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
If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/

This topic is closed to new replies.

Advertisement