Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - OpenGL Tabbed MDI Windows on Vista Aero problems
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

OpenGL Tabbed MDI Windows on Vista Aero problems

 Post Reply Post Reply
Author
Message
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 57
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Topic: OpenGL Tabbed MDI Windows on Vista Aero problems
    Posted: 27 April 2007 at 1:32am
Hi,

We have an Tabbed MDI that includes OpenGL rendering CView windows. When using this on Vista with Aero enabled, resizing the MDI mainframe flickers the OpenGL view.

It appears to be drawing some kind of backing window at some stage of the resize process before the WM_PAINT finally comes to the OpenGL CView window which finally draws correctly.
Using the same code but reverting to a standard MDI works correctly or using the Vista Basic scheme (Desktop Windows Composition Engine is disabled)

I have modified the MDITabWindow sample to render some OpenGL in the CHelloView window.uploads/20070427_012647_MDITabWindow.zip

I assume the problem lies deep within the codejock code somewhere related to CXTPTabClientWnd.

Does any one have any idea on how to stop the flashing?


Back to Top
Simon HB9DRV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 July 2005
Location: Switzerland
Status: Offline
Points: 458
Post Options Post Options   Thanks (0) Thanks(0)   Quote Simon HB9DRV Quote  Post ReplyReply Direct Link To This Post Posted: 27 April 2007 at 3:04am
In resizing I often set a timer in the Frame or View's ::OnSize to resize only after 200ms, this way you only get one redraw per resize, especially when the (ab)user is resizing the application.
Simon HB9DRV
Back to Top
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 57
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Posted: 27 April 2007 at 3:33am
This would not help in this situation. It appears that it is temporarily drawing "rubbish" in the window before the view gets to draw the OpenGL.

If possible please test the sample code on Vista.
Or look at these screen shots:
The view OpenGL rendered normally before and after a resize:



During the resize the window shows this (BTW, I captured this while the debugger was stopped at a break point at the start of CGLEnabledView::OnDraw) - I resized a lot before this to show how the window is dirtied. Obviously this is what the Vista DWM composition engine sees as the window contents prior to the OpenGL being restored.




While doing a resize it flicks rapidly between these two images, hence the flicker.




Back to Top
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 57
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Posted: 30 April 2007 at 10:21am
Oleg,

Do you have a solution/bugfix for this problem?

Thanks,

Scott
Back to Top
Oleg View Drop Down
Admin Group
Admin Group
Avatar

Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 01 May 2007 at 1:01am
Hello,
Sample you attached works for me without problems :(
If you don't use TabClient do you see same problem?
If you don't use last 11.1 version, please try evaluation, may be it will work for you also.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 57
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Posted: 01 May 2007 at 1:26am
Hi Oleg,

Sorry, I should have provided more information.

I am using the latest 11.1.0 source.

The problem is only evident when using the MDI TabClient on Vista with Aero enabled.

It works OK on XP and on Vista when Aero is disabled. It also works OK when using the standard MDI child windows regardless of the OS.

Our application has the problem, and when I built the sample it also showed the same problem. The sample shares no code with our appliation, infact the openGL part was taken from another sample on the web. So I think I can conclude that my code is OK (CLIP_CHILDREN, CLIP_SIBLINGS, OnEraseBackgound etc are all accounted for).

The only thing I will try is upgrading the graphics card drivers for my NVidia card - perhaps they have a bug.

Oleg, have you tested this on Vista with Aero enabled? what graphics card are you using?


Back to Top
Oleg View Drop Down
Admin Group
Admin Group
Avatar

Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 01 May 2007 at 11:02am
Strange :(
 
I tested with Aero enabled. My card NVIDIA GeForce 7600.
 
also this sample enable groups. if  you disable them do you see same?
change in mainfrm.cpp code to
VERIFY(m_MTIClientWnd.Attach(this, FALSE));
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 57
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Posted: 01 May 2007 at 10:21pm
Hi Oleg,

I have a Nvidia 6600. I have just update my drivers to the latest 158.18 but the problem still exists :(

As you suggested I disabled the tabbed groups and it does fix the problem when resizing the window, but the same flicker is evident when toggling between two tabs.

One of my other developers is just getting vista setup now - he has a NVidia 8600.  I will test the sample on his machine.

Cheers,

Scott
Back to Top
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 57
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2007 at 4:24am
Hi Oleg,

I have now tested the sample on 3 vista machines with Nvidia 6600, 7600, and 8600 cards. All 3 have the latest drivers from NVidia installed (if using the default Microsoft OpenGL drivers supplied with Vista I would guess the problem would not manifest itself).

All the test machines show the problem as described above.

Do you have the latest NVidia drivers installed?




Back to Top
Oleg View Drop Down
Admin Group
Admin Group
Avatar

Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2007 at 5:23am
Hi,
 
Please try to change sample as I suggested -
 
VERIFY(m_MTIClientWnd.Attach(this, FALSE));
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 57
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2007 at 9:01pm
Hi Oleg,

I have tested this change you suggested. Resizing the window does not show the flicker any more. But there is now the same flicker when toggling between 2 tabs ( to see it you need to have resized the window first).

The best way to see these problems is to first resize the window from the bottom right towards the top left and then resize out again.

I do notice a difference in CXTPTabClientWnd::CalcWindowRect between the single workspace and the group workspaces - could it be a problem here?




Back to Top
grudy View Drop Down
Groupie
Groupie


Joined: 02 November 2004
Location: United States
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote grudy Quote  Post ReplyReply Direct Link To This Post Posted: 17 July 2007 at 10:58am

Scottp and Oleg,

We are seeing exactly the same issue when switching tabs with our OpenGL application. The "trash" appears as soon as the tab is picked and is replaced by the correct image as soon as the OpenGL draw is finished and we swap buffers - the longer the daw, the longer the "trash" is on the screen. nVidia support thinks we have GDI code in the draw path (you cannot mix GDI and OpenGL in Vista) but we have not found it yet. Have either of you found a resolution to this yet. We are not grouping tabs and already set it to FALSE - so I presume that is why we never saw it with OnSize only with switching tabs.

Thanks

grudy

Back to Top
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 57
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Posted: 17 July 2007 at 11:17pm
Hi grundy,

Unfortunately I have not had any success in solving this problem.

Our application has no GDI mixed with OpenGL, and I have also tested on both Nvidia and ATI graphics and both cards show the problem.

Have you tested with the sample app I attached in my first post? the sample is about as basic as it can get to show the problem (and should be no GDI either).

What I have found is that the problem is found in more places than just MDI Tabs. If you reparent an OpenGL View to a floating dockable window, when mousing over the pin and close buttons the code to draw the buttons causes the same problem. In fact, when this happens the OpenGL is not redrawn correctly because there is no resize or paint events to force the redraw.

It appears to be a problem drawing the window/tab "non client" decorations that is causing the problem (i.e. the pin, close buttons, the tabs etc).

I am not sure if there is a better way for codejock to draw these non client decorations? or if there is a way to stop the Vista DWM composition from being triggered at the wrong time?


Cheers,

Scott

Back to Top
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 57
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Posted: 20 November 2007 at 9:18pm
I think I have found the cause of the major part of the problem.
It appears that when using Vista Aero (Desktop Windows Compositing enabled) it will be fooled into taking a dirty copy of the current window for composting after processing the WM_NCPAINT (or WM_PAINT) messages when no clipping regions are set to exclude the client  (opengl) regions.

So setting the DC clipping regions correctly using dcPaint.ExcludeClipRect in CXTPDockingPaneMiniWnd::OnNcPaint() , CXTPTabClientWnd::OnDraw and CXTPTabClientWnd::OnNcPaint() to exclude the client area of the window (i.e. the OpenGL content) appears to work.

The following usage patterns show the redraw problems:
1. load several of the opengl Views, resize the application in and out several times (I guess show contents while dragging option should be on). The resizing will cause the opengl contents to flicker.
2. click on the various tabs to activate the other MDI opengl views, changing the active view will also cause a "flicker" as a dirty backing window is shown.
3. make one of the opengl views "dockable" and float the docked pane. Anytime the the themed floating frame is drawn the opengl contents are cleared (deactivate, mouse over close buttons)

1. it appears is mostly fixed by CXTPTabClientWnd::OnDraw and CXTPTabClientWnd::OnNcPaint() changes
2. is still a problem (I think this is the same case as Grundy)
3. appears totally fixed by CXTPDockingPaneMiniWnd::OnNcPaint changes


Here are the changes that work for me - it would be nice if these could be included in the next release - hopefully this will be useful for other users too.

void CXTPTabClientWnd::OnDraw(CDC* pDC, CRect rc)
 {
 if (GetWorkspaceCount() == 0 || !m_bEnableGroups)
  {
  OnFillBackground(pDC, rc);
  }
 else
  {
  CRect rcClipBox;
  pDC->GetClipBox(&rcClipBox);

  for (int i = GetWorkspaceCount() - 1; i >= 0; i--)
   {
   CWorkspace* pWorkspace = GetWorkspace(i);
   CRect rectClient = pWorkspace->GetClientRect();
  
   CRect rectWindow;
   GetWindowRect(rectWindow);
   ScreenToClient(rectWindow);
   rectClient.OffsetRect(-rectWindow.left, -rectWindow.top);

   pDC->ExcludeClipRect(rectClient);

   }

  for (int i = GetWorkspaceCount() - 1; i >= 0; i--)
   {
   CWorkspace* pWorkspace = GetWorkspace(i);

   if (CRect().IntersectRect(rcClipBox, pWorkspace->m_rcControl))
    {
    GetPaintManager()->DrawTabControl(GetWorkspace(i), pDC, pWorkspace->m_rcControl);
    }

   if (!pWorkspace->m_rcSplitter.IsRectEmpty())
    {
    m_pPaintManager->GetAppearanceSet()->DrawWorkspacePart(pDC, pWorkspace->m_rcSplitter, m_bHorizSplitting ? xtpTabWorkspacePartHSplitter : xtpTabWorkspacePartVSplitter);
    }
   }
  }
 }


void CXTPTabClientWnd::OnNcPaint()
 {
 if (!m_bEnableGroups)
  {
  Default();
  return;
  }

 CWindowDC dcPaint(this);
 CXTPWindowRect rc(this);
 rc.OffsetRect(rc.TopLeft());

 CRect rectClient;
 GetClientRect(rectClient);
 CRect rectWindow;
 GetWindowRect(rectWindow);
 ScreenToClient(rectWindow);
 rectClient.OffsetRect(-rectWindow.left, -rectWindow.top);
 dcPaint.ExcludeClipRect(rectClient);

 m_pPaintManager->GetAppearanceSet()->DrawWorkspacePart(&dcPaint, rc, xtpTabWorkspacePartBorder);
 }

void CXTPDockingPaneMiniWnd::OnNcPaint()
{
if (IsThemed())
{
CXTPWindowRect rc(this);
rc.OffsetRect(-rc.TopLeft());
CWindowDC dc(this);

  CRect rectClient;
  GetClientRect(rectClient);
  CRect rectWindow;
  GetWindowRect(rectWindow);
  ScreenToClient(rectWindow);
  rectClient.OffsetRect(-rectWindow.left, -rectWindow.top);
  dc.ExcludeClipRect(rectClient);

CXTPDockingPanePaintManager* pPaintManager = GetPaintManager();
pPaintManager->DrawFloatingFrame(dc, this, rc);
}
else
{
Default();
}
}

As mentioned above this does not complete resolve the case when switching between tabs - the flicker to the dirty backwindow is still evident. Unfortunately I don't have any time to continue debugging this.

Regards,

Scott
Back to Top
Slamma View Drop Down
Newbie
Newbie


Joined: 22 August 2008
Location: United States
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote Slamma Quote  Post ReplyReply Direct Link To This Post Posted: 02 March 2009 at 7:32pm
I too am seeing this with a simple opengl viewport in the main MDI document area.
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 13 March 2009 at 7:41am
Any news regarding this? I'm experiencing similar OpenGL-problems with XTP 13.0.0, and I'm not sure if it has to do with this or not.
PokerMemento - http://www.pokermemento.com/
Back to Top
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 57
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Posted: 18 March 2009 at 3:07am
Some of the code changes included in the above post seem to have made there way into 13.0.0, but most of the CXTPTabClientWnd   changes have not.  There are also some other opengl drawing problems when switching the active tab, I have not been able to pinpoint the problem code yet.

It would be nice to have these changes included so I can stop having to manually patch each new release.

Back to Top
MarkcusD2 View Drop Down
Newbie
Newbie


Joined: 12 May 2013
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote MarkcusD2 Quote  Post ReplyReply Direct Link To This Post Posted: 14 May 2013 at 3:10pm
I'm running into a similar issue where the opengl view goes all white whenever the I click in a docked window or I re-size the entire application. I tried the changes above but they didn't have any effect in my program. I'm using a FrameWnd and Multiple docked windows. For Windows 7 I  just disable the dwm when my app starts but MS has taken away that ability in Win8 :(

Has this been fixed in later versions of the toolkit?
Back to Top
jakka30 View Drop Down
Newbie
Newbie


Joined: 16 June 2014
Location: Madison, AL
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote jakka30 Quote  Post ReplyReply Direct Link To This Post Posted: 16 June 2014 at 11:53am
Hello all,

I am having the same problem. With Windows Aero turned-ON and floating my docking window, whenever I go to other application window (making my docking window go out of focus) then my docking window draws white background (this is not my docking window background color). It is really frustrating. 

Any help on this will be greatly appreciated.

Thank you,
Suresh
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0.094 seconds.