mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-21 21:58:03 -06:00
Added glsafe() around OpenGL calls where missing
This commit is contained in:
parent
30c4e4fed6
commit
d795f07e7b
15 changed files with 544 additions and 534 deletions
|
@ -61,62 +61,62 @@ void GLGizmoBase::Grabber::render(float size, const float* render_color, bool us
|
|||
float half_size = dragging ? get_dragging_half_size(size) : get_half_size(size);
|
||||
|
||||
if (use_lighting)
|
||||
::glEnable(GL_LIGHTING);
|
||||
glsafe(::glEnable(GL_LIGHTING));
|
||||
|
||||
::glColor3fv(render_color);
|
||||
glsafe(::glColor3fv(render_color));
|
||||
|
||||
::glPushMatrix();
|
||||
::glTranslated(center(0), center(1), center(2));
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(center(0), center(1), center(2)));
|
||||
|
||||
::glRotated(Geometry::rad2deg(angles(2)), 0.0, 0.0, 1.0);
|
||||
::glRotated(Geometry::rad2deg(angles(1)), 0.0, 1.0, 0.0);
|
||||
::glRotated(Geometry::rad2deg(angles(0)), 1.0, 0.0, 0.0);
|
||||
glsafe(::glRotated(Geometry::rad2deg(angles(2)), 0.0, 0.0, 1.0));
|
||||
glsafe(::glRotated(Geometry::rad2deg(angles(1)), 0.0, 1.0, 0.0));
|
||||
glsafe(::glRotated(Geometry::rad2deg(angles(0)), 1.0, 0.0, 0.0));
|
||||
|
||||
// face min x
|
||||
::glPushMatrix();
|
||||
::glTranslatef(-(GLfloat)half_size, 0.0f, 0.0f);
|
||||
::glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef(-(GLfloat)half_size, 0.0f, 0.0f));
|
||||
glsafe(::glRotatef(-90.0f, 0.0f, 1.0f, 0.0f));
|
||||
render_face(half_size);
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
|
||||
// face max x
|
||||
::glPushMatrix();
|
||||
::glTranslatef((GLfloat)half_size, 0.0f, 0.0f);
|
||||
::glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef((GLfloat)half_size, 0.0f, 0.0f));
|
||||
glsafe(::glRotatef(90.0f, 0.0f, 1.0f, 0.0f));
|
||||
render_face(half_size);
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
|
||||
// face min y
|
||||
::glPushMatrix();
|
||||
::glTranslatef(0.0f, -(GLfloat)half_size, 0.0f);
|
||||
::glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef(0.0f, -(GLfloat)half_size, 0.0f));
|
||||
glsafe(::glRotatef(90.0f, 1.0f, 0.0f, 0.0f));
|
||||
render_face(half_size);
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
|
||||
// face max y
|
||||
::glPushMatrix();
|
||||
::glTranslatef(0.0f, (GLfloat)half_size, 0.0f);
|
||||
::glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef(0.0f, (GLfloat)half_size, 0.0f));
|
||||
glsafe(::glRotatef(-90.0f, 1.0f, 0.0f, 0.0f));
|
||||
render_face(half_size);
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
|
||||
// face min z
|
||||
::glPushMatrix();
|
||||
::glTranslatef(0.0f, 0.0f, -(GLfloat)half_size);
|
||||
::glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef(0.0f, 0.0f, -(GLfloat)half_size));
|
||||
glsafe(::glRotatef(180.0f, 1.0f, 0.0f, 0.0f));
|
||||
render_face(half_size);
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
|
||||
// face max z
|
||||
::glPushMatrix();
|
||||
::glTranslatef(0.0f, 0.0f, (GLfloat)half_size);
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef(0.0f, 0.0f, (GLfloat)half_size));
|
||||
render_face(half_size);
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
|
||||
if (use_lighting)
|
||||
::glDisable(GL_LIGHTING);
|
||||
glsafe(::glDisable(GL_LIGHTING));
|
||||
}
|
||||
|
||||
void GLGizmoBase::Grabber::render_face(float half_size) const
|
||||
|
@ -129,7 +129,7 @@ void GLGizmoBase::Grabber::render_face(float half_size) const
|
|||
::glVertex3f((GLfloat)half_size, (GLfloat)half_size, 0.0f);
|
||||
::glVertex3f(-(GLfloat)half_size, (GLfloat)half_size, 0.0f);
|
||||
::glVertex3f(-(GLfloat)half_size, -(GLfloat)half_size, 0.0f);
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
}
|
||||
|
||||
#if ENABLE_SVG_ICONS
|
||||
|
|
|
@ -142,10 +142,10 @@ void GLGizmoCut::on_render(const Selection& selection) const
|
|||
const float max_x = box.max(0) + Margin;
|
||||
const float min_y = box.min(1) - Margin;
|
||||
const float max_y = box.max(1) + Margin;
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
::glDisable(GL_CULL_FACE);
|
||||
::glEnable(GL_BLEND);
|
||||
::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
glsafe(::glDisable(GL_CULL_FACE));
|
||||
glsafe(::glEnable(GL_BLEND));
|
||||
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||
|
||||
// Draw the cutting plane
|
||||
::glBegin(GL_QUADS);
|
||||
|
@ -154,10 +154,10 @@ void GLGizmoCut::on_render(const Selection& selection) const
|
|||
::glVertex3f(max_x, min_y, plane_center(2));
|
||||
::glVertex3f(max_x, max_y, plane_center(2));
|
||||
::glVertex3f(min_x, max_y, plane_center(2));
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
|
||||
::glEnable(GL_CULL_FACE);
|
||||
::glDisable(GL_BLEND);
|
||||
glsafe(::glEnable(GL_CULL_FACE));
|
||||
glsafe(::glDisable(GL_BLEND));
|
||||
|
||||
// TODO: draw cut part contour?
|
||||
|
||||
|
@ -165,13 +165,13 @@ void GLGizmoCut::on_render(const Selection& selection) const
|
|||
m_grabbers[0].center = plane_center;
|
||||
m_grabbers[0].center(2) = plane_center(2) + Offset;
|
||||
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
::glLineWidth(m_hover_id != -1 ? 2.0f : 1.5f);
|
||||
::glColor3f(1.0, 1.0, 0.0);
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
glsafe(::glLineWidth(m_hover_id != -1 ? 2.0f : 1.5f));
|
||||
glsafe(::glColor3f(1.0, 1.0, 0.0));
|
||||
::glBegin(GL_LINES);
|
||||
::glVertex3dv(plane_center.data());
|
||||
::glVertex3dv(m_grabbers[0].center.data());
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
|
||||
std::copy(std::begin(GrabberColor), std::end(GrabberColor), m_grabbers[0].color);
|
||||
m_grabbers[0].render(m_hover_id == 0, (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0));
|
||||
|
@ -179,7 +179,7 @@ void GLGizmoCut::on_render(const Selection& selection) const
|
|||
|
||||
void GLGizmoCut::on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
render_grabbers_for_picking(selection.get_bounding_box());
|
||||
}
|
||||
|
|
|
@ -49,67 +49,67 @@ void GLGizmoFlatten::on_start_dragging(const Selection& selection)
|
|||
|
||||
void GLGizmoFlatten::on_render(const Selection& selection) const
|
||||
{
|
||||
::glClear(GL_DEPTH_BUFFER_BIT);
|
||||
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
||||
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
::glEnable(GL_BLEND);
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
glsafe(::glEnable(GL_BLEND));
|
||||
|
||||
if (selection.is_single_full_instance())
|
||||
{
|
||||
const Transform3d& m = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix();
|
||||
::glPushMatrix();
|
||||
::glTranslatef(0.f, 0.f, selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z());
|
||||
::glMultMatrixd(m.data());
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef(0.f, 0.f, selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z()));
|
||||
glsafe(::glMultMatrixd(m.data()));
|
||||
if (this->is_plane_update_necessary())
|
||||
const_cast<GLGizmoFlatten*>(this)->update_planes();
|
||||
for (int i = 0; i < (int)m_planes.size(); ++i)
|
||||
{
|
||||
if (i == m_hover_id)
|
||||
::glColor4f(0.9f, 0.9f, 0.9f, 0.75f);
|
||||
glsafe(::glColor4f(0.9f, 0.9f, 0.9f, 0.75f));
|
||||
else
|
||||
::glColor4f(0.9f, 0.9f, 0.9f, 0.5f);
|
||||
glsafe(::glColor4f(0.9f, 0.9f, 0.9f, 0.5f));
|
||||
|
||||
::glBegin(GL_POLYGON);
|
||||
for (const Vec3d& vertex : m_planes[i].vertices)
|
||||
{
|
||||
::glVertex3dv(vertex.data());
|
||||
}
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
}
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
}
|
||||
|
||||
::glEnable(GL_CULL_FACE);
|
||||
::glDisable(GL_BLEND);
|
||||
glsafe(::glEnable(GL_CULL_FACE));
|
||||
glsafe(::glDisable(GL_BLEND));
|
||||
}
|
||||
|
||||
void GLGizmoFlatten::on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
::glDisable(GL_BLEND);
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
glsafe(::glDisable(GL_BLEND));
|
||||
|
||||
if (selection.is_single_full_instance())
|
||||
{
|
||||
const Transform3d& m = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix();
|
||||
::glPushMatrix();
|
||||
::glTranslatef(0.f, 0.f, selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z());
|
||||
::glMultMatrixd(m.data());
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef(0.f, 0.f, selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z()));
|
||||
glsafe(::glMultMatrixd(m.data()));
|
||||
if (this->is_plane_update_necessary())
|
||||
const_cast<GLGizmoFlatten*>(this)->update_planes();
|
||||
for (int i = 0; i < (int)m_planes.size(); ++i)
|
||||
{
|
||||
::glColor3fv(picking_color_component(i).data());
|
||||
glsafe(::glColor3fv(picking_color_component(i).data()));
|
||||
::glBegin(GL_POLYGON);
|
||||
for (const Vec3d& vertex : m_planes[i].vertices)
|
||||
{
|
||||
::glVertex3dv(vertex.data());
|
||||
}
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
}
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
}
|
||||
|
||||
::glEnable(GL_CULL_FACE);
|
||||
glsafe(::glEnable(GL_CULL_FACE));
|
||||
}
|
||||
|
||||
void GLGizmoFlatten::set_flattening_data(const ModelObject* model_object)
|
||||
|
|
|
@ -97,8 +97,8 @@ void GLGizmoMove3D::on_render(const Selection& selection) const
|
|||
else if (!m_grabbers[2].dragging && (m_hover_id == 2))
|
||||
set_tooltip("Z");
|
||||
|
||||
::glClear(GL_DEPTH_BUFFER_BIT);
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
const Vec3d& center = box.center();
|
||||
|
@ -115,7 +115,7 @@ void GLGizmoMove3D::on_render(const Selection& selection) const
|
|||
m_grabbers[2].center = Vec3d(center(0), center(1), box.max(2) + Offset);
|
||||
::memcpy((void*)m_grabbers[2].color, (const void*)&AXES_COLOR[2], 3 * sizeof(float));
|
||||
|
||||
::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f);
|
||||
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
||||
|
||||
if (m_hover_id == -1)
|
||||
{
|
||||
|
@ -124,11 +124,11 @@ void GLGizmoMove3D::on_render(const Selection& selection) const
|
|||
{
|
||||
if (m_grabbers[i].enabled)
|
||||
{
|
||||
::glColor3fv(AXES_COLOR[i]);
|
||||
glsafe(::glColor3fv(AXES_COLOR[i]));
|
||||
::glBegin(GL_LINES);
|
||||
::glVertex3dv(center.data());
|
||||
::glVertex3dv(m_grabbers[i].center.data());
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,11 +143,11 @@ void GLGizmoMove3D::on_render(const Selection& selection) const
|
|||
else
|
||||
{
|
||||
// draw axis
|
||||
::glColor3fv(AXES_COLOR[m_hover_id]);
|
||||
glsafe(::glColor3fv(AXES_COLOR[m_hover_id]));
|
||||
::glBegin(GL_LINES);
|
||||
::glVertex3dv(center.data());
|
||||
::glVertex3dv(m_grabbers[m_hover_id].center.data());
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
|
||||
// draw grabber
|
||||
m_grabbers[m_hover_id].render(true, box.max_size());
|
||||
|
@ -157,7 +157,7 @@ void GLGizmoMove3D::on_render(const Selection& selection) const
|
|||
|
||||
void GLGizmoMove3D::on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
render_grabbers_for_picking(box);
|
||||
|
@ -229,25 +229,25 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
|
|||
}
|
||||
|
||||
if (!picking)
|
||||
::glEnable(GL_LIGHTING);
|
||||
glsafe(::glEnable(GL_LIGHTING));
|
||||
|
||||
::glColor3fv(color);
|
||||
::glPushMatrix();
|
||||
::glTranslated(m_grabbers[axis].center(0), m_grabbers[axis].center(1), m_grabbers[axis].center(2));
|
||||
glsafe(::glColor3fv(color));
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(m_grabbers[axis].center(0), m_grabbers[axis].center(1), m_grabbers[axis].center(2)));
|
||||
if (axis == X)
|
||||
::glRotated(90.0, 0.0, 1.0, 0.0);
|
||||
glsafe(::glRotated(90.0, 0.0, 1.0, 0.0));
|
||||
else if (axis == Y)
|
||||
::glRotated(-90.0, 1.0, 0.0, 0.0);
|
||||
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
|
||||
|
||||
::glTranslated(0.0, 0.0, 2.0 * size);
|
||||
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
|
||||
::gluQuadricOrientation(m_quadric, GLU_OUTSIDE);
|
||||
::gluCylinder(m_quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1);
|
||||
::gluQuadricOrientation(m_quadric, GLU_INSIDE);
|
||||
::gluDisk(m_quadric, 0.0, 0.75 * size, 36, 1);
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
|
||||
if (!picking)
|
||||
::glDisable(GL_LIGHTING);
|
||||
glsafe(::glDisable(GL_LIGHTING));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -155,13 +155,13 @@ void GLGizmoRotate::on_render(const Selection& selection) const
|
|||
m_snap_fine_out_radius = m_radius * (1.0f + ScaleLongTooth);
|
||||
}
|
||||
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
::glPushMatrix();
|
||||
glsafe(::glPushMatrix());
|
||||
transform_to_local(selection);
|
||||
|
||||
::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f);
|
||||
::glColor3fv((m_hover_id != -1) ? m_drag_color : m_highlight_color);
|
||||
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
||||
glsafe(::glColor3fv((m_hover_id != -1) ? m_drag_color : m_highlight_color));
|
||||
|
||||
render_circle();
|
||||
|
||||
|
@ -172,7 +172,7 @@ void GLGizmoRotate::on_render(const Selection& selection) const
|
|||
render_reference_radius();
|
||||
}
|
||||
|
||||
::glColor3fv(m_highlight_color);
|
||||
glsafe(::glColor3fv(m_highlight_color));
|
||||
|
||||
if (m_hover_id != -1)
|
||||
render_angle();
|
||||
|
@ -180,14 +180,14 @@ void GLGizmoRotate::on_render(const Selection& selection) const
|
|||
render_grabber(box);
|
||||
render_grabber_extension(box, false);
|
||||
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
}
|
||||
|
||||
void GLGizmoRotate::on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
::glPushMatrix();
|
||||
glsafe(::glPushMatrix());
|
||||
|
||||
transform_to_local(selection);
|
||||
|
||||
|
@ -195,7 +195,7 @@ void GLGizmoRotate::on_render_for_picking(const Selection& selection) const
|
|||
render_grabbers_for_picking(box);
|
||||
render_grabber_extension(box, true);
|
||||
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
}
|
||||
|
||||
void GLGizmoRotate::render_circle() const
|
||||
|
@ -209,7 +209,7 @@ void GLGizmoRotate::render_circle() const
|
|||
float z = 0.0f;
|
||||
::glVertex3f((GLfloat)x, (GLfloat)y, (GLfloat)z);
|
||||
}
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
}
|
||||
|
||||
void GLGizmoRotate::render_scale() const
|
||||
|
@ -232,7 +232,7 @@ void GLGizmoRotate::render_scale() const
|
|||
::glVertex3f((GLfloat)in_x, (GLfloat)in_y, (GLfloat)in_z);
|
||||
::glVertex3f((GLfloat)out_x, (GLfloat)out_y, (GLfloat)out_z);
|
||||
}
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
}
|
||||
|
||||
void GLGizmoRotate::render_snap_radii() const
|
||||
|
@ -257,7 +257,7 @@ void GLGizmoRotate::render_snap_radii() const
|
|||
::glVertex3f((GLfloat)in_x, (GLfloat)in_y, (GLfloat)in_z);
|
||||
::glVertex3f((GLfloat)out_x, (GLfloat)out_y, (GLfloat)out_z);
|
||||
}
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
}
|
||||
|
||||
void GLGizmoRotate::render_reference_radius() const
|
||||
|
@ -265,7 +265,7 @@ void GLGizmoRotate::render_reference_radius() const
|
|||
::glBegin(GL_LINES);
|
||||
::glVertex3f(0.0f, 0.0f, 0.0f);
|
||||
::glVertex3f((GLfloat)(m_radius * (1.0f + GrabberOffset)), 0.0f, 0.0f);
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
}
|
||||
|
||||
void GLGizmoRotate::render_angle() const
|
||||
|
@ -282,7 +282,7 @@ void GLGizmoRotate::render_angle() const
|
|||
float z = 0.0f;
|
||||
::glVertex3f((GLfloat)x, (GLfloat)y, (GLfloat)z);
|
||||
}
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
}
|
||||
|
||||
void GLGizmoRotate::render_grabber(const BoundingBoxf3& box) const
|
||||
|
@ -291,12 +291,12 @@ void GLGizmoRotate::render_grabber(const BoundingBoxf3& box) const
|
|||
m_grabbers[0].center = Vec3d(::cos(m_angle) * grabber_radius, ::sin(m_angle) * grabber_radius, 0.0);
|
||||
m_grabbers[0].angles(2) = m_angle;
|
||||
|
||||
::glColor3fv((m_hover_id != -1) ? m_drag_color : m_highlight_color);
|
||||
glsafe(::glColor3fv((m_hover_id != -1) ? m_drag_color : m_highlight_color));
|
||||
|
||||
::glBegin(GL_LINES);
|
||||
::glVertex3f(0.0f, 0.0f, 0.0f);
|
||||
::glVertex3dv(m_grabbers[0].center.data());
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
|
||||
::memcpy((void*)m_grabbers[0].color, (const void*)m_highlight_color, 3 * sizeof(float));
|
||||
render_grabbers(box);
|
||||
|
@ -320,56 +320,56 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
|
|||
}
|
||||
|
||||
if (!picking)
|
||||
::glEnable(GL_LIGHTING);
|
||||
glsafe(::glEnable(GL_LIGHTING));
|
||||
|
||||
::glColor3fv(color);
|
||||
::glPushMatrix();
|
||||
::glTranslated(m_grabbers[0].center(0), m_grabbers[0].center(1), m_grabbers[0].center(2));
|
||||
::glRotated(Geometry::rad2deg(m_angle), 0.0, 0.0, 1.0);
|
||||
::glRotated(90.0, 1.0, 0.0, 0.0);
|
||||
::glTranslated(0.0, 0.0, 2.0 * size);
|
||||
glsafe(::glColor3fv(color));
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(m_grabbers[0].center(0), m_grabbers[0].center(1), m_grabbers[0].center(2)));
|
||||
glsafe(::glRotated(Geometry::rad2deg(m_angle), 0.0, 0.0, 1.0));
|
||||
glsafe(::glRotated(90.0, 1.0, 0.0, 0.0));
|
||||
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
|
||||
::gluQuadricOrientation(m_quadric, GLU_OUTSIDE);
|
||||
::gluCylinder(m_quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1);
|
||||
::gluQuadricOrientation(m_quadric, GLU_INSIDE);
|
||||
::gluDisk(m_quadric, 0.0, 0.75 * size, 36, 1);
|
||||
::glPopMatrix();
|
||||
::glPushMatrix();
|
||||
::glTranslated(m_grabbers[0].center(0), m_grabbers[0].center(1), m_grabbers[0].center(2));
|
||||
::glRotated(Geometry::rad2deg(m_angle), 0.0, 0.0, 1.0);
|
||||
::glRotated(-90.0, 1.0, 0.0, 0.0);
|
||||
::glTranslated(0.0, 0.0, 2.0 * size);
|
||||
glsafe(::glPopMatrix());
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(m_grabbers[0].center(0), m_grabbers[0].center(1), m_grabbers[0].center(2)));
|
||||
glsafe(::glRotated(Geometry::rad2deg(m_angle), 0.0, 0.0, 1.0));
|
||||
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
|
||||
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
|
||||
::gluQuadricOrientation(m_quadric, GLU_OUTSIDE);
|
||||
::gluCylinder(m_quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1);
|
||||
::gluQuadricOrientation(m_quadric, GLU_INSIDE);
|
||||
::gluDisk(m_quadric, 0.0, 0.75 * size, 36, 1);
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
|
||||
if (!picking)
|
||||
::glDisable(GL_LIGHTING);
|
||||
glsafe(::glDisable(GL_LIGHTING));
|
||||
}
|
||||
|
||||
void GLGizmoRotate::transform_to_local(const Selection& selection) const
|
||||
{
|
||||
::glTranslated(m_center(0), m_center(1), m_center(2));
|
||||
glsafe(::glTranslated(m_center(0), m_center(1), m_center(2)));
|
||||
|
||||
if (selection.is_single_volume() || selection.is_single_modifier() || selection.requires_local_axes())
|
||||
{
|
||||
Transform3d orient_matrix = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(true, false, true, true);
|
||||
::glMultMatrixd(orient_matrix.data());
|
||||
glsafe(::glMultMatrixd(orient_matrix.data()));
|
||||
}
|
||||
|
||||
switch (m_axis)
|
||||
{
|
||||
case X:
|
||||
{
|
||||
::glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
|
||||
::glRotatef(-90.0f, 0.0f, 0.0f, 1.0f);
|
||||
glsafe(::glRotatef(90.0f, 0.0f, 1.0f, 0.0f));
|
||||
glsafe(::glRotatef(-90.0f, 0.0f, 0.0f, 1.0f));
|
||||
break;
|
||||
}
|
||||
case Y:
|
||||
{
|
||||
::glRotatef(-90.0f, 0.0f, 0.0f, 1.0f);
|
||||
::glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
|
||||
glsafe(::glRotatef(-90.0f, 0.0f, 0.0f, 1.0f));
|
||||
glsafe(::glRotatef(-90.0f, 0.0f, 1.0f, 0.0f));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -472,7 +472,7 @@ void GLGizmoRotate3D::on_stop_dragging()
|
|||
|
||||
void GLGizmoRotate3D::on_render(const Selection& selection) const
|
||||
{
|
||||
::glClear(GL_DEPTH_BUFFER_BIT);
|
||||
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
||||
|
||||
if ((m_hover_id == -1) || (m_hover_id == 0))
|
||||
m_gizmos[X].render(selection);
|
||||
|
|
|
@ -108,8 +108,8 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
|||
((m_hover_id == 6) || (m_hover_id == 7) || (m_hover_id == 8) || (m_hover_id == 9)))
|
||||
set_tooltip("X/Y/Z");
|
||||
|
||||
::glClear(GL_DEPTH_BUFFER_BIT);
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
BoundingBoxf3 box;
|
||||
Transform3d transform = Transform3d::Identity();
|
||||
|
@ -187,7 +187,7 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
|||
m_grabbers[i].angles = angles;
|
||||
}
|
||||
|
||||
::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f);
|
||||
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
||||
|
||||
const BoundingBoxf3& selection_box = selection.get_bounding_box();
|
||||
|
||||
|
@ -198,20 +198,20 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
|||
// draw connections
|
||||
if (m_grabbers[0].enabled && m_grabbers[1].enabled)
|
||||
{
|
||||
::glColor3fv(m_grabbers[0].color);
|
||||
glsafe(::glColor3fv(m_grabbers[0].color));
|
||||
render_grabbers_connection(0, 1);
|
||||
}
|
||||
if (m_grabbers[2].enabled && m_grabbers[3].enabled)
|
||||
{
|
||||
::glColor3fv(m_grabbers[2].color);
|
||||
glsafe(::glColor3fv(m_grabbers[2].color));
|
||||
render_grabbers_connection(2, 3);
|
||||
}
|
||||
if (m_grabbers[4].enabled && m_grabbers[5].enabled)
|
||||
{
|
||||
::glColor3fv(m_grabbers[4].color);
|
||||
glsafe(::glColor3fv(m_grabbers[4].color));
|
||||
render_grabbers_connection(4, 5);
|
||||
}
|
||||
::glColor3fv(m_base_color);
|
||||
glsafe(::glColor3fv(m_base_color));
|
||||
render_grabbers_connection(6, 7);
|
||||
render_grabbers_connection(7, 8);
|
||||
render_grabbers_connection(8, 9);
|
||||
|
@ -222,7 +222,7 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
|||
else if ((m_hover_id == 0) || (m_hover_id == 1))
|
||||
{
|
||||
// draw connection
|
||||
::glColor3fv(m_grabbers[0].color);
|
||||
glsafe(::glColor3fv(m_grabbers[0].color));
|
||||
render_grabbers_connection(0, 1);
|
||||
// draw grabbers
|
||||
m_grabbers[0].render(true, grabber_mean_size);
|
||||
|
@ -231,7 +231,7 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
|||
else if ((m_hover_id == 2) || (m_hover_id == 3))
|
||||
{
|
||||
// draw connection
|
||||
::glColor3fv(m_grabbers[2].color);
|
||||
glsafe(::glColor3fv(m_grabbers[2].color));
|
||||
render_grabbers_connection(2, 3);
|
||||
// draw grabbers
|
||||
m_grabbers[2].render(true, grabber_mean_size);
|
||||
|
@ -240,7 +240,7 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
|||
else if ((m_hover_id == 4) || (m_hover_id == 5))
|
||||
{
|
||||
// draw connection
|
||||
::glColor3fv(m_grabbers[4].color);
|
||||
glsafe(::glColor3fv(m_grabbers[4].color));
|
||||
render_grabbers_connection(4, 5);
|
||||
// draw grabbers
|
||||
m_grabbers[4].render(true, grabber_mean_size);
|
||||
|
@ -249,7 +249,7 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
|||
else if (m_hover_id >= 6)
|
||||
{
|
||||
// draw connection
|
||||
::glColor3fv(m_drag_color);
|
||||
glsafe(::glColor3fv(m_drag_color));
|
||||
render_grabbers_connection(6, 7);
|
||||
render_grabbers_connection(7, 8);
|
||||
render_grabbers_connection(8, 9);
|
||||
|
@ -264,7 +264,7 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
|||
|
||||
void GLGizmoScale3D::on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
render_grabbers_for_picking(selection.get_bounding_box());
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ void GLGizmoScale3D::render_grabbers_connection(unsigned int id_1, unsigned int
|
|||
::glBegin(GL_LINES);
|
||||
::glVertex3dv(m_grabbers[id_1].center.data());
|
||||
::glVertex3dv(m_grabbers[id_2].center.data());
|
||||
::glEnd();
|
||||
glsafe(::glEnd());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,13 +75,13 @@ void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const S
|
|||
|
||||
void GLGizmoSlaSupports::on_render(const Selection& selection) const
|
||||
{
|
||||
::glEnable(GL_BLEND);
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
glsafe(::glEnable(GL_BLEND));
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
render_points(selection, false);
|
||||
render_selection_rectangle();
|
||||
|
||||
::glDisable(GL_BLEND);
|
||||
glsafe(::glDisable(GL_BLEND));
|
||||
}
|
||||
|
||||
void GLGizmoSlaSupports::render_selection_rectangle() const
|
||||
|
@ -89,44 +89,44 @@ void GLGizmoSlaSupports::render_selection_rectangle() const
|
|||
if (!m_selection_rectangle_active)
|
||||
return;
|
||||
|
||||
::glLineWidth(1.5f);
|
||||
glsafe(::glLineWidth(1.5f));
|
||||
float render_color[3] = {1.f, 0.f, 0.f};
|
||||
::glColor3fv(render_color);
|
||||
glsafe(::glColor3fv(render_color));
|
||||
|
||||
::glPushAttrib(GL_TRANSFORM_BIT); // remember current MatrixMode
|
||||
glsafe(::glPushAttrib(GL_TRANSFORM_BIT)); // remember current MatrixMode
|
||||
|
||||
::glMatrixMode(GL_MODELVIEW); // cache modelview matrix and set to identity
|
||||
::glPushMatrix();
|
||||
::glLoadIdentity();
|
||||
glsafe(::glMatrixMode(GL_MODELVIEW)); // cache modelview matrix and set to identity
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glLoadIdentity());
|
||||
|
||||
::glMatrixMode(GL_PROJECTION); // cache projection matrix and set to identity
|
||||
::glPushMatrix();
|
||||
::glLoadIdentity();
|
||||
glsafe(::glMatrixMode(GL_PROJECTION)); // cache projection matrix and set to identity
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glLoadIdentity());
|
||||
|
||||
::glOrtho(0.f, m_canvas_width, m_canvas_height, 0.f, -1.f, 1.f); // set projection matrix so that world coords = window coords
|
||||
glsafe(::glOrtho(0.f, m_canvas_width, m_canvas_height, 0.f, -1.f, 1.f)); // set projection matrix so that world coords = window coords
|
||||
|
||||
// render the selection rectangle (window coordinates):
|
||||
::glPushAttrib(GL_ENABLE_BIT);
|
||||
::glLineStipple(4, 0xAAAA);
|
||||
::glEnable(GL_LINE_STIPPLE);
|
||||
glsafe(::glPushAttrib(GL_ENABLE_BIT));
|
||||
glsafe(::glLineStipple(4, 0xAAAA));
|
||||
glsafe(::glEnable(GL_LINE_STIPPLE));
|
||||
|
||||
::glBegin(GL_LINE_LOOP);
|
||||
::glVertex3f((GLfloat)m_selection_rectangle_start_corner(0), (GLfloat)m_selection_rectangle_start_corner(1), (GLfloat)0.5f);
|
||||
::glVertex3f((GLfloat)m_selection_rectangle_end_corner(0), (GLfloat)m_selection_rectangle_start_corner(1), (GLfloat)0.5f);
|
||||
::glVertex3f((GLfloat)m_selection_rectangle_end_corner(0), (GLfloat)m_selection_rectangle_end_corner(1), (GLfloat)0.5f);
|
||||
::glVertex3f((GLfloat)m_selection_rectangle_start_corner(0), (GLfloat)m_selection_rectangle_end_corner(1), (GLfloat)0.5f);
|
||||
::glEnd();
|
||||
::glPopAttrib();
|
||||
glsafe(::glEnd());
|
||||
glsafe(::glPopAttrib());
|
||||
|
||||
::glPopMatrix(); // restore former projection matrix
|
||||
::glMatrixMode(GL_MODELVIEW);
|
||||
::glPopMatrix(); // restore former modelview matrix
|
||||
::glPopAttrib(); // restore former MatrixMode
|
||||
glsafe(::glPopMatrix()); // restore former projection matrix
|
||||
glsafe(::glMatrixMode(GL_MODELVIEW));
|
||||
glsafe(::glPopMatrix()); // restore former modelview matrix
|
||||
glsafe(::glPopAttrib()); // restore former MatrixMode
|
||||
}
|
||||
|
||||
void GLGizmoSlaSupports::on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
render_points(selection, true);
|
||||
}
|
||||
|
@ -137,16 +137,16 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
|||
return;
|
||||
|
||||
if (!picking)
|
||||
::glEnable(GL_LIGHTING);
|
||||
glsafe(::glEnable(GL_LIGHTING));
|
||||
|
||||
const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
double z_shift = vol->get_sla_shift_z();
|
||||
const Transform3d& instance_scaling_matrix_inverse = vol->get_instance_transformation().get_matrix(true, true, false, true).inverse();
|
||||
const Transform3d& instance_matrix = vol->get_instance_transformation().get_matrix();
|
||||
|
||||
::glPushMatrix();
|
||||
::glTranslated(0.0, 0.0, z_shift);
|
||||
::glMultMatrixd(instance_matrix.data());
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(0.0, 0.0, z_shift));
|
||||
glsafe(::glMultMatrixd(instance_matrix.data()));
|
||||
|
||||
float render_color[3];
|
||||
for (int i = 0; i < (int)m_editing_mode_cache.size(); ++i)
|
||||
|
@ -178,14 +178,14 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
|||
for (unsigned char i=0; i<3; ++i) render_color[i] = 0.5f;
|
||||
}
|
||||
}
|
||||
::glColor3fv(render_color);
|
||||
glsafe(::glColor3fv(render_color));
|
||||
float render_color_emissive[4] = { 0.5f * render_color[0], 0.5f * render_color[1], 0.5f * render_color[2], 1.f};
|
||||
::glMaterialfv(GL_FRONT, GL_EMISSION, render_color_emissive);
|
||||
glsafe(::glMaterialfv(GL_FRONT, GL_EMISSION, render_color_emissive));
|
||||
|
||||
// Inverse matrix of the instance scaling is applied so that the mark does not scale with the object.
|
||||
::glPushMatrix();
|
||||
::glTranslated(support_point.pos(0), support_point.pos(1), support_point.pos(2));
|
||||
::glMultMatrixd(instance_scaling_matrix_inverse.data());
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(support_point.pos(0), support_point.pos(1), support_point.pos(2)));
|
||||
glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data()));
|
||||
|
||||
// Matrices set, we can render the point mark now.
|
||||
// If in editing mode, we'll also render a cone pointing to the sphere.
|
||||
|
@ -196,31 +196,31 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
|||
Eigen::Quaterniond q;
|
||||
q.setFromTwoVectors(Vec3d{0., 0., 1.}, instance_scaling_matrix_inverse * m_editing_mode_cache[i].normal.cast<double>());
|
||||
Eigen::AngleAxisd aa(q);
|
||||
::glRotated(aa.angle() * (180./M_PI), aa.axis()(0), aa.axis()(1), aa.axis()(2));
|
||||
glsafe(::glRotated(aa.angle() * (180. / M_PI), aa.axis()(0), aa.axis()(1), aa.axis()(2)));
|
||||
|
||||
const float cone_radius = 0.25f; // mm
|
||||
const float cone_height = 0.75f;
|
||||
::glPushMatrix();
|
||||
::glTranslatef(0.f, 0.f, m_editing_mode_cache[i].support_point.head_front_radius * RenderPointScale);
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef(0.f, 0.f, m_editing_mode_cache[i].support_point.head_front_radius * RenderPointScale));
|
||||
::gluCylinder(m_quadric, 0.f, cone_radius, cone_height, 24, 1);
|
||||
::glTranslatef(0.f, 0.f, cone_height);
|
||||
glsafe(::glTranslatef(0.f, 0.f, cone_height));
|
||||
::gluDisk(m_quadric, 0.0, cone_radius, 24, 1);
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
}
|
||||
::gluSphere(m_quadric, m_editing_mode_cache[i].support_point.head_front_radius * RenderPointScale, 24, 12);
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
}
|
||||
|
||||
{
|
||||
// Reset emissive component to zero (the default value)
|
||||
float render_color_emissive[4] = { 0.f, 0.f, 0.f, 1.f };
|
||||
::glMaterialfv(GL_FRONT, GL_EMISSION, render_color_emissive);
|
||||
glsafe(::glMaterialfv(GL_FRONT, GL_EMISSION, render_color_emissive));
|
||||
}
|
||||
|
||||
if (!picking)
|
||||
::glDisable(GL_LIGHTING);
|
||||
glsafe(::glDisable(GL_LIGHTING));
|
||||
|
||||
::glPopMatrix();
|
||||
glsafe(::glPopMatrix());
|
||||
}
|
||||
|
||||
bool GLGizmoSlaSupports::is_mesh_update_necessary() const
|
||||
|
@ -264,11 +264,11 @@ std::pair<Vec3f, Vec3f> GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse
|
|||
update_mesh();
|
||||
|
||||
Eigen::Matrix<GLint, 4, 1, Eigen::DontAlign> viewport;
|
||||
::glGetIntegerv(GL_VIEWPORT, viewport.data());
|
||||
glsafe(::glGetIntegerv(GL_VIEWPORT, viewport.data()));
|
||||
Eigen::Matrix<GLdouble, 4, 4, Eigen::DontAlign> modelview_matrix;
|
||||
::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix.data());
|
||||
glsafe(::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix.data()));
|
||||
Eigen::Matrix<GLdouble, 4, 4, Eigen::DontAlign> projection_matrix;
|
||||
::glGetDoublev(GL_PROJECTION_MATRIX, projection_matrix.data());
|
||||
glsafe(::glGetDoublev(GL_PROJECTION_MATRIX, projection_matrix.data()));
|
||||
|
||||
Vec3d point1;
|
||||
Vec3d point2;
|
||||
|
@ -356,11 +356,11 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
if ((action == SLAGizmoEventType::LeftUp || action == SLAGizmoEventType::ShiftUp) && m_selection_rectangle_active) {
|
||||
const Transform3d& instance_matrix = m_model_object->instances[m_active_instance]->get_transformation().get_matrix();
|
||||
GLint viewport[4];
|
||||
::glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
glsafe(::glGetIntegerv(GL_VIEWPORT, viewport));
|
||||
GLdouble modelview_matrix[16];
|
||||
::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix);
|
||||
glsafe(::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix));
|
||||
GLdouble projection_matrix[16];
|
||||
::glGetDoublev(GL_PROJECTION_MATRIX, projection_matrix);
|
||||
glsafe(::glGetDoublev(GL_PROJECTION_MATRIX, projection_matrix));
|
||||
|
||||
const Selection& selection = m_parent.get_selection();
|
||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue