-
Multithreading
Does anyone know of a tutorial that covers multithreading in DirectX? I've read a few tutorials in DirectX and never learned much so now I've decided to try to make some kind of game so I will actually learn something...I think multithreading will be important, at least if I add sound, since I think someone had an issue with their sounds interfering with display...
-
JaWiB - I don't know how to answer your question, but if you haven't learned much reading DirectX tutorials, read these. Looks like they just added a vertex fog tutorial - I'm off to read that.
-
About those tutorials, the way they are designed (OOP) used an application class to contain everything and create the window etc, so that WinMain only includes the message loop.
Is this the way professional games/3D apps are set out?
-
Hm thanks for that link...rethinking my post it may have been a bit premature and I wanted to stick with 2d game programming for a little while before I try anything 3d...
-
No no, he was specifficaly speaking of the tutorials themselves.
Multithreading can be very useful and it can - well not be. It depends on how (well) you implement it. The pretense is that with multi-threading you can run two "threads" at the same time. In reality this isnt true. Instead your telling your computer to devote time to two tasks alternatly - rather then starting one - finishing and starting the other. In a math metaphor let say - I want you to divide 2930/3.79 and 9/2.1304820 at the same time. So you work on the first problem for 2 seconds, second problem for 2 seconds and alternate until you are finished.
If done improperly this can slow down your rendering times as youll be branching off to spend time on another thread in the middle of a render process. There are ways to give certain processes more weight (more time).
An example of a way to use multithreads is for loading resources and displaying realtime progress of the loading.
Another use is for loading resources "On the Fly" something that Shadow Bane likes to do (uber UBER LAG) - is when you enter new areas with new resources instead of a loading screen you give a small amount of time to loading process during the render time. Say about 95% importantness to the Render process and a 5% weight to the loading process - so every render you hop into the loading thread for 5 milliseconds - then back out and continue loading - when the resources are finaly loaded you can add them to the render process.
Like I said - if not handled appropriately the attempt can be very disasterous.
For your 2d applicatiosn like rpg - if you break down your maps into "zones" with certain resources only in certain zones - as your character approaches the zones start multithreading the loading process. This way you can have a gigantic map with "no load times"
There are many other things to considere with multithreading - but this is a pretty good tutorial to get you started.
http://www.flipcode.com/tutorials/tut_mthreading.shtml
and part 2
http://www.flipcode.com/tutorials/tut_mthreading2.shtml
When I did the tutorial I stripped the code from the class he gives and did some simple tests with the consle input and printing at the same time. I'll think about cleaning it up and posting - maybe it can help.
-
Thanks! Haven't looked at those tutorials yet, but it sounds like something that could be fun to play around with a little :). I've been looking at the sunlightd tutorials on direct draw, and they have been very simple and straightforward so far...
-
The sunlight tutorials are also a bit old... but if that doesn't bother you and you like them, go for it.
-
Well it does bother me a little bit, but they are written very clearly and don't have about 500 lines of code in the first tutorial...at least I can use it to start with and later I'll either look at some other tutorials or get myself a book.