In WIN95API BIBLE some guy wrote that "my translation"====> PeekMessage is a sux way of doing the same by using Thread.

So im asking u what is better to use to make infinite MAIN LOOP in games
Posted on 2002-11-18 06:13:38 by drakoforma
Since using a thread gives you a time slice of the CPU (And i don't think you can set how much you get) i would think that would limit your game performance greatly if it were a game requiring fast graphics.

I think peek message woulld be the way to go and i'm sure i saw a thread on the board dealing with it in a game scenario.

Do a search.

:alright:
Posted on 2002-11-18 13:53:54 by IwasTitan
A little problem with PeekMessage is that the loop is paused if the process receives any message from Windows.(as a key pressed , etc.) On the other hand, you can set a thread priority at a max (real time if i remember) and in this case it consumes all of proces's time. So both options are possible.
The problem with threads is the syncronisation between them.

Your choice...

Eugen
Posted on 2002-11-19 16:57:39 by Eugen

A little problem with PeekMessage is that the loop is paused if the process receives any message from Windows.(as a key pressed , etc.) On the other hand, you can set a thread priority at a max (real time if i remember) and in this case it consumes all of proces's time. So both options are possible.
The problem with threads is the syncronisation between them.

Your choice...

Eugen


Hmmm..i didn't know you could set priority for a thread. Interesting. I'll have to try that for my game as well.

:alright:
Posted on 2002-11-19 17:38:47 by IwasTitan
A little obs:
You can set the thread's priority . inside the process priority (called "base priority"). So for the process the thread can be "realtime" but not for windows

Eugen
Posted on 2002-11-20 04:12:01 by Eugen
I totally agree.
Try it - put a thread into freespin, then put a messagepump into freespin... one of them will consume near on 100% cputime, the other will not even get close.
Can you guess which is which? :alright:
Posted on 2002-12-13 02:38:21 by Homer

But if you use a thread just for Windows messages, then no reason to use PeekMessage anymore.. use GetMessage instead, which makes the thread sleep when it doesn't really need the CPU.
Posted on 2002-12-13 03:00:22 by Maverick