views:

89

answers:

1

I am new to threads,SDL and how graphic work in general. I've been looking through all of LazyFoo's SDL tutorials, and had helped me greatly. But in his tutorials about multi threading, he commented that you should never use video functions in separate threads, or might cause problem. I am curious how it should be done, as I still have a vague understanding of graphics and threads.

As one of my projects is a shoot'em up, I was wondering if I should create one thread that displays all the graphics, one threads receives all the player input for his ship, and another thread for the enemy AI.

If this is NOT how it should be done, (I think it's wrong) does anyone have any advice of how graphics should be implemented with user input and enemy AI with threads?

For the Lazyfoo's tutorials, this is the link: http://lazyfoo.net/SDL_tutorials/

A: 

Generally I think it is a good idea to separate the rendering thread from the UI/AI threads. It helps to keep your code more understandable. As there are many games available in source code, why don't you check out how they did it?

lothar