I’m using OpenGl with glew & glm inside an audio plugin. in the
newOpenGLContextCreated function I’m doing the following:
// ... m_shader.reset(new tobanteAudio::Shader()); m_shader->loadFromFile(R"(shader\cube.vert)", R"(shader\cube.frag)"); // ...
// ... m_cube.reset(new tobanteAudio::Cube()); // Shader m_shader->bind(); // Projection glm::mat4 model = glm::mat4(1.0f); glm::mat4 mvp = m_camera->getProjectionMatrix() * m_camera->getViewMatrix() * model; m_shader->setMatrix4("u_mvp", mvp); // Render m_cube->render(); m_shader->unbind(); // ...
I’m uploading the vertices in the constructor of
m_cube. I would like to do that in the
newOpenGLContextCreated so that the data is only uploaded once, but if I move the
m_cube.reset() line, the cube only appears for a split second and then is gone.
I had the same results with a simpler triangle, which was not abstracted away and called
glGenVertexArrays directly in the main component. The same also happens if I use an
If I can’t send the data to the GPU in the
newOpenGLContextCreated function, where would be a suitable place?