Jump to content
  • Advertisement
Sign in to follow this  
bluntman

OpenGL Multi-threaded texture problems.

This topic is 4594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In my app I am running a few different threads, all with thier own GL contexts, and lists shared (using wglShareLists) with the main thread. In one thread I am calling glTexImage2D and it is returning GL_INVALID_OPERATION. The only way (according to the MSDN docs anyway) that this can return is if glTexImage2D is called between glBegin and glEnd. I am certain that in its own thread that is not the case, but can other threads interfere with this operation? Also the call is actually working, so whats with the error? I could just ignore it but it probably signifies some deeper problem which will come back to bite me at some point. This is the call:
// enable this texture
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_nOpenGLReference);

glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, glformat, 
    image->GetWidth(), image->GetHeight(), 0, gliformat, 
    gltype, image->GetBitsPointer());

// check for errors
err = glGetError();

if(err == GL_INVALID_ENUM)
{
     m_sLastError = "Cannot create OpenGL "
          "texture, error in OpenGL parameters.";
     return(false);
}
else if(err == GL_INVALID_VALUE)
{
     m_sLastError = "Cannot create OpenGL texture"
          ", data is incorrect.";
     return(false);
}
else if(err == GL_INVALID_OPERATION)
{
     m_sLastError = "Cannot create OpenGL texture"
          ", called between glBegin and glEnd.";
     return(false);
}

Also, I create all my texture references in the main thread using the main HGLRC, this is correct right? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
glGetError returns the last error flagged by any function, not just the previously called function. I'm willing to bet that glTexImage2D is not what is returning your GL_INVALID_OPERATION. Put in another glGetError check before calling glTexImage2D, and make sure there's no error carried over from a previous function.

That being said, as long as your contexts are different, there is no reason a different thread would interfere with your GL state and raise spurious errors.

Share this post


Link to post
Share on other sites
For such problems i would reccommend you use GLIntercept, it helps detects OpenGL errors and even texture/VBO/shader leaks. Also you need not touch your source code.
Quote:

Also, I create all my texture references in the main thread using the main HGLRC, this is correct right?


I dont use GL in multiple threads so i wouldnt know but i get the feeling that texture references should be created in the thread where it is used.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!