FIX:Replace v_barycentric by gl_Color to slove factory computer issues

modify Shortcut keys to toggle Wireframe
Jira: STUDIO-4772

Change-Id: Ica5c1c6c0a41ed247c85173b3b0437632f596e7d
(cherry picked from commit 79a1805e8fde6e0b735a529ab7c7c7fe9015865b)
This commit is contained in:
zhou.xu 2023-10-13 16:01:08 +08:00 committed by Lane.Wei
parent 8a8020e0a9
commit 17e9bb48d8
5 changed files with 22 additions and 24 deletions

View file

@ -1267,12 +1267,14 @@ void TriangleSelectorPatch::render(ImGuiWrapper* imgui)
assert(shader->get_name() == "mm_gouraud");
GLint position_id = -1;
GLint barycentric_id = -1;
bool show_wireframe = false;
if (wxGetApp().plater()->is_wireframe_enabled()) {
if (m_need_wireframe && wxGetApp().plater()->is_show_wireframe()) {
position_id = shader->get_attrib_location("v_position");
barycentric_id = shader->get_attrib_location("v_barycentric");
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", show_wireframe on");
shader->set_uniform("show_wireframe", true);
show_wireframe = true;
}
else {
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", show_wireframe off");
@ -1298,7 +1300,7 @@ void TriangleSelectorPatch::render(ImGuiWrapper* imgui)
shader->set_uniform("uniform_color", new_color);
//shader->set_uniform("uniform_color", color);
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", buffer_idx %1%: new_color[%2%, %3%, %4%, %5%]")%buffer_idx%new_color[0]%new_color[1]%new_color[2]%new_color[3];
this->render(buffer_idx, (int)position_id, (int)barycentric_id);
this->render(buffer_idx, (int) position_id, show_wireframe);
}
}
@ -1562,7 +1564,7 @@ void TriangleSelectorPatch::update_render_data()
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", exit");
}
void TriangleSelectorPatch::render(int triangle_indices_idx, int position_id, int barycentric_id)
void TriangleSelectorPatch::render(int triangle_indices_idx, int position_id, bool show_wireframe)
{
assert(triangle_indices_idx < this->m_triangle_indices_VBO_ids.size());
assert(this->m_triangle_patches.size() == this->m_triangle_indices_VBO_ids.size());
@ -1575,18 +1577,15 @@ void TriangleSelectorPatch::render(int triangle_indices_idx, int position_id, in
//glsafe(::glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), (const void*)(0 * sizeof(float))));
if (this->m_triangle_indices_sizes[triangle_indices_idx] > 0) {
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, this->m_vertices_VBO_ids[triangle_indices_idx]));
if (position_id != -1) {
glsafe(::glEnableVertexAttribArray((GLint)position_id));
glsafe(::glVertexAttribPointer((GLint)position_id, 3, GL_FLOAT, GL_FALSE, 6*sizeof(float), nullptr));
if (show_wireframe) {
glsafe(::glVertexPointer(3, GL_FLOAT, 6 * sizeof(float), (const void *) 0));
glsafe(::glColorPointer(3,GL_FLOAT, 6 * sizeof(float), (const void *) (3 * sizeof(float))));
glsafe(::glEnableClientState(GL_COLOR_ARRAY));
}
else {
glsafe(::glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), nullptr));
}
if (barycentric_id != -1) {
glsafe(::glEnableVertexAttribArray((GLint)barycentric_id));
glsafe(::glVertexAttribPointer((GLint)barycentric_id, 3, GL_FLOAT, GL_FALSE, 6*sizeof(float), (GLvoid*)(intptr_t)(3 * sizeof(float))));
}
//glsafe(::glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), nullptr));
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", Line %1%: triangle_indices_idx %2%, bind vertex vbo, buffer id %3%")%__LINE__%triangle_indices_idx%this->m_vertices_VBO_ids[triangle_indices_idx];
}
@ -1604,9 +1603,9 @@ void TriangleSelectorPatch::render(int triangle_indices_idx, int position_id, in
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
if ((this->m_triangle_indices_sizes[triangle_indices_idx] > 0)&&(position_id != -1))
glsafe(::glDisableVertexAttribArray(position_id));
if ((this->m_triangle_indices_sizes[triangle_indices_idx] > 0)&&(barycentric_id != -1))
glsafe(::glDisableVertexAttribArray((GLint)barycentric_id));
if ((this->m_triangle_indices_sizes[triangle_indices_idx] > 0)&&show_wireframe) {
glsafe(::glEnableClientState(GL_COLOR_ARRAY));
}
if (this->m_triangle_indices_sizes[triangle_indices_idx] > 0)
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
}