Dawing Juce Componets with OpenGL

Hi everyone!

It’s there anyway to override the look and feel of a component (for example a button) and draw it using Opengl? I have a custom vector render in Opengl that I would like to use instead of juce’s default raster graphics.

Juce has an opengl renderer. Simply make an OpenGLContext and attach your parents component for opengl to it.

For LookAndFeel itself it’ll be quite complex if you really need opengl just for LaF since it simply calls function with a juce::Graphics.

You’d might be able to trick it if your LookAndFeel class gets reference to your context so you’ll be able to check if you’re attached to opengl context.
But for UI that isn’t doing a lot of animation it’s not worth doing custom opengl instead of JUCE OpenGL renderer.

If the component itself is already pretty custom (a fancy oscilloscope / spectrum / visualization) - you can have a class based on OpenGLComponent.

1 Like

Thanks for the response! Yes I had been using an OpenGLContext and attaching it to the parent components for an RT analyzer, but I don’t like the result of mixing a rastered UI and vector UI. The rastered tends to look blurry sometimes especially with text. I was thinking on implementing custom components inheriting from OpenGLAppComponent instead of Component, but I’m not sure if it’s a good idea.

Sounds like you’re doing something wrong.
JUCE renderer doesn’t rasterize that much when you’re drawing paths.