16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00

workaround for ebo binding issues, do not enable ai vehicles automatically on map

This commit is contained in:
milek7
2020-10-21 00:45:19 +02:00
parent df87b37b5b
commit 6af6f5156d
4 changed files with 22 additions and 9 deletions

View File

@@ -18,7 +18,7 @@ namespace gl
COPY_WRITE_BUFFER, COPY_WRITE_BUFFER,
DISPATCH_INDIRECT_BUFFER, DISPATCH_INDIRECT_BUFFER,
DRAW_INDIRECT_BUFFER, DRAW_INDIRECT_BUFFER,
ELEMENT_ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, // ELEMENT_ARRAY_BUFFER is part of VAO and therefore shouldn't be managed by global tracker!
PIXEL_PACK_BUFFER, PIXEL_PACK_BUFFER,
PIXEL_UNPACK_BUFFER, PIXEL_UNPACK_BUFFER,
SHADER_STORAGE_BUFFER, SHADER_STORAGE_BUFFER,

View File

@@ -38,6 +38,8 @@ void gl::vao::setup_ebo(buffer &e)
{ {
if (use_vao) { if (use_vao) {
bind(); bind();
// ELEMENT_ARRAY_BUFFER is part of VAO and therefore shouldn't be managed by gl::buffer global tracker!
// but it is needed by it for buffer data management, so eh
e.bind(buffer::ELEMENT_ARRAY_BUFFER); e.bind(buffer::ELEMENT_ARRAY_BUFFER);
} }
else { else {

View File

@@ -199,6 +199,9 @@ bool opengl33_renderer::Init(GLFWwindow *Window)
if (!init_viewport(default_viewport)) if (!init_viewport(default_viewport))
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(); gl::buffer::unbind();
if (Global.gfx_shadowmap_enabled) if (Global.gfx_shadowmap_enabled)
@@ -351,6 +354,9 @@ 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(); gl::buffer::unbind();
return ret; return ret;
@@ -518,7 +524,11 @@ 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::buffer::unbind();
m_current_viewport = &(*m_viewports.front()); m_current_viewport = &(*m_viewports.front());
/* /*
m_debugtimestext += "cpu: " + to_string(Timer::subsystem.gfx_color.average(), 2) + " ms (" + std::to_string(m_cellqueue.size()) + " sectors)\n" += m_debugtimestext += "cpu: " + to_string(Timer::subsystem.gfx_color.average(), 2) + " ms (" + std::to_string(m_cellqueue.size()) + " sectors)\n" +=
@@ -635,7 +645,11 @@ 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(); 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))
@@ -4095,9 +4109,6 @@ bool opengl33_renderer::Debug_Ui_State(std::optional<bool> param)
// utility methods // utility methods
void opengl33_renderer::Update_Pick_Control() void opengl33_renderer::Update_Pick_Control()
{ {
// context-switch workaround
gl::buffer::unbind();
if (!m_picking_pbo->is_busy()) if (!m_picking_pbo->is_busy())
{ {
unsigned char pickreadout[4]; unsigned char pickreadout[4];
@@ -4284,6 +4295,11 @@ 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();

View File

@@ -640,11 +640,6 @@ ui::vehicle_click_window::vehicle_click_window(ui_panel &panel, std::shared_ptr<
void ui::vehicle_click_window::render_content() void ui::vehicle_click_window::render_content()
{ {
if (!m_vehicle->dynobj->MoverParameters->Battery) {
std::string name_enable = m_vehicle->name + "%Prepare_engine";
m_relay.post(user_command::sendaicommand, 1.0, 1.0, GLFW_PRESS, 0, glm::vec3(), &name_enable);
}
ImGui::TextUnformatted(STR_C("Light signal:")); ImGui::TextUnformatted(STR_C("Light signal:"));
if (ImGui::Button(STR_C("none"))) { if (ImGui::Button(STR_C("none"))) {