mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
#4880 - Initialization of OpenGL data used by GCodeViewer done on the first call of GCodeViewer::render()
This commit is contained in:
parent
c2f5cef8a4
commit
ce3fc31b48
3 changed files with 19 additions and 10 deletions
|
@ -434,10 +434,26 @@ void GCodeViewer::reset()
|
||||||
|
|
||||||
void GCodeViewer::render() const
|
void GCodeViewer::render() const
|
||||||
{
|
{
|
||||||
|
auto init_gl_data = [this]() {
|
||||||
|
static bool first_run = true;
|
||||||
|
if (first_run) {
|
||||||
|
m_sequential_view.marker.init();
|
||||||
|
|
||||||
|
std::array<int, 2> point_sizes;
|
||||||
|
::glGetIntegerv(GL_ALIASED_POINT_SIZE_RANGE, point_sizes.data());
|
||||||
|
m_detected_point_sizes = { static_cast<float>(point_sizes[0]), static_cast<float>(point_sizes[1]) };
|
||||||
|
first_run = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
m_statistics.reset_opengl();
|
m_statistics.reset_opengl();
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
|
||||||
|
// OpenGL data must be initialized after the glContext has been created.
|
||||||
|
// This is ensured when this method is called by GLCanvas3D::_render_gcode().
|
||||||
|
init_gl_data();
|
||||||
|
|
||||||
if (m_roles.empty())
|
if (m_roles.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -893,13 +909,8 @@ void GCodeViewer::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
set_toolpath_move_type_visible(EMoveType::Extrude, true);
|
set_toolpath_move_type_visible(EMoveType::Extrude, true);
|
||||||
m_sequential_view.marker.init();
|
|
||||||
// m_sequential_view.skip_invisible_moves = true;
|
// m_sequential_view.skip_invisible_moves = true;
|
||||||
|
|
||||||
std::array<int, 2> point_sizes;
|
|
||||||
::glGetIntegerv(GL_ALIASED_POINT_SIZE_RANGE, point_sizes.data());
|
|
||||||
m_detected_point_sizes = { static_cast<float>(point_sizes[0]), static_cast<float>(point_sizes[1]) };
|
|
||||||
|
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -410,7 +410,7 @@ private:
|
||||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
mutable Statistics m_statistics;
|
mutable Statistics m_statistics;
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
std::array<float, 2> m_detected_point_sizes = { 0.0f, 0.0f };
|
mutable std::array<float, 2> m_detected_point_sizes = { 0.0f, 0.0f };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GCodeViewer() = default;
|
GCodeViewer() = default;
|
||||||
|
|
|
@ -234,10 +234,8 @@ OpenGLManager::~OpenGLManager()
|
||||||
|
|
||||||
bool OpenGLManager::init_gl()
|
bool OpenGLManager::init_gl()
|
||||||
{
|
{
|
||||||
if (!m_gl_initialized)
|
if (!m_gl_initialized) {
|
||||||
{
|
if (glewInit() != GLEW_OK) {
|
||||||
if (glewInit() != GLEW_OK)
|
|
||||||
{
|
|
||||||
BOOST_LOG_TRIVIAL(error) << "Unable to init glew library";
|
BOOST_LOG_TRIVIAL(error) << "Unable to init glew library";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue