I have an application using OpenGL. As I work normally in Windows, my OpenGLSurface control has the property DoubleBuffer activated to avoid flickering.
Now I’m trying to work this application in a Mac and I’ve found a very weird behaviour and I don’t know if it is a bug or perhaps I’m doing something wrong.
If the OpenGLSurface has the DoubleBuffer activated if flickers terribly, even more than Windows without it.
If I use it with the DoubleBuffer not activated it works OK (probably because OS X is already Double Buffer). In fact this is the first weird behaviour: I have to deactivate this property.
But what is worse is that: My application must be cross platform. So I pretend to deactivate this property at the beginning with pragma #if TargetMacOS, but it doesn’t do anything. It keeps flickering. I’ve tried to write this at the Open event of the window and at the Open event of the control with the same negative result.
The only way to have a good behaviour is deactivate the property in the IDE, but then it is not cross platform.
Am I doing something wrong? Where should I put the pragma #If TargetMacOS? Is it a bug?
I will appreciate your comments,
Your second suggestion doesn’t work. It is exactly the opposite of the case. If DoubleBuffer is OFF in the IDE, it is ever OFF no matter you change it in code.
About your first suggestion, I don’t understand. If you create a constant value (boolean), where do you apply it? I’ve seen I can not apply it in open events or constructor.
This is very odd, I’m mac only and checked my projects and DoubleBuffer is on by default, all my Surfaces have it on yet there’s no flicker, and turning it off nothing gets drawn at all.
Are you doing the frame buffer swap yourself or changing the draw buffer or anything like that? Are you using PointSprites? I’ve flicker with that. Also Yosemite has a flicker problem I’ve seen in Listboxes, Canvases and occasionally in OpenGLSurface.
Maybe DoubleBuffer should be marked ReadOnly or this is a bug. I can think of 2 workarounds: Setup your context in the Configure event or make 2 ContainerControls, one with a DoubleBuffered surface the other without, and embed the appropriate one.
Thank you for your hints.
My application has been working for years on Windows. In fact I received OpenGLSurface control with enthusiasm because before it I had to prepare OpenGL framework by myself. That meant a lot of work and not portability.
With the control I could port my application to OS X, but I received a lot of complains from my clients, so I decided to experiment my application on a Mac hardware. And now I’ve begun to experiment all this complaints.
Yes this is Yosemite.
Unfortunately I can not answer (at this moment) your question about swapping the frame by myself. I think I did it only before using OpenGLSurface control, but I have to check.
However I think I found a
S O L U T I O N
DoubleBuffer should be, definitely, a ReadOnly property.
If you want to change it by code you must do it at the Constructor of the Window, but before “Super.Constructor”. If you do it after, it doesn’t work.
#if TargetMacOS Then pbGraf.DoubleBuffer = False
// Calling the overridden superclass constructor.
Super.Constructor