JUCE openGL 3.2 issue, no VAO object bound

I created a component  which implements the OpenGLRenderer protocol, I set up the context with open gl 3.2,. But the pogram fails at

OpenGLContext::copyTexture,  at the line  931  JUCE_CHECK_OPENGL_ERROR
 

        const GLuint index = (GLuint) program.params.positionAttribute.attributeID;
        extensions.glVertexAttribPointer (index, 2, GL_SHORT, GL_FALSE, 4, 0);
        extensions.glEnableVertexAttribArray (index);
        JUCE_CHECK_OPENGL_ERROR

I belive this is because there is no bound VAO object at that point , if I do this

 

        GLuint vao;
        glGenVertexArrays(1, &vao);
        glBindVertexArray(vao);
        const GLuint index = (GLuint) program.params.positionAttribute.attributeID;
        extensions.glVertexAttribPointer (index, 2, GL_SHORT, GL_FALSE, 4, 0);
        extensions.glEnableVertexAttribArray (index);
        JUCE_CHECK_OPENGL_ERROR       

I get no error and the progrma runs. also if I remove all the JUCE_CHECK_OPENGL_ERROR, the program seems to run fine.
 

 

Hmm. If you look higher up in that file, at line 398, there's some code that should be creating a VAO that is used later on. Is that code not being executed on your machine?

 

398 gets exectuted, but inside my  renderOpenGL() callback I bind my own VAO  to draw my mesh then I unbind (glBindVertexArray(0)) it after I draw my mesh. so by the time the program gets to , this part

         const GLuint index = (GLuint) program.params.positionAttribute.attributeID;
        extensions.glVertexAttribPointer (index, 2, GL_SHORT, GL_FALSE, 4, 0);
        extensions.glEnableVertexAttribArray (index);
        JUCE_CHECK_OPENGL_ERROR

there is no bound vao object, because renderOpenGL() gets called after OpenGLContext::CachedImage::initialiseOnThread()

Ok, I see. Well, I guess that if people are going to unbind it, the original one should be re-bound when it's needed. Your suggestion above would be leaky, but how about this, in drawComponentBuffer() around line 290

        ...
        glBindTexture (GL_TEXTURE_2D, cachedImageFrameBuffer.getTextureID());

       #if JUCE_OPENGL3
        if (vertexArrayObject != 0)
            glBindVertexArray (vertexArrayObject);
       #endif

        const Rectangle<int> cacheBounds (cachedImageFrameBuffer.getWidth(), cachedImageFrameBuffer.getHeight());
        ...


Yes that works thank you!