Remove not needed buffer unbinds. In OpenGl unbinding for every frame is not needed.

This commit is contained in:
docentYT
2026-02-06 23:32:48 +01:00
parent dac74e7cb1
commit 84277ed051

View File

@@ -208,10 +208,6 @@ bool opengl33_renderer::Init(GLFWwindow *Window)
return false; return false;
glfwMakeContextCurrent(m_window); glfwMakeContextCurrent(m_window);
// after potential context switch, reset vao and buffer because we can have invalid bindings cache
gl::vao::unbind();
gl::buffer::unbind();
if (Global.gfx_shadowmap_enabled) if (Global.gfx_shadowmap_enabled)
{ {
m_shadow_fb = std::make_unique<gl::framebuffer>(); m_shadow_fb = std::make_unique<gl::framebuffer>();
@@ -363,10 +359,6 @@ bool opengl33_renderer::AddViewport(const global_settings::extraviewport_config
bool ret = init_viewport(*vp); bool ret = init_viewport(*vp);
glfwMakeContextCurrent(m_window); glfwMakeContextCurrent(m_window);
// after potential context switch, reset vao and buffer because we can have invalid bindings cache
gl::vao::unbind();
gl::buffer::unbind();
return ret; return ret;
} }
@@ -542,9 +534,6 @@ bool opengl33_renderer::Render()
glfwMakeContextCurrent(m_window); glfwMakeContextCurrent(m_window);
// after potential context switch, reset vao and buffer because we can have invalid bindings cache
gl::vao::unbind();
gl::buffer::unbind();
gl::framebuffer::unbind(); gl::framebuffer::unbind();
m_current_viewport = &(*m_viewports.front()); m_current_viewport = &(*m_viewports.front());
@@ -670,10 +659,6 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
glDebug("context switch"); glDebug("context switch");
glfwMakeContextCurrent(vp.window); glfwMakeContextCurrent(vp.window);
// after potential context switch, reset vao and buffer because we can have invalid bindings cache
gl::vao::unbind();
gl::buffer::unbind();
m_current_viewport = &vp; m_current_viewport = &vp;
if ((!simulation::is_ready) || (Global.gfx_skiprendering)) if ((!simulation::is_ready) || (Global.gfx_skiprendering))
@@ -683,8 +668,6 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (vp.main) { if (vp.main) {
// clear state for ui // clear state for ui
gl::vao::unbind();
gl::buffer::unbind();
gl::program::unbind(); gl::program::unbind();
Application.render_ui(); Application.render_ui();
} }
@@ -999,8 +982,6 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
if (vp.main) { if (vp.main) {
// clear state for ui // clear state for ui
gl::vao::unbind();
gl::buffer::unbind();
gl::program::unbind(); gl::program::unbind();
draw_debug_ui(); draw_debug_ui();
Application.render_ui(); Application.render_ui();
@@ -4483,11 +4464,6 @@ glm::dvec3 opengl33_renderer::Update_Mouse_Position()
void opengl33_renderer::Update(double const Deltatime) void opengl33_renderer::Update(double const Deltatime)
{ {
// workaround: we might be after context switch
// reset vao and buffer because we can have invalid bindings cache
gl::vao::unbind();
gl::buffer::unbind();
Update_Pick_Control(); Update_Pick_Control();
Update_Pick_Node(); Update_Pick_Node();