move vao from WorkspaceSceneOpenGL to GlxContext

EglContext already had a vao, and it makes more sense for the context to
take care of this than the scene
This commit is contained in:
Xaver Hugl 2024-01-22 15:21:46 +01:00
parent 7e095412aa
commit 8db8dd24bf
3 changed files with 11 additions and 5 deletions

View file

@ -21,10 +21,20 @@ GlxContext::GlxContext(::Display *display, GLXWindow window, GLXContext handle)
, m_window(window)
, m_handle(handle)
{
// It is not legal to not have a vertex array object bound in a core context
// to make code handling old and new OpenGL versions easier, bind a dummy vao that's used for everything
if (!isOpenglES() && hasOpenglExtension(QByteArrayLiteral("GL_ARB_vertex_array_object"))) {
glGenVertexArrays(1, &m_vao);
glBindVertexArray(m_vao);
}
}
GlxContext::~GlxContext()
{
if (m_vao) {
makeCurrent();
glDeleteVertexArrays(1, &m_vao);
}
glXDestroyContext(m_display, m_handle);
}

View file

@ -30,6 +30,7 @@ private:
::Display *const m_display;
const GLXWindow m_window;
const GLXContext m_handle;
uint32_t m_vao = 0;
};
}

View file

@ -43,11 +43,6 @@ WorkspaceSceneOpenGL::WorkspaceSceneOpenGL(OpenGLBackend *backend)
: WorkspaceScene(std::make_unique<ItemRendererOpenGL>())
, m_backend(backend)
{
// It is not legal to not have a vertex array object bound in a core context
if (!GLPlatform::instance()->isGLES() && hasGLExtension(QByteArrayLiteral("GL_ARB_vertex_array_object"))) {
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
}
}
WorkspaceSceneOpenGL::~WorkspaceSceneOpenGL()