Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have done a opengl application in win32 only using platform library.
it was performing very slow so i decided to do the same opengl project using glut library

opengl code workes fine in glut but not in win32.

i thought it would be because of wm-paint so i did it with timer but no effect even
played with pixel struct.


so how can i integrate opengl code in win32 without loss in performance
Posted

1 solution

After drawing a frame, please call ::ValidateRect( m_hRenderingWindow, 0 ); of the corresponding Window. m_hRenderingWindow is the window where you drawing opengl scene. 0 is given to avoid the entire region from updating on next time.

Please try like this:

C++
LRESULT CALLBACK WindowProc( HWND   hWnd, 
							 UINT   msg, 
							 WPARAM wParam, 
							 LPARAM lParam )
switch( msg )
	{
        case WM_PAINT:
	{
....  
RenderScene(); // Prepares your sence.

ValidateRect( m_hRenderWindow, 0 ); // Specifies that entire region of window should be avoided from update region.
	}
.....
}
 
Share this answer
 
v3
Comments
Richard MacCutchan 22-Jun-12 7:54am    

ValidateRect()
takes a HWND not a HDC as parameter 1.
Santhosh G_ 22-Jun-12 8:16am    
Thanks Richard, I corrected the answer.
01.mandar 22-Jun-12 10:10am    
i have already passed NULL.
is there anything that increase win32 opengl execution which i may have missed out.

i am puzzled how have glut optimized their loop?
Santhosh G_ 22-Jun-12 10:28am    
If issue is related to unwanted WM_PAINT message, then ValidateRect can solve.
What are the operations in your drawing ?
Is there any chance to consume much time for the processing ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900