Loop message and the eternal C vs. C++ question.

Can any of you tell me of an efficient Windows loop message for use with OpenGL, and tell me why is efficient?
Another thing, Im doing a little demo using C (structs and no classes). While programming for an OpenGL app. is there some preference between C and C++?

i don’t really understand what you mean by efficient windows loop message but I think you mean:

//Drawing & logic code here
InvalidateRect(hwnd,NULL,FALSE); //I think those parameters are correct?!?

By the way PeekMessage(…) is more efficient than GetMessage(…) because it doesn’t sit and wait for a message to be queued.

[This message has been edited by poop on a stick (edited 08-25-2000).]

The above code only processes 1 single message before drawing. It is better to process all of the window’s messages before drawing, as more than one message can accumulate in a window’s msg queue while the app is drawing and processing data. Use a “while” loop instead of an “if” statement with the PeekMessage function. BTW, Mr. Stick, why does your loop not check to see if the window was destroyed?

do {

if ( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) {
  	TranslateMessage( &msg );
  	DispatchMessage( &msg );
    } else {

} while( WM_QUIT != msg.message );

This is the msg loop I use - it basically hogs as much of windows resources as possible (if you want to call that efficient). If there are messages it processes them and when it has emptiedthe message queue it does the application programming, leaving no idle time for other programs. If you have multiple windows etc in your app this wont be very good but for something like a game it works a treat

[This message has been edited by foobar (edited 08-30-2000).]

Ok. I made a little program with an OpenGL window and a little console (a Windows dialog box). If I click on the dialog to move the window I noticed that the OpenGL window stop drawing stuff, how can I fix that?