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%
case WM_ACTIVATE:
if ( ! HIWORD(wParam) )
g_bActive = TRUE;
else
g_bActive = FALSE;
break;
case WM_PAINT:
if ( g_bActive )
OnPaint();
break;
i only call onpaint if the window is active, and my cpu gets used at 100% even when the window is not active…
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
PAINTSTRUCT PaintStruct;
then in the wndProc function (message handler), to respond to WM_PAINT, do this: