PDA

View Full Version : OpenGL Windows Update



GQ
02-11-2004, 04:57 AM
I want to update my window after every half second interval?
Any body help me in it and tell me the function for updating the window.

Nychold
02-11-2004, 05:08 AM
In the Win32 API, UpdateWindow(HWND hWin) will update the window, but to find out what it does, you'd have to read the API because I totally forget; I know it sends a few messages to the window in question, though. Other than that, you'd have to set up a timer (or possibly a second thread) which will trigger a specific function to "update" the window you want.

Relic
02-11-2004, 05:48 AM
This message loop should do it:



LRESULT CALLBACK WndProc(HWND hwnd,UINT uMessage, WPARAM wParam, LPARAM lParam)
{
static unsigned int uiTimer = 0;

switch (uMessage)
{
case WM_CREATE:
// Build OpenGL rendering context here.
uiTimer = SetTimer(hwnd, 1, 500, NULL);
return 0;

case WM_TIMER:
InvalidateRect(hwnd, NULL, FALSE);
return 0;

case WM_ERASEBKGND:
return 1; // Keep GDI from clearing.

case WM_PAINT:
glClear(GL_COLOR_BUFFER_BIT);
ValidateRect(hwnd, NULL);
return 0; // OpenGL handles the painting.

case WM_DESTROY:
if (uiTimer != 0)
{
KillTimer(hwnd, 1);
}
// Cleanup OpenGL here.
PostQuitMessage(0);
break;

}
return (DefWindowProc(hwnd, uMessage, wParam,lParam));
}


[This message has been edited by Relic (edited 02-11-2004).]