Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

dopeflow

OpenGL Multi-threading with Opengl question

This topic is 5474 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

Just wondering, I tried running a separate thread for my LoadGame routine, where I load new textures, load the map, etc... I want to run it in a thread so that I can draw a progress bar at the same time, among others. The problem is that, both threads have call to opengl. The LoadGame routine creates some texture so I get to do a few gl calls there and meanwhile the main thread use some gl drawing operations. It seems that when I load my game with a thread, once the game is loaded all the in game textures are white, I debugged in to see what was the problem and all texID''s of my textures had impossible values, so im guessing something in glGenTexture goes wrong. Is there any way I could do this? Besides not using a thread?

Share this post


Link to post
Share on other sites
Advertisement
If you want to use threads, you need to know about synchronization. Read up on mutexes.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
quote:
Original post by mannam
OpenGL is not thread-safe. Textures loaded in a thread are not accessible by other threads
What''s your source for this? While GL calls are certainly not reentrant, I see no reason why textures from one thread wouldn''t be usable by another thread.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
You could load you''re textures into memory in you''re second thread and then transfer them to OpenGL in the same thread that you created you''re GL context after they''ve been loaded.

Having said that, I really don''t see the need to use multiple threads just to have a progress bar. Unless the files are ridiculously large, update the bar between loading each file should be regular enough.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!