Jump to content
  • Advertisement
Sign in to follow this  
littlekid

SDL + opengl with multithread

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

Hi I am only using SDL to create the window rendering context for opengl. My question is that is it possible to use all of them on separate threads?? for e.g

thread_1: SDL_Init(SDL_INIT_VIDEO) // since I am only using the video subsystem

thread_2: Create SDL window/SDL_WM_SetCaption etc

thread_3: do all opengl stuff like glNormal, glBegin() etc.

Or must all of them run on the same thread??

Share this post


Link to post
Share on other sites
Advertisement
Normally when i think of multi-threaded applications, i think graphics thread, physics thread, ai thread, etc. You're proposing, it seems, just 4 graphics threads!

SDL_Init has to be called before anything else, so it is not a good candidate for threading. Creating the window and setting a captions has to be done after SDL_Init and before everything else, so it's not a good candidate for threading.

Basically, these are sequential operations. Threads are no use there.

Finally, your glBegins and glNormals, i don't really know (maybe someone else will respond about that), but i don't think it's a good idea.

Why do you want to use multiple threads anyway? They're incredibly useful in big applications that are very demanding on CPU time, but if that was the case, i don't think you'd be asking quite the same questions.

Share this post


Link to post
Share on other sites
haha yah, it is just a thought question, I am not really creating 4 graphics thread. My main concern is whether the rendering context and the gl commands can be on different threads.

Share this post


Link to post
Share on other sites
Actually, creating multiple graphics threads isn't that stupid, I experimented with it in my engine (though based on a task system) with directx11 which supports multithreading by creating additional (deferred) device contexts, and it worked out great.
However, I don't believe (or at least, I have not been able to find) that OpenGL currently has the same functionality, so 1-0 to microsoft. You can however "emulate" such a system by creating your own command buffer creator which can receive request and handle them multithreaded.
There is a great article on this in the book "Game Engine Gems 1", I don't have it with me right now so i don't know the title, but you will recognise it when you see it, I believe it was something like "rendering with a command buffer".

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.

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!