From 743fc9dbd0fede7dc89f784a4f6fcae46ef856d1 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 11 Dec 2017 18:00:51 +0100 Subject: [PATCH] Workaround for buggy Intel HD Graphics OpenGL drivers: Fall back to OpenGL 1.1 by a "use_legacy_opengl" preferences switch. https://github.com/prusa3d/Slic3r/issues/233 https://github.com/prusa3d/Slic3r/issues/268 https://github.com/prusa3d/Slic3r/issues/619 --- lib/Slic3r/GUI/3DScene.pm | 12 +++++++++++- lib/Slic3r/GUI/Preferences.pm | 10 +++++++++- xs/src/slic3r/GUI/AppConfig.cpp | 4 ++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 51c822590eb..7fae4894a9a 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -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); @@ -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'); diff --git a/lib/Slic3r/GUI/Preferences.pm b/lib/Slic3r/GUI/Preferences.pm index d20ccb53fd8..0f0f319fe9c 100644 --- a/lib/Slic3r/GUI/Preferences.pm +++ b/lib/Slic3r/GUI/Preferences.pm @@ -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); @@ -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."); } diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp index 3161c5b788e..9378a209427 100644 --- a/xs/src/slic3r/GUI/AppConfig.cpp +++ b/xs/src/slic3r/GUI/AppConfig.cpp @@ -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()