I am making a litle paint program, rendering the scene using opengl, i only call the funtion to draw when i receive WM_PAINT thinking that it wont use the cpu at 100% but it still does.
Is there any way i can only render when i need too so my cpu dosent get used at 100%
if ( ! HIWORD(wParam) )
g_bActive = TRUE;
g_bActive = FALSE;
if ( g_bActive )
i only call onpaint if the window is active, and my cpu gets used at 100% even when the window is not active…
Try to put a breakpoint in your rendering code, to see when it’s called.
You have this problem because WM_PAINT is sent to your window again after every drawing of the scene. To let windows know that you have updated the window, do this:
declare a global PAINTSTRUCT structure
then in the wndProc function (message handler), to respond to WM_PAINT, do this:
Then windows won’t send the WM_PAINT message any more until it’s required again.