OGL Renderer + UI


Hi guys,

I’m trying to get my application to work with both opengl as well as the nice controls juce provides. I have my opengl scene ready, so I decided to try to integrate the ui controls from the helloworld example. To my surprise, the rendering is kind of nuts. For example, the Quit button doesnt render properly, and when hovered or pressed, it renders worse. I added the fillAll line on the paint function to see if it would paint over the opengl code, but to my surprise it renders half a screen diagonally.

void OpenGLCanvas::paint(Graphics& g) { g.fillAll (Colour (0xffc1d0ff)); }

What am I doing wrong? Is this combination a no-no and I should resort to other frameworks like Cinder or something?


Which OS are you using?

Does the juce demo plugin work, which also mixes 2D + 3D like that?


Hey jules,

I’m using MacOS. After all the work I’ve done, this is the first time I’m running the Juce demo. Seems to be working fine. I’ll investigate further. If you have any suggestions as to what could be wrong, don’t hesitate on letting me know.

I’ll keep you posted :), thanks!



Most likely your own GL calls are leaving the GL context in an unexpected state, which could obviously mess things up for the 2D renderer.


Managed to fix it. I had to disable face culling for the ui to look good.

I added glDisable(GL_CULL_FACE); at the end of the renderOpenGL() function and that was it.

Thanks man :wink:


2D and 3D tread on each other’s toes.

before 2D UI, I do these,

glDisable( GL_DEPTH_TEST ); glDisable( GL_CULL_FACE); glDisable( GL_DITHER);