Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Win32 OpenGL VC++
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 21-Jun-12 19:50pm
01.mandar1.2K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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:
 
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.
	}
.....
}
  Permalink  
v3
Comments
Richard MacCutchan at 22-Jun-12 7:54am
   

ValidateRect()
takes a HWND not a HDC as parameter 1.
Santhosh_G at 22-Jun-12 8:16am
   
Thanks Richard, I corrected the answer.
01.mandar at 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 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 575
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,476
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,917


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 22 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100