Click here to Skip to main content
11,806,026 members (61,259 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Win32 OpenGL VisualC++
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 at 22-Jun-12 7:54am

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 Richard Deeming 225
1 OriginalGriff 215
2 Sergey Alexandrovich Kryukov 170
3 Abhinav S 120
4 ppolymorphe 115
0 OriginalGriff 3,330
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,905
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 22 Jun 2012
Copyright © CodeProject, 1999-2015
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