title: Texture losing binding
body: <p>I am losing the binding to a texture. Generally my code works but it seems that in some circumstances the generate function will successfully create and upload the texture to graphics memory but in the main loop <code>glIsTexture()</code> will return false.</p>
  
  <p>There is only one thread that touches OpenGL.</p>
  
  <p>The following is pseudo code as this is part of a much larger project and far too complicated to go into details here. I am not looking for syntax checking of my code, I need some help understanding what could cause this to happen and how to debug it.</p>
  
  <p>Main loop:</p>
  
  <pre><code>while(generateTexture(texture_id, sequence_number))
  {
    if(glIsTexture(texture_id))
    {
      cerr &lt;&lt; "Got texture!\n";
      // (Do something with texture here)
      glDeleteTextures(1, &amp;texture_id);
    }
    else
      cerr &lt;&lt; "Bad texture\n";
  }
  </code></pre>
  
  <p>Function:</p>
  
  <pre><code>void generateTexture(GLuint &amp;texID, int number)
  {
    // (Generate texture here)
  
    glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    glGenTextures(1, &amp;texID);
    glBindTexture(GL_TEXTURE_2D, texID);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, width, height, 0,
                 GL_RGB, GL_UNSIGNED_BYTE, texture_data);
  
    if(!glIsTexture(texID))
    {
      cerr &lt;&lt; "Failed to upload texture " &lt;&lt; texID &lt;&lt; " for number " &lt;&lt; number &lt;&lt; "\n";
    }
    else
      cerr &lt;&lt; " -&gt; uploaded to texture " &lt;&lt; texID &lt;&lt; "\n";
  }
  </code></pre>