|
-
Feb 23rd, 2003, 08:48 PM
#1
Thread Starter
Addicted Member
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
-
Feb 24th, 2003, 12:18 AM
#2
Hyperactive Member
You are using MFC or just plain Win32 programming?
-
Feb 24th, 2003, 06:52 AM
#3
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
}
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 24th, 2003, 03:27 PM
#4
Frenzied Member
or you could make a new thread
-
Feb 25th, 2003, 07:28 AM
#5
Fanatic Member
CornedBee: Why do you use a for-loop? Is it faster than a while-loop?
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
-
Feb 25th, 2003, 12:01 PM
#6
I always use for(;; ) for infinite loops, it's shorter to write than while(true) and while(1) isn't C++-like.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 25th, 2003, 12:02 PM
#7
Except if you have a very stupid compiler (an anti-optimizing compiler so to say ) they are both exactly the same speed.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|