#4880 - Initialization of OpenGL data used by GCodeViewer done on the first call of GCodeViewer::render()

This commit is contained in:
enricoturri1966 2020-10-17 13:04:58 +02:00
parent c2f5cef8a4
commit ce3fc31b48
3 changed files with 19 additions and 10 deletions

View file

@ -434,10 +434,26 @@ void GCodeViewer::reset()
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
m_statistics.reset_opengl();
#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())
return;
@ -893,13 +909,8 @@ void GCodeViewer::init()
}
set_toolpath_move_type_visible(EMoveType::Extrude, true);
m_sequential_view.marker.init();
// 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;
}

View file

@ -410,7 +410,7 @@ private:
#if ENABLE_GCODE_VIEWER_STATISTICS
mutable Statistics m_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:
GCodeViewer() = default;

View file

@ -234,10 +234,8 @@ OpenGLManager::~OpenGLManager()
bool OpenGLManager::init_gl()
{
if (!m_gl_initialized)
{
if (glewInit() != GLEW_OK)
{
if (!m_gl_initialized) {
if (glewInit() != GLEW_OK) {
BOOST_LOG_TRIVIAL(error) << "Unable to init glew library";
return false;
}