Sorry guys for asking so much OpenGL stuff lately ![]()
For the context: I’m trying to build an OpenGL-based oscilloscope component as a first project to learn OpenGL.
I designed my Component a bit like OpenGLAppComponent so it has an OpenGLContext as member variable (but unlike OpenGLAppComponent mine is private)
In the constructor I set
OpenGLOscilloscope::OpenGLOscilloscope() {
setOpaque (true);
openGLContext.setRenderer (this);
openGLContext.attachTo (*this);
openGLContext.setContinuousRepainting (true);
};
Now in my design, each audio channel to be displayed has its own vertex attribute buffer. So when adding a channel, from whichever thread (most likely the message thread) I do this, to let the OpenGLThread take care of the buffer allocation:
int OpenGLOscilloscope::addChannel (const String &channelName, Colour channelColour) {
// a lambda to execute on the gl thread
openGLContext.executeOnGLThread ([this] (OpenGLContext &openGLContext)
{
GLuint glBufferLocation;
openGLContext.extensions.glGenBuffers (1, &glBufferLocation);
openGLContext.extensions.glBindBuffer (GL_ARRAY_BUFFER, glBufferLocation);
openGLContext.extensions.glBufferData (GL_ARRAY_BUFFER,
static_cast<GLsizeiptr> (maxNumSamples * sizeof (Point<float>)),
NULL,
GL_STREAM_DRAW);
channelGLBuffers.add (glBufferLocation);
}, false);
// ... some more work that may run on whichever thread it wants to
This compiles, but an assertion in juce_OpenGLContext.cpp line 1056 fires when calling addChannel, telling me jassertfalse; // You must have attached the context to a component. But wait, didn’t I attach my context to the component right up in the constructor?
I’m not quite sure what I did wrong - one thing I still don’t feel 100% safe at are indeed lambdas, so might this be some stupid lambda-syntax error?


