-
Graphics loops
I've programmed games in visual basic that have used graphical loops, but i'm not sure how to go about it in C++. In a windowed environment, isn't there always a loop running (the message loop)?
if this loop has to be there in order to communicate with windows, does the graphics loop have to go inside this loop? i can't image how you could have two loops running at the same time.
thanks,
jmiller
-
You are using MFC or just plain Win32 programming?
-
Modify the message loop to look like this:
Code:
for(;;)
{
if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Game stuff here
}
-
or you could make a new thread
-
CornedBee: Why do you use a for-loop? Is it faster than a while-loop?
-
I always use for(;; ) for infinite loops, it's shorter to write than while(true) and while(1) isn't C++-like.
-
Except if you have a very stupid compiler (an anti-optimizing compiler so to say ;)) they are both exactly the same speed.