Tech ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - Use vertex attributes and matrices in shaders.

Shader: gouraud_light - Gizmo Scale hovered grabbers
This commit is contained in:
enricoturri1966 2022-03-03 13:30:22 +01:00
parent dccc8aea17
commit 2d72931fac
2 changed files with 26 additions and 17 deletions

View File

@ -39,9 +39,6 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo
GLShaderProgram* shader = wxGetApp().get_current_shader();
if (shader == nullptr)
return;
bool use_attributes = boost::algorithm::iends_with(shader->get_name(), "_attr");
// assert(use_attributes);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
if (!m_cube.is_initialized()) {
@ -74,22 +71,18 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo
shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
// picking render
shader->set_uniform("projection_view_model_matrix", projection_matrix * view_model_matrix);
if (!use_attributes) {
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
#else
glsafe(::glPushMatrix());
glsafe(::glTranslated(center.x(), center.y(), center.z()));
glsafe(::glRotated(Geometry::rad2deg(angles.z()), 0.0, 0.0, 1.0));
glsafe(::glRotated(Geometry::rad2deg(angles.y()), 0.0, 1.0, 0.0));
glsafe(::glRotated(Geometry::rad2deg(angles.x()), 1.0, 0.0, 0.0));
glsafe(::glScaled(fullsize, fullsize, fullsize));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
}
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
m_cube.render();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
if (!use_attributes)
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
}
GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)

View File

@ -329,7 +329,11 @@ void GLGizmoScale3D::on_render()
}
// draw grabbers
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
shader = wxGetApp().get_shader("gouraud_light_attr");
#else
shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
#else
// draw connection
glsafe(::glColor4fv(m_grabbers[0].color.data()));
@ -364,7 +368,11 @@ void GLGizmoScale3D::on_render()
}
// draw grabbers
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
shader = wxGetApp().get_shader("gouraud_light_attr");
#else
shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
#else
// draw connection
glsafe(::glColor4fv(m_grabbers[2].color.data()));
@ -399,7 +407,11 @@ void GLGizmoScale3D::on_render()
}
// draw grabbers
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
shader = wxGetApp().get_shader("gouraud_light_attr");
#else
shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
#else
// draw connection
glsafe(::glColor4fv(m_grabbers[4].color.data()));
@ -437,7 +449,11 @@ void GLGizmoScale3D::on_render()
}
// draw grabbers
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
shader = wxGetApp().get_shader("gouraud_light_attr");
#else
shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
#else
// draw connection
glsafe(::glColor4fv(m_drag_color.data()));