Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2017-03-30 11:25:52 +0300
committerbubnikv <bubnikv@gmail.com>2017-03-30 11:25:52 +0300
commit36416d77b8f0db6692ffbafd56abf753e51d074f (patch)
treec0edd0d07357178e7565a69e13e3da4aca556495
parentb60ae4745f0c95dd6f8a5960b9827e3d1b4e0b42 (diff)
Fixes of VBO rendering on Linux with wxWidgets & GTKversion_1.34.0
-rw-r--r--lib/Slic3r/GUI/3DScene.pm12
-rw-r--r--xs/src/slic3r/GUI/3DScene.hpp6
-rw-r--r--xs/xsp/GUI_3DScene.xsp1
3 files changed, 18 insertions, 1 deletions
diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm
index b95e8777f..d4eb1eaea 100644
--- a/lib/Slic3r/GUI/3DScene.pm
+++ b/lib/Slic3r/GUI/3DScene.pm
@@ -906,13 +906,16 @@ sub UseVBOs {
my ($self) = @_;
if (! defined ($self->{use_VBOs})) {
+ # 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');
# Don't use VBOs if anything fails.
$self->{use_VBOs} = 0;
if ($self->GetContext) {
$self->SetCurrent($self->GetContext);
my @gl_version = split(/\./, glGetString(GL_VERSION));
$self->{use_VBOs} = int($gl_version[0]) >= 2;
- # print "InitGL $self OpenGL major: $gl_version[0], minor: $gl_version[1]. Use VBOs: ", $self->{use_VBOs}, "\n";
+ # print "UseVBOs $self OpenGL major: $gl_version[0], minor: $gl_version[1]. Use VBOs: ", $self->{use_VBOs}, "\n";
}
}
return $self->{use_VBOs};
@@ -968,6 +971,13 @@ sub InitGL {
return unless $self->GetContext;
$self->init(1);
+ # 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.
+ # In that case the volumes are wainting to be moved to Vertex Buffer Objects
+ # after the OpenGL context is being initialized.
+ $self->volumes->finalize_geometry(1)
+ if ($^O eq 'linux' && $self->UseVBOs);
+
glClearColor(0, 0, 0, 1);
glColor3f(1, 0, 0);
glEnable(GL_DEPTH_TEST);
diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp
index 1e5b968ba..ed992754d 100644
--- a/xs/src/slic3r/GUI/3DScene.hpp
+++ b/xs/src/slic3r/GUI/3DScene.hpp
@@ -264,6 +264,7 @@ public:
void set_range(coordf_t low, coordf_t high);
void render() const;
+ void finalize_geometry(bool use_VBOs) { this->indexed_vertex_array.finalize_geometry(use_VBOs); }
void release_geometry() { this->indexed_vertex_array.release_geometry(); }
/************************************************ Layer height texture ****************************************************/
@@ -312,6 +313,11 @@ public:
// Render the volumes by OpenGL.
void render_VBOs() const;
void render_legacy() const;
+
+ // Finalize the initialization of the geometry & indices,
+ // upload the geometry and indices to OpenGL VBO objects
+ // and shrink the allocated data, possibly relasing it if it has been loaded into the VBOs.
+ void finalize_geometry(bool use_VBOs) { for (auto *v : volumes) v->finalize_geometry(use_VBOs); }
// Release the geometry data assigned to the volumes.
// If OpenGL VBOs were allocated, an OpenGL context has to be active to release them.
void release_geometry() { for (auto *v : volumes) v->release_geometry(); }
diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp
index 06ae7ce13..06b042f3b 100644
--- a/xs/xsp/GUI_3DScene.xsp
+++ b/xs/xsp/GUI_3DScene.xsp
@@ -87,6 +87,7 @@
void render_VBOs() const;
void render_legacy() const;
+ void finalize_geometry(bool use_VBOs);
void release_geometry();
%{