Threads vs. States

Started by
3 comments, last by Goku705 23 years, 2 months ago
Well, now I''ve read several articles on different methods of running the main game function in Windows games. Each has advantages and disadvantages. Question is, which should I go for? If I set up a new thread, it''s really easy to maintain but I take a bit of a performance hit not to mention it seems a little hack-ish. If I use states, the program can get very unwieldy very fast (unless I''m clever about it). From what I''ve heard, it can be a nightmare to maintain. Any and all help/opinions on the matter are appreciated. -Goku SANE Productions Homepage
Advertisement
If you have little experience with Windows or multithreaded code just stick with a single-threaded model. You will run into a million little with a multi-threaded model. Someone who understands these issues can get around them. If youre not familier with mutex or Critical Sections then just stick with the single thread. I tried using multiple threads in my engine and it just made it more complicated and didn''t give any performance increase. Most of the time comsuming issues are done in hardware anyway( if your using DirectX or OpenGL ). I usually set everything up before I hit the message loop and clean everything up when GetMessage returns zero( that means someone posted a WM_QUIT message ).
Games shouldn''t be multithreaded, *especially* in Windows. You''ll see posts around here that will say otherwise (I think one awhile back said to use one for each enitity *gasp!*) but really, they should be avoided in 99% of the cases out there.

The only circumstance that I think that threads could be used is accessing files realtime as gameplay commences (such as Kings Field II and Castlevania: SOTN uses for Playstation). But even in these cases, it could be implemented without threads via states.

.travois.
why not multithread ??

i found it useful in making the frame rate constant all the time ...

useful for loading maps and files..

i usually process the mouse from a separate thread also ...
Doesn''t threads break platform independancy? If that''s not a good reason to not use them I don''t know what is.


- Houdini
- Houdini
quote:Original post by Houdini

Doesn''t threads break platform independancy? If that''s not a good reason to not use them I don''t know what is.


- Houdini



Well by that logic, using C++ to program your game in is a bad idea because that too will break platform independency, since there are some platforms that you can''t program for in C++...

A lot of game functions are easier to keep in separate threads, like audio, file i/o, etc...

Don''t ever say games _shouldn''t_ be done in a particular way because there''s always situations where it''s better to do it in that way...

This topic is closed to new replies.

Advertisement