Jump to content
  • Advertisement
Sign in to follow this  
iberg

OpenGL OpenGL and MFC with ATI cards

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, Sorry, this posting may be a bit long, but please read it to the end i definitively need some suggestions here. This is my Problem: I'm currently writing an OpenGL screensaver based on a MFC application. When running the screensaver on ATI cards with double buffering enabled every second Frame is a copy of my desktop screen (or a previous frame of the screensaver, but always the same frame). Looks like a massive bug in the double buffering mechanism but only on ATI cards. I found out that this frame is copied to the screen in the OnPaint Callback when calling CPaintDC constructor. CPaintDC dc(this); It is not caused by the OnEraseBackground function since I overloaded it proberly (returns true). So this call should be doing nothing. All the OpenGL stuff follows afterwards and seems to work correctly. Removing the CPaintDC call will result in an infinite loop since the application does not know a screen update occured and resents the onpaint messages. So i removed this and used: PAINTSTRUCT rPS; BeginPaint(&rPS); EndPaint(&rPS); Thus hoping to notify the App about the update with this dummy call without actually doing anything. To my suprise it yields the same result. Instead of doing nothing a copy of my desktop screen (or a previos screen saver frame, when run from the debugger) is copied to the screen. This only happens with ATI cards. If I disable double Buffering the screen saver runs fine on ATI cards but only on ATI cards. All other graphic cards show a massive flickering (as is to expect). In fact it runs so fine that it almost seems the saver is using double buffering without me actually using double buffering techniques in my code. (No SwapBuffer call whatsoever) The pixel format of my window is set to: PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER The windows class is registered with all necessary flags: CS_HREDRAW | CS_VREDRAW | CS_OWNDC And the window is created with the following flags: dwExstyle = WS_EX_TOPMOST, dwstyle = WS_VISIBLE | WS_POPUP; I'm running out of ideas. If anyone wants to have a look at the screen saver you can download it from: http://www.codeproject.com/opengl/Wator.asp Could anyone give me a hint what could be wrong? Or how can i notify the Application of an update without calling the CPaintDC destructor or BeginPaint(). Since these calls seem to scrw it up, but only on ATI cards. Regards, Ingo

Share this post


Link to post
Share on other sites
Advertisement
Something I noticed whilst looking through your code is the way that you obtain a Win32 HDC. Your code uses the following lines:
HWND hWnd = GetSafeHwnd();
m_hDC = ::GetDC(hWnd);
I think that you should use this code:
CClientDC clientDC(this);

iPixelFormat = ::ChoosePixelFormat(clientDC.m_hDC, &pfd);

// etc.
Don't use a variable to hold the hDC; any time you need the window's hDC, create a CClientDC object from the window (the "this" argument), and use it's m_hDC variable. In OnPaint, you should send the CPaintDC object to your Draw function, and use it's m_hDC variable.

It's a small thing, and it might be fine the way you're doing it, but MFC can be a bit funny if you don't do things it's way...

Share this post


Link to post
Share on other sites
Unfortunately that did not help. The original code was taken from an microsoft example for a MFC screensaver (without OpenGL).

I found out that this problem only occurs when I open a fullscreen window exactly the same size of the entire screen. If it is 1 pixel smaller or larger in x or y dimension everything is fine.

[Edited by - iberg on August 15, 2005 6:03:08 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!