3D OpenGL Plugin Example

Hey, I’d like to make a request for a basic demo showing an OpenGL scene running inside of a plugin. I’ve hacked one together multiple times now based on the OpenGL section of the main JUCE demo- however I’ve always abandoned the approach due to rampant bugginess. For instance there are random crashes which seem to be worse in certain hosts (might have to do with the bit-ness of the host, although I can’t be sure), or otherwise some of my normal JUCE components will start glitching out visually. I think it would be very helpful to the community in general to have a working example showing a 3D waveform being drawn GL-style inside of a plugin (simple VBO with GL_POINTS would be fine).

I could post a simplified demo of what doesn’t seem to work as a starting point, but I just wanted to throw this out there to see if anyone else is interested or has experience with the issue. I’ve talked to other developers who have shared similar frustrations so I don’t think I’m alone here.

Ok I made a simplified plugin example in order to explain the issues I’m having. It’s a basic VBO+shader particle system running inside of a plugin, based off of the standalone OpenGL app demo.

When I build and run this in Mac Ableton Live 64-bit, I get frequent crashes and OpenGL assertion errors. Additionally, the Ableton GUI becomes unresponsive while running. I believe this has to do with the plugin modifying attributes on a shared OpenGL context, so perhaps I’m simply not setting it up right during initialization. If anyone has advice I’d be very appreciative.

The plugin runs well in Plugin Host, although I have seen a crash after hitting the “Update” button many times (20+ as opposed to Ableton which crashes within the first few). The fact that it works better in Plugin Host than Ableton seems to support the theory that the DAW’s use of OpenGL interferes with our plugin.

When Ableton crashes it happens at this line, throwing an EXC_BAD_ACCESS:

glDrawElements (GL_POINTS, vertexBuffer.numIndices, GL_UNSIGNED_INT, 0);

Here’s a link to the repository:


Fingers crossed, but I believe I’ve figured out the issue.

First off, I was stupidly attaching the same OpenGLContext to both the editor and its child component.

Second, I was forcing an immediate update of the shader inside of the buttonClicked callback which introduces a threading issue (i.e. occasionally nuking the shader while it’s being used inside of renderOpenGL). Setting a flag indicating that the shader should be updated and checking that in the next renderOpenGL seems to be the right approach. My Ableton bugs are solved as far as I can tell.

After confirming that this is bulletproof, I will update the github project in case anyone is interested in the future.

1 Like

Hello ! I have compiled the code on GitHub, and the plug-in loads on Win8 + Reaper 64 bits after I remove a call to a function called “random()”, but otherwise nothing happens at all in the black rectangle. Any idea why ?

Try pulling again and let me know if it works. You should see glowing dots like in the screenshot once you hit the “update” button. It could be a windows thing- I’m testing on mac.

It works now, thanks a lot !

1 Like

Here is another example of an opengl plugin which I often use to test opengl behaviour in plug-ins: