Tech ENABLE_COLOR_CLASSES - 1st installment -> Introduction of classes ColorRGB and ColorRGBA to unify color data definition and manipulation

This commit is contained in:
enricoturri1966 2021-12-22 10:45:35 +01:00
parent 48098fbaff
commit cd4094743e
53 changed files with 1810 additions and 60 deletions

View file

@ -23,7 +23,12 @@ namespace GUI {
const double GLGizmoCut::Offset = 10.0;
const double GLGizmoCut::Margin = 20.0;
#if ENABLE_COLOR_CLASSES
static const ColorRGBA GRABBER_COLOR = ColorRGBA::ORANGE();
static const ColorRGBA PLANE_COLOR = { 0.8f, 0.8f, 0.8f, 0.5f };
#else
const std::array<float, 4> GLGizmoCut::GrabberColor = { 1.0, 0.5, 0.0, 1.0 };
#endif // ENABLE_COLOR_CLASSES
GLGizmoCut::GLGizmoCut(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
: GLGizmoBase(parent, icon_filename, sprite_id)
@ -103,7 +108,11 @@ void GLGizmoCut::on_render()
// Draw the cutting plane
::glBegin(GL_QUADS);
#if ENABLE_COLOR_CLASSES
::glColor4fv(PLANE_COLOR.data());
#else
::glColor4f(0.8f, 0.8f, 0.8f, 0.5f);
#endif // ENABLE_COLOR_CLASSES
::glVertex3f(min_x, min_y, plane_center.z());
::glVertex3f(max_x, min_y, plane_center.z());
::glVertex3f(max_x, max_y, plane_center.z());
@ -134,7 +143,11 @@ void GLGizmoCut::on_render()
shader->start_using();
shader->set_uniform("emission_factor", 0.1f);
#if ENABLE_COLOR_CLASSES
m_grabbers[0].color = GRABBER_COLOR;
#else
m_grabbers[0].color = GrabberColor;
#endif // ENABLE_COLOR_CLASSES
m_grabbers[0].render(m_hover_id == 0, (float)((box.size().x() + box.size().y() + box.size().z()) / 3.0));
shader->stop_using();