Fixes of VBO rendering on Linux with wxWidgets & GTK
This commit is contained in:
parent
b60ae4745f
commit
36416d77b8
3 changed files with 18 additions and 1 deletions
|
@ -906,13 +906,16 @@ sub UseVBOs {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
if (! defined ($self->{use_VBOs})) {
|
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.
|
# Don't use VBOs if anything fails.
|
||||||
$self->{use_VBOs} = 0;
|
$self->{use_VBOs} = 0;
|
||||||
if ($self->GetContext) {
|
if ($self->GetContext) {
|
||||||
$self->SetCurrent($self->GetContext);
|
$self->SetCurrent($self->GetContext);
|
||||||
my @gl_version = split(/\./, glGetString(GL_VERSION));
|
my @gl_version = split(/\./, glGetString(GL_VERSION));
|
||||||
$self->{use_VBOs} = int($gl_version[0]) >= 2;
|
$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};
|
return $self->{use_VBOs};
|
||||||
|
@ -968,6 +971,13 @@ sub InitGL {
|
||||||
return unless $self->GetContext;
|
return unless $self->GetContext;
|
||||||
$self->init(1);
|
$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);
|
glClearColor(0, 0, 0, 1);
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
|
@ -264,6 +264,7 @@ public:
|
||||||
|
|
||||||
void set_range(coordf_t low, coordf_t high);
|
void set_range(coordf_t low, coordf_t high);
|
||||||
void render() const;
|
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(); }
|
void release_geometry() { this->indexed_vertex_array.release_geometry(); }
|
||||||
|
|
||||||
/************************************************ Layer height texture ****************************************************/
|
/************************************************ Layer height texture ****************************************************/
|
||||||
|
@ -312,6 +313,11 @@ public:
|
||||||
// Render the volumes by OpenGL.
|
// Render the volumes by OpenGL.
|
||||||
void render_VBOs() const;
|
void render_VBOs() const;
|
||||||
void render_legacy() 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.
|
// Release the geometry data assigned to the volumes.
|
||||||
// If OpenGL VBOs were allocated, an OpenGL context has to be active to release them.
|
// 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(); }
|
void release_geometry() { for (auto *v : volumes) v->release_geometry(); }
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
|
|
||||||
void render_VBOs() const;
|
void render_VBOs() const;
|
||||||
void render_legacy() const;
|
void render_legacy() const;
|
||||||
|
void finalize_geometry(bool use_VBOs);
|
||||||
void release_geometry();
|
void release_geometry();
|
||||||
%{
|
%{
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue