I am coding my framework for my DirectX applications and I don't like the message loop that is used in my book:
If you people here on CBoard help me understand this a little more(mainly around the time), then I might be able to make my own function that wraps the message loop.
int EnterMsgLoop(bool (*ptr_display)(float timeDelta))
static float lastTime = (float)timeGetTime();
while(msg.message != WM_QUIT)
if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
float currTime = (float)timeGetTime();
float timeDelta = (currTime - lastTime)*0.001f;
lastTime = currTime;
Can you perhaps explain what part of this you don't like?
What part of the time-management don't you understand?
The general idea, from what I see, is that you loop around until the application closes, doing either: a message operation, or you display the current state of whatever you are drawing, and part of that is of course to track time so that we know how far to move things around, for example.
Since windows is message-based, you will have to "fetch" the messages at some time or another - otherwise you won't know what's going on.
You could of course have two threads, one that does drawing, and one that handles messages - but then how would you get the drawing thread to understand that the user clicked the mouse, hit a spacebar or a arrow-key or whatever, which means something to the drawing side (fire a bullet, move the player or whatever)? Aha, I hear you say, I send a message - so we're back at the beginning, you need a message loop.
You may be able to write it in a different way - and depending on your definitions of better, it may well be better - and I'm sure if you are going to write a full-feature game, none of the existing code would be left - you would rewrite all of that. But you'd have something that does roughly the same thing.
I have explained how to get around the pointer to the display function multiple times in multiple threads.
I've also explained how to take the code in that book and create your own C++ class framework from it.
A board search would yield many many answers to your problem.