From 89702a5b4e63b783193bfbfcf1bddeeaf404a7c4 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 17 Feb 2017 15:11:59 +0100 Subject: Fixing an update of the "Export G-code, Send to printer" and similar buttons. It is a bug, which was lingering around for a long time, only now the buggy function is called at a time point, where it really hurts. https://github.com/prusa3d/Slic3r/issues/137 --- lib/Slic3r/GUI/3DScene.pm | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 740fbcc10..e7a3791b8 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -61,7 +61,6 @@ __PACKAGE__->mk_accessors( qw(_quat _dirty init _drag_start_xy _dragged - layer_editing_enabled _layer_height_edited _camera_type @@ -190,6 +189,28 @@ sub Destroy { return $self->SUPER::Destroy; } +sub layer_editing_enabled { + my ($self, $value) = @_; + if (@_ == 2) { + $self->{layer_editing_enabled} = $value; + if ($value && ! $self->{layer_editing_initialized}) { + # Enabling the layer editing for the first time. This triggers compilation of the necessary OpenGL shaders. + # If compilation fails, the compile log is printed into the console. + $self->{layer_editing_initialized} = 1; + my $shader = $self->{shader} = new Slic3r::GUI::GLShader; + my $info = $shader->Load($self->_fragment_shader, $self->_vertex_shader); + print $info if $info; + ($self->{layer_preview_z_texture_id}) = glGenTextures_p(1); + glBindTexture(GL_TEXTURE_2D, $self->{layer_preview_z_texture_id}); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1); + glBindTexture(GL_TEXTURE_2D, 0); + } + } + return $self->{layer_editing_enabled}; +} + sub _first_selected_object_id { my ($self) = @_; for my $i (0..$#{$self->volumes}) { @@ -893,16 +914,6 @@ sub InitGL { return unless $self->GetContext; $self->init(1); - my $shader = $self->{shader} = new Slic3r::GUI::GLShader; - my $info = $shader->Load($self->_fragment_shader, $self->_vertex_shader); -# print $info if $info; - ($self->{layer_preview_z_texture_id}) = glGenTextures_p(1); - glBindTexture(GL_TEXTURE_2D, $self->{layer_preview_z_texture_id}); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1); - glBindTexture(GL_TEXTURE_2D, 0); - glClearColor(0, 0, 0, 1); glColor3f(1, 0, 0); glEnable(GL_DEPTH_TEST); -- cgit v1.2.3