Click here to Skip to main content
13,050,896 members (63,421 online)
Rate this:
Please Sign up or sign in to vote.
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 18:50pm

1 solution

Rate this: bad
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:

							 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.
Richard MacCutchan 22-Jun-12 7:54am

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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 22 Jun 2012
Copyright © CodeProject, 1999-2017
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