Skip to content

Commit a564ad3

Browse files
committed
::GLUT no need package-qualify OpenGL::GLUT stuff since import
1 parent 4f61a53 commit a564ad3

1 file changed

Lines changed: 35 additions & 35 deletions

File tree

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

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,32 @@ sub new {
2222
sub _init_glut_window {
2323
my ($self, $window_obj) = @_;
2424
my $p = $self->{Options};
25-
OpenGL::GLUT::glutInitWindowPosition( $p->{x}, $p->{y} );
26-
OpenGL::GLUT::glutInitWindowSize( $p->{width}, $p->{height} );
27-
OpenGL::GLUT::glutInitDisplayMode( OpenGL::GLUT::GLUT_RGBA() | OpenGL::GLUT::GLUT_DOUBLE() | OpenGL::GLUT::GLUT_DEPTH() ); # hardwire for now
25+
glutInitWindowPosition( $p->{x}, $p->{y} );
26+
glutInitWindowSize( $p->{width}, $p->{height} );
27+
glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH ); # hardwire for now
2828
if ($^O ne 'MSWin32' and not $OpenGL::Config->{DEFINE} =~ /-DHAVE_W32API/) { # skip these MODE checks on win32, they don't work
29-
if (not OpenGL::GLUT::glutGet(OpenGL::GLUT::GLUT_DISPLAY_MODE_POSSIBLE()))
29+
if (not glutGet(GLUT_DISPLAY_MODE_POSSIBLE))
3030
{
3131
warn "glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA) not possible";
3232
warn "...trying without GLUT_ALPHA";
3333
# try without GLUT_ALPHA
34-
OpenGL::GLUT::glutInitDisplayMode( OpenGL::GLUT::GLUT_RGBA() | OpenGL::GLUT::GLUT_DOUBLE() | OpenGL::GLUT::GLUT_DEPTH() );
35-
if ( not OpenGL::GLUT::glutGet( OpenGL::GLUT::GLUT_DISPLAY_MODE_POSSIBLE() ) )
34+
glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
35+
if ( not glutGet( GLUT_DISPLAY_MODE_POSSIBLE ) )
3636
{
3737
die "display mode not possible";
3838
}
3939
}
4040
}
41-
$self->{glutwindow} = OpenGL::GLUT::glutCreateWindow( "GLUT TriD" );
42-
OpenGL::GLUT::glutSetWindowTitle("GLUT TriD #$self->{glutwindow}");
43-
OpenGL::GLUT::glutReshapeFunc( \&_pdl_fake_ConfigureNotify );
44-
OpenGL::GLUT::glutCloseFunc( \&_pdl_fake_exit_handler );
45-
OpenGL::GLUT::glutKeyboardFunc( \&_pdl_fake_KeyPress );
46-
OpenGL::GLUT::glutMouseFunc( \&_pdl_fake_button_event );
47-
OpenGL::GLUT::glutMotionFunc( \&_pdl_fake_MotionNotify );
48-
OpenGL::GLUT::glutDisplayFunc( \&_pdl_display_wrapper );
49-
OpenGL::GLUT::glutSetOption(OpenGL::GLUT::GLUT_ACTION_ON_WINDOW_CLOSE(), OpenGL::GLUT::GLUT_ACTION_GLUTMAINLOOP_RETURNS()) if OpenGL::GLUT::_have_freeglut();
50-
OpenGL::GLUT::glutMainLoopEvent(); # pump event loop so window appears
41+
$self->{glutwindow} = glutCreateWindow( "GLUT TriD" );
42+
glutSetWindowTitle("GLUT TriD #$self->{glutwindow}");
43+
glutReshapeFunc( \&_pdl_fake_ConfigureNotify );
44+
glutCloseFunc( \&_pdl_fake_exit_handler );
45+
glutKeyboardFunc( \&_pdl_fake_KeyPress );
46+
glutMouseFunc( \&_pdl_fake_button_event );
47+
glutMotionFunc( \&_pdl_fake_MotionNotify );
48+
glutDisplayFunc( \&_pdl_display_wrapper );
49+
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS) if _have_freeglut();
50+
glutMainLoopEvent(); # pump event loop so window appears
5151
if ($PDL::Graphics::TriD::verbose) {
5252
print "gdriver: Got TriD::GL object(GLUT window ID# " . $self->{glutwindow} . ")\n";
5353
}
@@ -56,28 +56,28 @@ sub _init_glut_window {
5656

5757
sub DESTROY {
5858
my ($self) = @_;
59-
return if !OpenGL::GLUT::done_glutInit();
60-
print __PACKAGE__."::DESTROY called (win=$self->{glutwindow}), GLUT says ", OpenGL::GLUT::glutGetWindow(), "\n" if $PDL::Graphics::TriD::verbose;
61-
OpenGL::GLUT::glutMainLoopEvent(); # pump to deal with any clicking "X"
62-
if (!OpenGL::GLUT::glutGetWindow()) {
59+
return if !done_glutInit();
60+
print __PACKAGE__."::DESTROY called (win=$self->{glutwindow}), GLUT says ", glutGetWindow(), "\n" if $PDL::Graphics::TriD::verbose;
61+
glutMainLoopEvent(); # pump to deal with any clicking "X"
62+
if (!glutGetWindow()) {
6363
# "X" was clicked, clear queue then stop
6464
@{ $self->{xevents} } = ();
65-
OpenGL::GLUT::glutMainLoopEvent(); # pump once
65+
glutMainLoopEvent(); # pump once
6666
return;
6767
}
68-
OpenGL::GLUT::glutSetWindow($self->{glutwindow});
69-
OpenGL::GLUT::glutReshapeFunc();
70-
OpenGL::GLUT::glutCloseFunc();
71-
OpenGL::GLUT::glutKeyboardFunc();
72-
OpenGL::GLUT::glutMouseFunc();
73-
OpenGL::GLUT::glutMotionFunc();
74-
OpenGL::GLUT::glutDestroyWindow($self->{glutwindow});
75-
OpenGL::GLUT::glutMainLoopEvent() for 1..2; # pump so window gets actually closed
68+
glutSetWindow($self->{glutwindow});
69+
glutReshapeFunc();
70+
glutCloseFunc();
71+
glutKeyboardFunc();
72+
glutMouseFunc();
73+
glutMotionFunc();
74+
glutDestroyWindow($self->{glutwindow});
75+
glutMainLoopEvent() for 1..2; # pump so window gets actually closed
7676
delete $self->{glutwindow};
7777
}
7878

7979
sub _pdl_display_wrapper {
80-
my ($win) = OpenGL::GLUT::glutGetWindow();
80+
my ($win) = glutGetWindow();
8181
if ( defined($win) and defined($winObjects[$win]) ) {
8282
$winObjects[$win]->display();
8383
}
@@ -91,7 +91,7 @@ sub _pdl_fake_exit_handler {
9191

9292
sub _pdl_fake_ConfigureNotify {
9393
print "_pdl_fake_ConfigureNotify: got (@_)\n" if $PDL::Graphics::TriD::verbose;
94-
OpenGL::GLUT::glutPostRedisplay();
94+
glutPostRedisplay();
9595
push @fakeXEvents, [ 'reshape', @_ ];
9696
}
9797

@@ -138,7 +138,7 @@ sub _pdl_fake_KeyPress {
138138
sub event_pending {
139139
my($self) = @_;
140140
# monitor state of @fakeXEvents, return number on queue
141-
OpenGL::GLUT::glutMainLoopEvent() if !@{$self->{xevents}};
141+
glutMainLoopEvent() if !@{$self->{xevents}};
142142
print STDERR "OO::event_pending: have " . scalar( @{$self->{xevents}} ) . " xevents\n" if $PDL::Graphics::TriD::verbose > 1;
143143
scalar( @{$self->{xevents}} );
144144
}
@@ -147,21 +147,21 @@ sub next_event {
147147
my($self) = @_;
148148
while ( !scalar( @{$self->{xevents}} ) ) {
149149
# If no events, we keep pumping the event loop
150-
OpenGL::GLUT::glutMainLoopEvent();
150+
glutMainLoopEvent();
151151
}
152152
# Extract first event from fake event queue and return
153153
@{ shift @{$self->{xevents}} };
154154
}
155155

156156
sub swap_buffers {
157157
my ($this) = @_;
158-
OpenGL::GLUT::glutSwapBuffers();
158+
glutSwapBuffers();
159159
}
160160

161161
sub set_window {
162162
my ($this) = @_;
163163
# set GLUT context to current window (for multiwindow support)
164-
OpenGL::GLUT::glutSetWindow($this->{glutwindow});
164+
glutSetWindow($this->{glutwindow});
165165
}
166166

167167
1;

0 commit comments

Comments
 (0)