Jump to content

  • Log In with Google      Sign In   
  • Create Account

multithreading woes


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 evilchicken   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 November 2001 - 03:05 PM

how do you go about generating opengl textures across threads? I cant seem to use the textures I generate in a worker thread, from the main thread.

Sponsor:

#2 Shannon Barber   Moderators   -  Reputation: 1390

Like
Likes
Like

Posted 27 November 2001 - 03:18 PM

You need a way to signal the main thread that the worker thread has finished creating the textures before it tries to use them...

Could you be more specific about what fails?

Magmai Kai Holmlor
- Not For Rent

#3 Oluseyi   Staff Emeritus   -  Reputation: 1678

Like
Likes
Like

Posted 27 November 2001 - 03:23 PM

Note that OpenGL is not reentrant, so be sure to keep all your GL calls to one thread.

That said, I think you''d need to have a "global" store of data/memory in which you create the textures. Realize, though, that you''ll then need to synchronize access using mutexes and all those other lovely multithreading issues.

Other than that, I can offer no specifics. Sorry, hope I helped.


Start Here!

#4 evilchicken   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 November 2001 - 04:12 PM

yeah, I was alittle vague.

The problem is that I have a thread dedicated to recving network packets, and in that thread I call a function that loads game data. Now it appears glTexImage2D() does not put the texture in a "global" store and is only local to my worker thread.

Im pretty sure there is a way to tell OpenGL to stick the texture in a "global" store, but as you said I would have to open up a whole new can of worms.

So what Im planning to do is just throw a flag in the worker thread that signals the main thread to load the stuff in there.

#5 Brother Bob   Moderators   -  Reputation: 8605

Like
Likes
Like

Posted 27 November 2001 - 11:57 PM

A rendering context can only be used in one thread at a time. If you want the second thread to create textures for the main thread, you need to move the rendering context over to the second thread before uploading the texture. When done, you must move it back to the main thread. Also make sure you don''t move the thread to the second thread when the main thread is still drawing. All this requires some synchronization.

As you say, best way it so tell the main thread to do it instead.

#6 jacksonh   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 November 2001 - 06:44 AM

Wouldn''t it be best for the worker thread to send a message to the main thread to upload the texture?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS