Skip to content

Commit

Permalink
Workaround for buggy Intel HD Graphics OpenGL drivers:
Browse files Browse the repository at this point in the history
Fall back to OpenGL 1.1 by a "use_legacy_opengl" preferences switch.
#233
#268
#619
  • Loading branch information
bubnikv committed Dec 11, 2017
1 parent 61e6f23 commit 743fc9d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
12 changes: 11 additions & 1 deletion lib/Slic3r/GUI/3DScene.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package Slic3r::GUI::3DScene::Base;
use strict;
use warnings;

use Wx qw(:timer :bitmap :icon :dialog);
use Wx qw(wxTheApp :timer :bitmap :icon :dialog);
use Wx::Event qw(EVT_PAINT EVT_SIZE EVT_ERASE_BACKGROUND EVT_IDLE EVT_MOUSEWHEEL EVT_MOUSE_EVENTS EVT_CHAR EVT_TIMER);
# must load OpenGL *before* Wx::GLCanvas
use OpenGL qw(:glconstants :glfunctions :glufunctions :gluconstants);
Expand Down Expand Up @@ -956,6 +956,16 @@ sub UseVBOs {
my ($self) = @_;

if (! defined ($self->{use_VBOs})) {
my $use_legacy = wxTheApp->{app_config}->get('use_legacy_opengl');
if ($use_legacy eq '1') {
# Disable OpenGL 2.0 rendering.
$self->{use_VBOs} = 0;
# Don't enable the layer editing tool.
$self->{layer_editing_enabled} = 0;
# 2 means failed
$self->{layer_editing_initialized} = 2;
return 0;
}
# This is a special path for wxWidgets on GTK, where an OpenGL context is initialized
# first when an OpenGL widget is shown for the first time. How ugly.
return 0 if (! $self->init && $^O eq 'linux');
Expand Down
10 changes: 9 additions & 1 deletion lib/Slic3r/GUI/Preferences.pm
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ sub new {
'if they are marked as incompatible with the active printer',
default => $app_config->get("show_incompatible_presets"),
));
$optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
opt_id => 'use_legacy_opengl',
type => 'bool',
label => 'Use legacy OpenGL 1.1 rendering',
tooltip => 'If you have rendering issues caused by a buggy OpenGL 2.0 driver, you may try to check this checkbox. This will disable the layer height editing, so it is likely better to upgrade your graphics driver.',
default => $app_config->get("use_legacy_opengl"),
));

my $sizer = Wx::BoxSizer->new(wxVERTICAL);
$sizer->Add($optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
Expand All @@ -90,7 +97,8 @@ sub _accept {
my ($self) = @_;

if (defined($self->{values}{no_controller}) ||
defined($self->{values}{no_defaults})) {
defined($self->{values}{no_defaults}) ||
defined($self->{values}{use_legacy_opengl})) {
Slic3r::GUI::warning_catcher($self)->("You need to restart Slic3r to make the changes effective.");
}

Expand Down
4 changes: 4 additions & 0 deletions xs/src/slic3r/GUI/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ void AppConfig::set_defaults()
// Version check is enabled by default in the config, but it is not implemented yet.
if (get("version_check").empty())
set("version_check", "1");
// Use OpenGL 1.1 even if OpenGL 2.0 is available. This is mainly to support some buggy Intel HD Graphics drivers.
// https://github.com/prusa3d/Slic3r/issues/233
if (get("use_legacy_opengl").empty())
set("use_legacy_opengl", "0");
}

void AppConfig::load()
Expand Down

0 comments on commit 743fc9d

Please sign in to comment.