mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-22 06:04:01 -06:00
Removed static members from GLGizmoBase and GLGizmoBase::Grabber to fix OpenGL error when closing the application
This commit is contained in:
parent
2e24e689fa
commit
b63de990d4
4 changed files with 16 additions and 21 deletions
|
@ -13,10 +13,6 @@ namespace GUI {
|
||||||
const float GLGizmoBase::Grabber::SizeFactor = 0.05f;
|
const float GLGizmoBase::Grabber::SizeFactor = 0.05f;
|
||||||
const float GLGizmoBase::Grabber::MinHalfSize = 1.5f;
|
const float GLGizmoBase::Grabber::MinHalfSize = 1.5f;
|
||||||
const float GLGizmoBase::Grabber::DraggingScaleFactor = 1.25f;
|
const float GLGizmoBase::Grabber::DraggingScaleFactor = 1.25f;
|
||||||
GLModel GLGizmoBase::Grabber::VBOCube;
|
|
||||||
GLModel GLGizmoBase::VBOCone;
|
|
||||||
GLModel GLGizmoBase::VBOCylinder;
|
|
||||||
GLModel GLGizmoBase::VBOSphere;
|
|
||||||
|
|
||||||
GLGizmoBase::Grabber::Grabber()
|
GLGizmoBase::Grabber::Grabber()
|
||||||
: center(Vec3d::Zero())
|
: center(Vec3d::Zero())
|
||||||
|
@ -25,9 +21,9 @@ GLGizmoBase::Grabber::Grabber()
|
||||||
, enabled(true)
|
, enabled(true)
|
||||||
{
|
{
|
||||||
color = { 1.0f, 1.0f, 1.0f, 1.0f };
|
color = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
TriangleMesh cube = make_cube(1., 1., 1.);
|
TriangleMesh mesh = make_cube(1., 1., 1.);
|
||||||
cube.translate(Vec3f(-0.5, -0.5, -0.5));
|
mesh.translate(Vec3f(-0.5, -0.5, -0.5));
|
||||||
VBOCube.init_from(cube);
|
cube.init_from(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoBase::Grabber::render(bool hover, float size) const
|
void GLGizmoBase::Grabber::render(bool hover, float size) const
|
||||||
|
@ -75,7 +71,7 @@ void GLGizmoBase::Grabber::render(float size, const std::array<float, 4>& render
|
||||||
glsafe(::glRotated(Geometry::rad2deg(angles(1)), 0.0, 1.0, 0.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));
|
glsafe(::glRotated(Geometry::rad2deg(angles(0)), 1.0, 0.0, 0.0));
|
||||||
glsafe(::glScaled(fullsize, fullsize, fullsize));
|
glsafe(::glScaled(fullsize, fullsize, fullsize));
|
||||||
VBOCube.render();
|
cube.render();
|
||||||
glsafe(::glPopMatrix());
|
glsafe(::glPopMatrix());
|
||||||
|
|
||||||
if (! picking)
|
if (! picking)
|
||||||
|
@ -98,9 +94,9 @@ GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, u
|
||||||
::memcpy((void*)m_base_color, (const void*)DEFAULT_BASE_COLOR, 4 * sizeof(float));
|
::memcpy((void*)m_base_color, (const void*)DEFAULT_BASE_COLOR, 4 * sizeof(float));
|
||||||
::memcpy((void*)m_drag_color, (const void*)DEFAULT_DRAG_COLOR, 4 * sizeof(float));
|
::memcpy((void*)m_drag_color, (const void*)DEFAULT_DRAG_COLOR, 4 * sizeof(float));
|
||||||
::memcpy((void*)m_highlight_color, (const void*)DEFAULT_HIGHLIGHT_COLOR, 4 * sizeof(float));
|
::memcpy((void*)m_highlight_color, (const void*)DEFAULT_HIGHLIGHT_COLOR, 4 * sizeof(float));
|
||||||
VBOCone.init_from(make_cone(1., 1., 2*PI/24));
|
m_cone.init_from(make_cone(1., 1., 2 * PI / 24));
|
||||||
VBOSphere.init_from(make_sphere(1., (2*M_PI)/24.));
|
m_sphere.init_from(make_sphere(1., (2 * M_PI) / 24.));
|
||||||
VBOCylinder.init_from(make_cylinder(1., 1., 2*PI/24.));
|
m_cylinder.init_from(make_cylinder(1., 1., 2 * PI / 24.));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoBase::set_hover_id(int id)
|
void GLGizmoBase::set_hover_id(int id)
|
||||||
|
|
|
@ -45,9 +45,8 @@ protected:
|
||||||
static const float SizeFactor;
|
static const float SizeFactor;
|
||||||
static const float MinHalfSize;
|
static const float MinHalfSize;
|
||||||
static const float DraggingScaleFactor;
|
static const float DraggingScaleFactor;
|
||||||
static GLModel VBOCube;
|
|
||||||
static GLModel VBOCone;
|
|
||||||
|
|
||||||
|
GLModel cube;
|
||||||
Vec3d center;
|
Vec3d center;
|
||||||
Vec3d angles;
|
Vec3d angles;
|
||||||
std::array<float, 4> color;
|
std::array<float, 4> color;
|
||||||
|
@ -102,9 +101,9 @@ protected:
|
||||||
bool m_first_input_window_render;
|
bool m_first_input_window_render;
|
||||||
mutable std::string m_tooltip;
|
mutable std::string m_tooltip;
|
||||||
CommonGizmosDataPool* m_c;
|
CommonGizmosDataPool* m_c;
|
||||||
static GLModel VBOCone;
|
GLModel m_cone;
|
||||||
static GLModel VBOCylinder;
|
GLModel m_cylinder;
|
||||||
static GLModel VBOSphere;
|
GLModel m_sphere;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GLGizmoBase(GLCanvas3D& parent,
|
GLGizmoBase(GLCanvas3D& parent,
|
||||||
|
|
|
@ -345,7 +345,7 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
|
||||||
glsafe(::glRotated(90.0, 1.0, 0.0, 0.0));
|
glsafe(::glRotated(90.0, 1.0, 0.0, 0.0));
|
||||||
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
|
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
|
||||||
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
|
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
|
||||||
VBOCone.render();
|
m_cone.render();
|
||||||
glsafe(::glPopMatrix());
|
glsafe(::glPopMatrix());
|
||||||
glsafe(::glPushMatrix());
|
glsafe(::glPushMatrix());
|
||||||
glsafe(::glTranslated(m_grabbers[0].center(0), m_grabbers[0].center(1), m_grabbers[0].center(2)));
|
glsafe(::glTranslated(m_grabbers[0].center(0), m_grabbers[0].center(1), m_grabbers[0].center(2)));
|
||||||
|
@ -353,7 +353,7 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
|
||||||
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
|
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
|
||||||
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
|
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
|
||||||
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
|
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
|
||||||
VBOCone.render();
|
m_cone.render();
|
||||||
glsafe(::glPopMatrix());
|
glsafe(::glPopMatrix());
|
||||||
|
|
||||||
if (!picking)
|
if (!picking)
|
||||||
|
|
|
@ -202,7 +202,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
||||||
glsafe(::glPushMatrix());
|
glsafe(::glPushMatrix());
|
||||||
glsafe(::glRotated(180., 1., 0., 0.));
|
glsafe(::glRotated(180., 1., 0., 0.));
|
||||||
glsafe(::glScaled(cone_radius, cone_radius, cone_height));
|
glsafe(::glScaled(cone_radius, cone_radius, cone_height));
|
||||||
VBOCone.render();
|
m_cone.render();
|
||||||
glsafe(::glPopMatrix());
|
glsafe(::glPopMatrix());
|
||||||
glsafe(::glTranslatef(0.f, 0.f, cone_height));
|
glsafe(::glTranslatef(0.f, 0.f, cone_height));
|
||||||
glsafe(::glPopMatrix());
|
glsafe(::glPopMatrix());
|
||||||
|
@ -211,7 +211,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
||||||
glsafe(::glPushMatrix());
|
glsafe(::glPushMatrix());
|
||||||
double radius = (double)support_point.head_front_radius * RenderPointScale;
|
double radius = (double)support_point.head_front_radius * RenderPointScale;
|
||||||
glsafe(::glScaled(radius, radius, radius));
|
glsafe(::glScaled(radius, radius, radius));
|
||||||
VBOSphere.render();
|
m_sphere.render();
|
||||||
glsafe(::glPopMatrix());
|
glsafe(::glPopMatrix());
|
||||||
|
|
||||||
if (vol->is_left_handed())
|
if (vol->is_left_handed())
|
||||||
|
@ -251,7 +251,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
||||||
glsafe(::glPushMatrix());
|
glsafe(::glPushMatrix());
|
||||||
glsafe(::glTranslated(0., 0., -drain_hole.height));
|
glsafe(::glTranslated(0., 0., -drain_hole.height));
|
||||||
glsafe(::glScaled(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength));
|
glsafe(::glScaled(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength));
|
||||||
VBOCylinder.render();
|
m_cylinder.render();
|
||||||
glsafe(::glPopMatrix());
|
glsafe(::glPopMatrix());
|
||||||
|
|
||||||
if (vol->is_left_handed())
|
if (vol->is_left_handed())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue