mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-08 10:09:11 +08:00
Support multi sampled anti-aliasing with wxWidgets 3.0.3.
This commit is contained in:
parent
d8be976356
commit
ab9e3b718c
@ -56,10 +56,30 @@ use constant HOVER_COLOR => [0.4,0.9,0,1];
|
|||||||
sub new {
|
sub new {
|
||||||
my ($class, $parent) = @_;
|
my ($class, $parent) = @_;
|
||||||
|
|
||||||
|
# We can only enable multi sample anti aliasing wih wxWidgets 3.0.3 and with a hacked Wx::GLCanvas,
|
||||||
|
# which exports some new WX_GL_XXX constants, namely WX_GL_SAMPLE_BUFFERS and WX_GL_SAMPLES.
|
||||||
|
my $can_multisample =
|
||||||
|
Wx::wxVERSION >= 3.000003 &&
|
||||||
|
defined Wx::GLCanvas->can('WX_GL_SAMPLE_BUFFERS') &&
|
||||||
|
defined Wx::GLCanvas->can('WX_GL_SAMPLES');
|
||||||
|
my $attrib = [WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 24];
|
||||||
|
if ($can_multisample) {
|
||||||
|
# Request a window with multi sampled anti aliasing. This is a new feature in Wx 3.0.3 (backported from 3.1.0).
|
||||||
|
# Use eval to avoid compilation, if the subs WX_GL_SAMPLE_BUFFERS and WX_GL_SAMPLES are missing.
|
||||||
|
eval 'push(@$attrib, (WX_GL_SAMPLE_BUFFERS, 1, WX_GL_SAMPLES, 4));';
|
||||||
|
}
|
||||||
|
# wxWidgets expect the attrib list to be ended by zero.
|
||||||
|
push(@$attrib, 0);
|
||||||
|
|
||||||
# we request a depth buffer explicitely because it looks like it's not created by
|
# we request a depth buffer explicitely because it looks like it's not created by
|
||||||
# default on Linux, causing transparency issues
|
# default on Linux, causing transparency issues
|
||||||
my $self = $class->SUPER::new($parent, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, 0, "",
|
my $self = $class->SUPER::new($parent, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, 0, "", $attrib);
|
||||||
[WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0]);
|
if (Wx::wxVERSION >= 3.000003) {
|
||||||
|
# Wx 3.0.3 contains an ugly hack to support some advanced OpenGL attributes through the attribute list.
|
||||||
|
# The attribute list is transferred between the wxGLCanvas and wxGLContext constructors using a single static array s_wglContextAttribs.
|
||||||
|
# Immediatelly force creation of the OpenGL context to consume the static variable s_wglContextAttribs.
|
||||||
|
$self->GetContext();
|
||||||
|
}
|
||||||
|
|
||||||
$self->background(1);
|
$self->background(1);
|
||||||
$self->_quat((0, 0, 0, 1));
|
$self->_quat((0, 0, 0, 1));
|
||||||
|
@ -143,7 +143,13 @@ __PACKAGE__->mk_accessors(qw(
|
|||||||
sub new {
|
sub new {
|
||||||
my ($class, $parent, $print) = @_;
|
my ($class, $parent, $print) = @_;
|
||||||
|
|
||||||
my $self = $class->SUPER::new($parent);
|
my $self = (Wx::wxVERSION >= 3.000003) ?
|
||||||
|
# The wxWidgets 3.0.3-beta have a bug, they crash with NULL attribute list.
|
||||||
|
$class->SUPER::new($parent, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, 0, "",
|
||||||
|
[WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 24, 0]) :
|
||||||
|
$class->SUPER::new($parent);
|
||||||
|
# Immediatelly force creation of the OpenGL context to consume the static variable s_wglContextAttribs.
|
||||||
|
$self->GetContext();
|
||||||
$self->print($print);
|
$self->print($print);
|
||||||
$self->_zoom(1);
|
$self->_zoom(1);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user