mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 17:27:52 -06:00
Simplified OpenGL calls
This commit is contained in:
parent
e201c5123c
commit
bb2000d094
3 changed files with 29 additions and 28 deletions
|
@ -572,7 +572,7 @@ void GLVolume::render_VBOs(int color_id, int detection_id, int worldmatrix_id) c
|
||||||
::glUniform4fv(color_id, 1, (const GLfloat*)color);
|
::glUniform4fv(color_id, 1, (const GLfloat*)color);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
::glColor4f(render_color[0], render_color[1], render_color[2], render_color[3]);
|
::glColor4fv(render_color);
|
||||||
|
|
||||||
if (detection_id != -1)
|
if (detection_id != -1)
|
||||||
::glUniform1i(detection_id, shader_outside_printer_detection_enabled ? 1 : 0);
|
::glUniform1i(detection_id, shader_outside_printer_detection_enabled ? 1 : 0);
|
||||||
|
@ -591,7 +591,7 @@ void GLVolume::render_VBOs(int color_id, int detection_id, int worldmatrix_id) c
|
||||||
if (color_id >= 0)
|
if (color_id >= 0)
|
||||||
::glUniform4fv(color_id, 1, (const GLfloat*)render_color);
|
::glUniform4fv(color_id, 1, (const GLfloat*)render_color);
|
||||||
else
|
else
|
||||||
::glColor4f(render_color[0], render_color[1], render_color[2], render_color[3]);
|
::glColor4fv(render_color);
|
||||||
|
|
||||||
if (detection_id != -1)
|
if (detection_id != -1)
|
||||||
::glUniform1i(detection_id, shader_outside_printer_detection_enabled ? 1 : 0);
|
::glUniform1i(detection_id, shader_outside_printer_detection_enabled ? 1 : 0);
|
||||||
|
@ -640,7 +640,7 @@ void GLVolume::render_legacy() const
|
||||||
::glDisableClientState(GL_VERTEX_ARRAY);
|
::glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
::glDisableClientState(GL_NORMAL_ARRAY);
|
::glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
|
|
||||||
::glColor4f(render_color[0], render_color[1], render_color[2], render_color[3]);
|
::glColor4fv(render_color);
|
||||||
render();
|
render();
|
||||||
|
|
||||||
::glEnableClientState(GL_VERTEX_ARRAY);
|
::glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
@ -649,7 +649,7 @@ void GLVolume::render_legacy() const
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
::glColor4f(render_color[0], render_color[1], render_color[2], render_color[3]);
|
::glColor4fv(render_color);
|
||||||
::glVertexPointer(3, GL_FLOAT, 6 * sizeof(float), indexed_vertex_array.vertices_and_normals_interleaved.data() + 3);
|
::glVertexPointer(3, GL_FLOAT, 6 * sizeof(float), indexed_vertex_array.vertices_and_normals_interleaved.data() + 3);
|
||||||
::glNormalPointer(GL_FLOAT, 6 * sizeof(float), indexed_vertex_array.vertices_and_normals_interleaved.data());
|
::glNormalPointer(GL_FLOAT, 6 * sizeof(float), indexed_vertex_array.vertices_and_normals_interleaved.data());
|
||||||
|
|
||||||
|
|
|
@ -600,7 +600,8 @@ bool GLCanvas3D::Bed::_are_equal(const Pointfs& bed_1, const Pointfs& bed_2)
|
||||||
}
|
}
|
||||||
|
|
||||||
GLCanvas3D::Axes::Axes()
|
GLCanvas3D::Axes::Axes()
|
||||||
: origin(0, 0, 0), length(0.0f)
|
: origin(Vec3d::Zero())
|
||||||
|
, length(0.0f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,11 +616,11 @@ void GLCanvas3D::Axes::render(bool depth_test) const
|
||||||
::glBegin(GL_LINES);
|
::glBegin(GL_LINES);
|
||||||
// draw line for x axis
|
// draw line for x axis
|
||||||
::glColor3f(1.0f, 0.0f, 0.0f);
|
::glColor3f(1.0f, 0.0f, 0.0f);
|
||||||
::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2));
|
::glVertex3dv(origin.data());
|
||||||
::glVertex3f((GLfloat)origin(0) + length, (GLfloat)origin(1), (GLfloat)origin(2));
|
::glVertex3f((GLfloat)origin(0) + length, (GLfloat)origin(1), (GLfloat)origin(2));
|
||||||
// draw line for y axis
|
// draw line for y axis
|
||||||
::glColor3f(0.0f, 1.0f, 0.0f);
|
::glColor3f(0.0f, 1.0f, 0.0f);
|
||||||
::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2));
|
::glVertex3dv(origin.data());
|
||||||
::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1) + length, (GLfloat)origin(2));
|
::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1) + length, (GLfloat)origin(2));
|
||||||
::glEnd();
|
::glEnd();
|
||||||
// draw line for Z axis
|
// draw line for Z axis
|
||||||
|
@ -629,7 +630,7 @@ void GLCanvas3D::Axes::render(bool depth_test) const
|
||||||
|
|
||||||
::glBegin(GL_LINES);
|
::glBegin(GL_LINES);
|
||||||
::glColor3f(0.0f, 0.0f, 1.0f);
|
::glColor3f(0.0f, 0.0f, 1.0f);
|
||||||
::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2));
|
::glVertex3dv(origin.data());
|
||||||
::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2) + length);
|
::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2) + length);
|
||||||
::glEnd();
|
::glEnd();
|
||||||
}
|
}
|
||||||
|
@ -4894,7 +4895,7 @@ void GLCanvas3D::_camera_tranform() const
|
||||||
::glRotatef(m_camera.phi, 0.0f, 0.0f, 1.0f); // yaw
|
::glRotatef(m_camera.phi, 0.0f, 0.0f, 1.0f); // yaw
|
||||||
|
|
||||||
Vec3d neg_target = - m_camera.target;
|
Vec3d neg_target = - m_camera.target;
|
||||||
::glTranslatef((GLfloat)neg_target(0), (GLfloat)neg_target(1), (GLfloat)neg_target(2));
|
::glTranslated(neg_target(0), neg_target(1), neg_target(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_picking_pass() const
|
void GLCanvas3D::_picking_pass() const
|
||||||
|
@ -5003,9 +5004,9 @@ void GLCanvas3D::_render_background() const
|
||||||
::glVertex2f(1.0f, -1.0f);
|
::glVertex2f(1.0f, -1.0f);
|
||||||
|
|
||||||
if (m_dynamic_background_enabled && _is_any_volume_outside())
|
if (m_dynamic_background_enabled && _is_any_volume_outside())
|
||||||
::glColor3f(ERROR_BG_COLOR[0], ERROR_BG_COLOR[1], ERROR_BG_COLOR[2]);
|
::glColor3fv(ERROR_BG_COLOR);
|
||||||
else
|
else
|
||||||
::glColor3f(DEFAULT_BG_COLOR[0], DEFAULT_BG_COLOR[1], DEFAULT_BG_COLOR[2]);
|
::glColor3fv(DEFAULT_BG_COLOR);
|
||||||
|
|
||||||
::glVertex2f(1.0f, 1.0f);
|
::glVertex2f(1.0f, 1.0f);
|
||||||
::glVertex2f(-1.0f, 1.0f);
|
::glVertex2f(-1.0f, 1.0f);
|
||||||
|
@ -5172,7 +5173,7 @@ void GLCanvas3D::_render_volumes(bool fake_colors) const
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vol->set_render_color();
|
vol->set_render_color();
|
||||||
::glColor4f(vol->render_color[0], vol->render_color[1], vol->render_color[2], vol->render_color[3]);
|
::glColor4fv(vol->render_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
vol->render();
|
vol->render();
|
||||||
|
|
|
@ -142,15 +142,15 @@ void GLGizmoBase::Grabber::render(const BoundingBoxf3& box, const float* render_
|
||||||
if (use_lighting)
|
if (use_lighting)
|
||||||
::glEnable(GL_LIGHTING);
|
::glEnable(GL_LIGHTING);
|
||||||
|
|
||||||
::glColor3f((GLfloat)render_color[0], (GLfloat)render_color[1], (GLfloat)render_color[2]);
|
::glColor3fv(render_color);
|
||||||
|
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
::glTranslatef((GLfloat)center(0), (GLfloat)center(1), (GLfloat)center(2));
|
::glTranslated(center(0), center(1), center(2));
|
||||||
|
|
||||||
float rad_to_deg = 180.0f / (GLfloat)PI;
|
double rad_to_deg = 180.0 / (double)PI;
|
||||||
::glRotatef((GLfloat)angles(0) * rad_to_deg, 1.0f, 0.0f, 0.0f);
|
::glRotated(angles(0) * rad_to_deg, 1.0, 0.0, 0.0);
|
||||||
::glRotatef((GLfloat)angles(1) * rad_to_deg, 0.0f, 1.0f, 0.0f);
|
::glRotated(angles(1) * rad_to_deg, 0.0, 1.0, 0.0);
|
||||||
::glRotatef((GLfloat)angles(2) * rad_to_deg, 0.0f, 0.0f, 1.0f);
|
::glRotated(angles(2) * rad_to_deg, 0.0, 0.0, 1.0);
|
||||||
|
|
||||||
// face min x
|
// face min x
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
|
@ -568,7 +568,7 @@ void GLGizmoRotate::render_grabber(const BoundingBoxf3& box) const
|
||||||
|
|
||||||
::glBegin(GL_LINES);
|
::glBegin(GL_LINES);
|
||||||
::glVertex3f(0.0f, 0.0f, 0.0f);
|
::glVertex3f(0.0f, 0.0f, 0.0f);
|
||||||
::glVertex3f((GLfloat)m_grabbers[0].center(0), (GLfloat)m_grabbers[0].center(1), (GLfloat)m_grabbers[0].center(2));
|
::glVertex3dv(m_grabbers[0].center.data());
|
||||||
::glEnd();
|
::glEnd();
|
||||||
|
|
||||||
::memcpy((void*)m_grabbers[0].color, (const void*)m_highlight_color, 3 * sizeof(float));
|
::memcpy((void*)m_grabbers[0].color, (const void*)m_highlight_color, 3 * sizeof(float));
|
||||||
|
@ -577,7 +577,7 @@ void GLGizmoRotate::render_grabber(const BoundingBoxf3& box) const
|
||||||
|
|
||||||
void GLGizmoRotate::transform_to_local() const
|
void GLGizmoRotate::transform_to_local() const
|
||||||
{
|
{
|
||||||
::glTranslatef((GLfloat)m_center(0), (GLfloat)m_center(1), (GLfloat)m_center(2));
|
::glTranslated(m_center(0), m_center(1), m_center(2));
|
||||||
|
|
||||||
switch (m_axis)
|
switch (m_axis)
|
||||||
{
|
{
|
||||||
|
@ -965,8 +965,8 @@ void GLGizmoScale3D::render_grabbers_connection(unsigned int id_1, unsigned int
|
||||||
if ((id_1 < grabbers_count) && (id_2 < grabbers_count))
|
if ((id_1 < grabbers_count) && (id_2 < grabbers_count))
|
||||||
{
|
{
|
||||||
::glBegin(GL_LINES);
|
::glBegin(GL_LINES);
|
||||||
::glVertex3f((GLfloat)m_grabbers[id_1].center(0), (GLfloat)m_grabbers[id_1].center(1), (GLfloat)m_grabbers[id_1].center(2));
|
::glVertex3dv(m_grabbers[id_1].center.data());
|
||||||
::glVertex3f((GLfloat)m_grabbers[id_2].center(0), (GLfloat)m_grabbers[id_2].center(1), (GLfloat)m_grabbers[id_2].center(2));
|
::glVertex3dv(m_grabbers[id_2].center.data());
|
||||||
::glEnd();
|
::glEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1170,8 +1170,8 @@ void GLGizmoMove3D::on_render(const BoundingBoxf3& box) const
|
||||||
{
|
{
|
||||||
::glColor3fv(AXES_COLOR[i]);
|
::glColor3fv(AXES_COLOR[i]);
|
||||||
::glBegin(GL_LINES);
|
::glBegin(GL_LINES);
|
||||||
::glVertex3f(center(0), center(1), center(2));
|
::glVertex3dv(center.data());
|
||||||
::glVertex3f((GLfloat)m_grabbers[i].center(0), (GLfloat)m_grabbers[i].center(1), (GLfloat)m_grabbers[i].center(2));
|
::glVertex3dv(m_grabbers[i].center.data());
|
||||||
::glEnd();
|
::glEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1184,8 +1184,8 @@ void GLGizmoMove3D::on_render(const BoundingBoxf3& box) const
|
||||||
// draw axis
|
// draw axis
|
||||||
::glColor3fv(AXES_COLOR[m_hover_id]);
|
::glColor3fv(AXES_COLOR[m_hover_id]);
|
||||||
::glBegin(GL_LINES);
|
::glBegin(GL_LINES);
|
||||||
::glVertex3f(center(0), center(1), center(2));
|
::glVertex3dv(center.data());
|
||||||
::glVertex3f((GLfloat)m_grabbers[m_hover_id].center(0), (GLfloat)m_grabbers[m_hover_id].center(1), (GLfloat)m_grabbers[m_hover_id].center(2));
|
::glVertex3dv(m_grabbers[m_hover_id].center.data());
|
||||||
::glEnd();
|
::glEnd();
|
||||||
|
|
||||||
// draw grabber
|
// draw grabber
|
||||||
|
@ -1303,7 +1303,7 @@ void GLGizmoFlatten::on_render(const BoundingBoxf3& box) const
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
::glBegin(GL_POLYGON);
|
::glBegin(GL_POLYGON);
|
||||||
for (const Vec3d& vertex : m_planes[i].vertices)
|
for (const Vec3d& vertex : m_planes[i].vertices)
|
||||||
::glVertex3f((GLfloat)vertex(0), (GLfloat)vertex(1), (GLfloat)vertex(2));
|
::glVertex3dv(vertex.data());
|
||||||
::glEnd();
|
::glEnd();
|
||||||
::glPopMatrix();
|
::glPopMatrix();
|
||||||
}
|
}
|
||||||
|
@ -1330,7 +1330,7 @@ void GLGizmoFlatten::on_render_for_picking(const BoundingBoxf3& box) const
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
::glBegin(GL_POLYGON);
|
::glBegin(GL_POLYGON);
|
||||||
for (const Vec3d& vertex : m_planes[i].vertices)
|
for (const Vec3d& vertex : m_planes[i].vertices)
|
||||||
::glVertex3f((GLfloat)vertex(0), (GLfloat)vertex(1), (GLfloat)vertex(2));
|
::glVertex3dv(vertex.data());
|
||||||
::glEnd();
|
::glEnd();
|
||||||
::glPopMatrix();
|
::glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue