Harito's picture

Scroll Flicker

Hi guys.

If I enable autoscrolling in a GLControl, the control will flicker when scrolling. I read that this is a problem with Aero (I'm using win7) , I disabled it within the app and, to no surprise, it did suppress it. However, this is not a viable solution. I then read that this may be caused because the scrollbars are actually overlapping the openGL context. I'm going to assume this is the problem here, so I wonder if anyone deeply versed with openGL knows how to tackle issue? Should I not be using Win form scroll bars at all? But instead a different approach?

Thanks in advance :)


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Harito's picture

Just to be a little more specific when I say not to use the scrollbars at all :

I mean not to use the autoscrolling feature of the control, but instead use independent scrollbars that would basically translate the openGL "camera" instead of interacting with the forms control itself. I hope you understand what I mean.


the Fiddler's picture

Drawing OpenGL and GDI graphics onto the same surface is generally not recommended, especially when composition (Aero) is enabled. If possible, try to move the scrollbar outside of the OpenGL surface, for example by embedding the GLControl into a scrollable "outer" control (I haven't tested this approach, but it should work).

Another alternative is to render the scrollbar yourself, via OpenGL. The drawback is more complex implementation and inconsistent appearance with native winforms scrollbars.

Any other ideas?

Harito's picture

Thanks for your answer.
Those were my thoughts (placing the scrollbars outside the control) which is what I'm going to try now.
I did try placing the GLControl on a scrollable panel, but it seemed worse. So I think that perhaps just placing some scrollbars outside and implementing my own actions for scrolling should be adequate .

Thanks a lot for your input. :)

BlueMonkMN's picture

I just discovered this problem myself after upgrading my development system to Windows 7. It's really unfortunate that due to a problem that only exists due to such a limited set of circumstances, the whole notion of using AutoScroll on the GLControl itself has to be discarded. I guess I can understand that AutoScroll really wasn't designed for this, though. Still, I wish there was some level of framework support that provided the scroll bars attached to both axes of the control, but didn't try to do *anything* with movement or painting and left it all up to the application. I'll have to read more about this to understand the source of the problem... Aero and Composition have something to do with it apparently?

- Ben / "BlueMonkMN" / Scrolling Game Development Kit - http://sgdk2.sf.net/

BlueMonkMN's picture

I didn't realize that composition could be disabled temporarily by the application with a mere API call (DwmEnableComposition). I'll probably use that for my case. Although I am concerned about resorting to P/Invoke. I managed to eliminate all P/Invoke reliance from my program, and now I'm having to introduce one again. Perhaps if I put a Try/Catch around it, it won't matter whether it succeeds or fails and can still run on any platform with any security settings.

- Ben / "BlueMonkMN" / Scrolling Game Development Kit - http://sgdk2.sf.net/