Skip to content

Commit

Permalink
Fixing an update of the "Export G-code, Send to printer" and similar …
Browse files Browse the repository at this point in the history
…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.
#137
  • Loading branch information
bubnikv committed Feb 17, 2017
1 parent 31f213d commit 89702a5
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions lib/Slic3r/GUI/3DScene.pm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ __PACKAGE__->mk_accessors( qw(_quat _dirty init
_drag_start_xy
_dragged
layer_editing_enabled
_layer_height_edited
_camera_type
Expand Down Expand Up @@ -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}) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 89702a5

Please sign in to comment.