Jump to content
  • Advertisement
Sign in to follow this  
sander242

Multithreading SDL

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

Is multithreading with SDL useful, when you don't have a multicore CPU, and is it even possible? :D Because i want to write a piece of code that could constantly update a picture and in the same time i want the program to be able to receive input from the user at any given time. I thought it's only possible by multithreading, is it?

Share this post


Link to post
Share on other sites
Advertisement
Multithreading is possible even on a single-core CPU but only on a multi-core two threads can run really simultaneously (concurrent). On a single-core CPU the concurrency is only emulated by giving each thread a short time slice on the CPU (but is does that *really* fast so you dont feel it).

Have a look at: http://en.wikipedia.org/wiki/Multithreading for details.

Threading is useful when you have a part of you program that has to wait for a certain event but you want to continue your flow. But it makes debugging a lot harder because, so only do it if you really want to get into trouble (or know how to deal with it).

For your case it is probably not necessary. In SDL you usually query the SDL event system each frame for input events that you process. If your drawing is reasonably fast (e.g. > 20 fps) this should suffice for manipulating the image and give an impression of manipulating the image directly.

Share this post


Link to post
Share on other sites
If it's for gameprogramming with SDL, just do a single thread with an update loop. Then you first check input, then draw to the screen. Computers are that fast :)

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!