Component with OpenGLContext doesn't repaint after switching windows



We have a window and one of its child components has an openGL context attached to it. However, when a repaint is issued for the entire window this component doesn't repaint (neither the paint() method, or the renderOpenGL() method is called). With Aero disabled it means that when the window is repainted after it was covered by another window, the component still shows the image of the previous window. With Aero enabled you can still reproduce the problem if the component has a fixed size and position and you make the window smaller and then larger than the component.

This problem always occurs with an openGL context attached, with component repainting on or off and with or without an OpenGLRenderer.

I looked in the debugger and in HWNDComponentPeer::performPaint, the call to EnumChildWindows will mask out the affected component, causing it not to get repainted. I'm not sure if this is a feature or a bug. For this component we don't need continuous repainting but it still needs to be repainted after it was covered by something else.

I attached the code to reproduce the problem, can you have a look?



Any pointers on how this should be fixed? We have a big component using openGL in our application, and after switching windows this component is just filled with garbage from the previous window. The only way I see to solve this in our application code is having some Timer to do a repaint regularly, something I would like to avoid.

The component peer of the child component doesn't receive WM_PAINT messages, should the HWNDComponentPeer::performPaint call of the parent window ensure the child component is repainted as well?



Well, that was harder to fix than I expected! Try again now..

BTW it's bad practice to add that redundant 'virtual' keyword in front of your methods - nowadays you should always use the new 'override' notation!


Thank you, it's working.