Added missing GL context "Set Current" calls before loading data

into vertex buffers.

Changed behavior of Canvas3D::on_render() to postpone rendering to idle,
as on OSX the paint events happen directly from control updates,
if the control update triggers Canvas3D window rescaling. With this change,
rendering only happens from idle handler consistently.
This commit is contained in:
bubnikv 2019-01-30 19:02:30 +01:00
parent eec289961a
commit ed9a924880

View File

@ -4627,6 +4627,8 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
if ((m_canvas == nullptr) || (m_config == nullptr) || (m_model == nullptr))
return;
_set_current();
struct ModelVolumeState {
ModelVolumeState(const GLVolume *volume) :
model_volume(nullptr), geometry_id(volume->geometry_id), volume_idx(-1) {}
@ -4933,6 +4935,8 @@ void GLCanvas3D::load_gcode_preview(const GCodePreviewData& preview_data, const
const Print *print = this->fff_print();
if ((m_canvas != nullptr) && (print != nullptr))
{
_set_current();
std::vector<float> tool_colors = _parse_colors(str_tool_colors);
if (m_volumes.empty())
@ -4970,6 +4974,7 @@ void GLCanvas3D::load_sla_preview()
const SLAPrint* print = this->sla_print();
if ((m_canvas != nullptr) && (print != nullptr))
{
_set_current();
_load_shells_sla();
}
}
@ -4980,6 +4985,8 @@ void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors, c
if (print == nullptr)
return;
_set_current();
_load_print_toolpaths();
_load_wipe_tower_toolpaths(str_tool_colors);
for (const PrintObject* object : print->objects())
@ -5650,7 +5657,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
void GLCanvas3D::on_paint(wxPaintEvent& evt)
{
render();
m_dirty = true;
}
void GLCanvas3D::on_key_down(wxKeyEvent& evt)