Skip to content

Commit b6dc3cd

Browse files
committed
use inheritance for default_options
1 parent 61dc55b commit b6dc3cd

2 files changed

Lines changed: 30 additions & 17 deletions

File tree

lib/PDL/Graphics/TriD/GL.pm

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -805,12 +805,6 @@ Returns a new OpenGL object.
805805
806806
=item width,height - the width and height of the window in pixels (500,500)
807807
808-
=item parent - the parent under which the new window should be opened (root)
809-
810-
=item mask - the user interface mask (StructureNotifyMask)
811-
812-
=item attributes - attributes to pass to glXChooseVisual
813-
814808
=back
815809
816810
Allowed 3d window types, case insensitive, are:
@@ -823,13 +817,25 @@ Allowed 3d window types, case insensitive, are:
823817
824818
=item x11 - use Perl OpenGL (POGL) bindings with X11
825819
820+
Additional attributes for X11 windows:
821+
822+
=over
823+
824+
=item parent - the parent under which the new window should be opened (root)
825+
826+
=item mask - the user interface mask (StructureNotifyMask)
827+
828+
=item attributes - attributes to pass to glXChooseVisual
829+
830+
=back
831+
826832
=back
827833
828834
=cut
829835

830836
sub new {
831837
my($class,$options,$window_obj) = @_;
832-
my $opt = PDL::Options->new(default_options());
838+
my $opt = PDL::Options->new($class->default_options);
833839
$opt->incremental(1);
834840
$opt->options($options) if(defined $options);
835841
my $p = $opt->options;
@@ -842,16 +848,13 @@ default options for object oriented methods
842848
843849
=cut
844850

845-
sub default_options{
846-
{ 'x' => 0,
847-
'y' => 0,
848-
'width' => 500,
849-
'height'=> 500,
850-
'parent'=> 0,
851-
'mask' => eval '&OpenGL::StructureNotifyMask',
852-
'steal' => 0,
853-
'attributes' => eval '[ &OpenGL::GLX_DOUBLEBUFFER, &OpenGL::GLX_RGBA ]',
854-
}
851+
sub default_options {
852+
{
853+
x => 0,
854+
y => 0,
855+
width => 500,
856+
height => 500,
857+
}
855858
}
856859

857860
=head2 swap_buffers

lib/PDL/Graphics/TriD/GL/GLX.pm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ sub new {
3131
$self;
3232
}
3333

34+
sub default_options {
35+
my ($class) = @_;
36+
+{ %{ $class->SUPER::default_options },
37+
parent => 0,
38+
mask => StructureNotifyMask,
39+
steal => 0,
40+
attributes => [ GLX_DOUBLEBUFFER, GLX_RGBA ],
41+
};
42+
}
43+
3444
sub event_pending {
3545
my ($self) = @_;
3646
OpenGL::XPending($self->{Display});

0 commit comments

Comments
 (0)