Open GL and Native Title Bar

Seems like a lot of Open GL talk here lately! Got a small problem…

(OS 10.5.6)
If you use the Juce DEMO (from the TIP)
And goto OpenGL demo and try to resize the window, its quite ugly as the context flickers and goes a little nuts.

I tend to prefer the native titlebar’s anyway, so we toggle that and…hmmm…blank screen. Reselecting the OpenGL brings everything back to normal, and resizing is lovely, no flicker…

Problem methinks is the whole generation of the NSOpenGLContexts and assignment without the view being on the screen at the time(just a stab, but when I did some stuff with Ogre I had to create my NSView put it in my window, wait for the window to come onscreen and THEN assign the view to the context)

In my Window Constructor I have…

		centreWithSize(800, 600);
		setResizable(true, false);
		setContentComponent(new MyOpenGLSubClass());

With the setUsing commented, the GL appears and draws and everything is fine. (although flickers on resize)

With it enabled OpenGLComponent::renderAndSwapBuffers is never called(well its called once and that’s that)…

It seems to make it as far as…

BTW this was mentioned in another thread, but even without fullscreen this should be set to eliminate flicker

	/* Enable vblank sync -*/
renderContext = [[[NSOpenGLContext alloc] initWithFormat: format
                                                    shareContext: sharedContext] autorelease];

	const long sw = 1;
	[renderContext setValues:&sw forParameter: NSOpenGLCPSwapInterval];

Hope that helps !

Thanks! I’ll add that swap interval stuff…

Yes, when you add or remove the title bar it has to move everything to a new window, so there’s probably an issue with re-using the old context. It’s unlikely that many apps apart from the juce demo would ever hit this, so I think I’ll leave it up to them to refresh their gl components if necessary!

But it appears right now there is no way to create a native window WITHOUT setting the gl component/context twice!

If you look at my example again, the OpenGLComponent isn’t created until after the window is created. Its probably something subtle that is missed, but I think its worth mentioning here in case it comes up for someone.

PS - The browser plugin wrappers sound cool and very useful!

Surely as long as you set up the title bar correctly before you create the gl component, that’d do the trick?

The OpenGLComponent allready has a setSwapInterval method.
So if you need the swap control just call setSwapInterval(1);

Ah yes, I must have missed that… tnx

So, is there a way to prevent flicker in OpenGL if you're not using the native title bar?

Has anyone had an answer on this?

Sorry, but an answer to exactly what question? This thread is ancient and has a lot of different things in it - can you give us a code example of what doesn’t work that we could try?

I hit reply on ‘dtissier’ question, but didnt seem to show that I had responded to that commment. I have opedned a new topic on this here: Resizing Window with Non-native title bar causes flicker in OpenGL app

I just noticed a similar question was asked here a while back.

Thanks - carry on on the new thread - I’ll lock this one because it’s so old.