Skip to content

Commit

Permalink
Cleaned up all of SDL::App to SDLx::App
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Thakore committed Jun 22, 2010
1 parent 6e1f923 commit c3d720d
Show file tree
Hide file tree
Showing 42 changed files with 112 additions and 112 deletions.
4 changes: 2 additions & 2 deletions examples/adventure/adventure.pl
Expand Up @@ -129,7 +129,7 @@ package main;
use warnings; use warnings;


use SDL; use SDL;
use SDL::App; use SDLx::App;
use SDL::Surface; use SDL::Surface;
use SDL::Color; use SDL::Color;


Expand All @@ -139,7 +139,7 @@ package main;
my ($bg_r, $bg_g, $bg_b) = ( 0x77, 0xee, 0x77 ); my ($bg_r, $bg_g, $bg_b) = ( 0x77, 0xee, 0x77 );
my $sleep_msec = 0.05; my $sleep_msec = 0.05;


my $app = SDL::App->new( my $app = SDLx::App->new(
-width => $width, -width => $width,
-height => $height, -height => $height,
-depth => $depth, -depth => $depth,
Expand Down
4 changes: 2 additions & 2 deletions examples/openglapp.pl
Expand Up @@ -4,7 +4,7 @@
use strict; use strict;
use warnings; use warnings;
use SDL; use SDL;
use SDL::App; use SDLx::App;
use SDL::Mouse; use SDL::Mouse;
use SDL::Video; use SDL::Video;
use SDL::Events; use SDL::Events;
Expand All @@ -16,7 +16,7 @@
$| = 1; $| = 1;
$WIDTH = 1024; $WIDTH = 1024;
$HEIGHT = 768; $HEIGHT = 768;
$SDLAPP = SDL::App->new(-title => "Opengl App", -width => $WIDTH, -height => $HEIGHT, -gl => 1); $SDLAPP = SDLx::App->new(-title => "Opengl App", -width => $WIDTH, -height => $HEIGHT, -gl => 1);
$SDLEVENT = SDL::Event->new; $SDLEVENT = SDL::Event->new;


SDL::Mouse::show_cursor(0); SDL::Mouse::show_cursor(0);
Expand Down
4 changes: 2 additions & 2 deletions lib/SDL/Tutorial.pm
Expand Up @@ -34,13 +34,13 @@ use strict;
use warnings; use warnings;


use SDL; use SDL;
use SDL::App; use SDLx::App;


# change these values as necessary # change these values as necessary
my $title = 'My SDL App'; my $title = 'My SDL App';
my ($width, $height, $depth) = ( 640, 480, 16 ); my ($width, $height, $depth) = ( 640, 480, 16 );


my $app = SDL::App->new( my $app = SDLx::App->new(
-width => $width, -width => $width,
-height => $height, -height => $height,
-depth => $depth, -depth => $depth,
Expand Down
6 changes: 3 additions & 3 deletions lib/SDL/Tutorial/Animation.pm
Expand Up @@ -34,7 +34,7 @@ use strict;
use warnings; use warnings;


use SDL; use SDL;
use SDL::App; use SDLx::App;
use SDL::Rect; use SDL::Rect;
use SDL::Color; use SDL::Color;
use SDL::Video; use SDL::Video;
Expand All @@ -46,7 +46,7 @@ my ($bg_r, $bg_g, $bg_b) = ( 0x00, 0x00, 0x00 );
my ($rect_r, $rect_g, $rect_b) = ( 0x00, 0x00, 0xff ); my ($rect_r, $rect_g, $rect_b) = ( 0x00, 0x00, 0xff );
my ($rect_width, $rect_height, $rect_y) = ( 100, 100, 190 ); my ($rect_width, $rect_height, $rect_y) = ( 100, 100, 190 );


my $app = SDL::App->new( my $app = SDLx::App->new(
-width => $width, -width => $width,
-height => $height, -height => $height,
-depth => $depth, -depth => $depth,
Expand Down Expand Up @@ -166,7 +166,7 @@ frame and saving and restoring the background for every object drawn.
Since you have to draw the screen in the right order once to start with it's Since you have to draw the screen in the right order once to start with it's
pretty easy to make this into a loop and redraw things in the right order for pretty easy to make this into a loop and redraw things in the right order for
every frame. Given a L<SDL::App> object C<$app>, a L<SDL::Rect> C<$rect>, and every frame. Given a L<SDLx::App> object C<$app>, a L<SDL::Rect> C<$rect>, and
a L<SDL::Color> C<$color>, you only have to create a new SDL::Rect C<$bg>, a L<SDL::Color> C<$color>, you only have to create a new SDL::Rect C<$bg>,
representing the whole of the background surface and a new SDL::Color representing the whole of the background surface and a new SDL::Color
C<$bg_color>, representing the background color. You can write a C<$bg_color>, representing the background color. You can write a
Expand Down
4 changes: 2 additions & 2 deletions lib/SDL/Tutorial/LunarLander.pm
Expand Up @@ -908,15 +908,15 @@ D8 BC C3 52 B7 FA 3F F9 91 00 CA 7A 4B E9 FF D9
#!/usr/bin/perl #!/usr/bin/perl
use SDL; #needed to get all constants use SDL; #needed to get all constants
use SDL::Video; use SDL::Video;
use SDL::App; use SDLx::App;
use SDL::Surface; use SDL::Surface;
use SDL::Rect; use SDL::Rect;
use SDL::Image; use SDL::Image;
use strict; use strict;
use warnings; use warnings;
my $app = SDL::App->new( my $app = SDLx::App->new(
-title => "Lunar Lander", -title => "Lunar Lander",
-width => 800, -width => 800,
-height => 600, -height => 600,
Expand Down
10 changes: 5 additions & 5 deletions lib/SDLx/App.pm
Expand Up @@ -61,7 +61,7 @@ sub new {
$f |= SDL::Video::SDL_ASYNCBLIT if ($async); $f |= SDL::Video::SDL_ASYNCBLIT if ($async);


if ($f & SDL::Video::SDL_OPENGL) { if ($f & SDL::Video::SDL_OPENGL) {
$SDL::App::USING_OPENGL = 1; $SDLx::App::USING_OPENGL = 1;
SDL::Video::GL_set_attribute(SDL::Constants::SDL_GL_RED_SIZE(),$r) if ($r); SDL::Video::GL_set_attribute(SDL::Constants::SDL_GL_RED_SIZE(),$r) if ($r);
SDL::Video::GL_set_attribute(SDL::Constants::SDL_GL_GREEN_SIZE(),$g) if ($g); SDL::Video::GL_set_attribute(SDL::Constants::SDL_GL_GREEN_SIZE(),$g) if ($g);
SDL::Video::GL_set_attribute(SDL::Constants::SDL_GL_BLUE_SIZE(),$b) if ($b); SDL::Video::GL_set_attribute(SDL::Constants::SDL_GL_BLUE_SIZE(),$b) if ($b);
Expand All @@ -76,7 +76,7 @@ sub new {
SDL::Video::GL_set_attribute(SDL::Constants::SDL_GL_BUFFER_SIZE(),$bs) if ($bs); SDL::Video::GL_set_attribute(SDL::Constants::SDL_GL_BUFFER_SIZE(),$bs) if ($bs);
SDL::Video::GL_set_attribute(SDL::Constants::SDL_GL_DEPTH_SIZE(),$d); SDL::Video::GL_set_attribute(SDL::Constants::SDL_GL_DEPTH_SIZE(),$d);
} else { } else {
$SDL::App::USING_OPENGL = 0; $SDLx::App::USING_OPENGL = 0;
} }


my $self = SDL::Video::set_video_mode($w,$h,$d,$f) my $self = SDL::Video::set_video_mode($w,$h,$d,$f)
Expand Down Expand Up @@ -161,7 +161,7 @@ sub loop ($$) {


sub sync ($) { sub sync ($) {
my $self = shift; my $self = shift;
if ($SDL::App::USING_OPENGL) { if ($SDLx::App::USING_OPENGL) {
SDL::Video::GL_swap_buffers() SDL::Video::GL_swap_buffers()
} else { } else {
SDL::Video::flip($self); SDL::Video::flip($self);
Expand All @@ -170,12 +170,12 @@ sub sync ($) {


sub attribute ($$;$) { sub attribute ($$;$) {
my ($self,$mode,$value) = @_; my ($self,$mode,$value) = @_;
return undef unless ($SDL::App::USING_OPENGL); return undef unless ($SDLx::App::USING_OPENGL);
if (defined $value) { if (defined $value) {
SDL::Video::GL_set_attribute($mode,$value); SDL::Video::GL_set_attribute($mode,$value);
} }
my $returns = SDL::Video::GL_get_attribute($mode); my $returns = SDL::Video::GL_get_attribute($mode);
croak "SDL::App::attribute failed to get GL attribute" if ($$returns[0] < 0); croak "SDLx::App::attribute failed to get GL attribute" if ($$returns[0] < 0);
$$returns[1]; $$returns[1];
} }


Expand Down
File renamed without changes.
40 changes: 20 additions & 20 deletions lib/pods/SDL/App.pod
Expand Up @@ -2,7 +2,7 @@


=head1 NAME =head1 NAME


SDL::App - a SDL perl extension SDLx::App - a SDL perl extension


=head1 CATEGORY =head1 CATEGORY


Expand All @@ -11,11 +11,11 @@ Extension
=head1 SYNOPSIS =head1 SYNOPSIS


use SDL; use SDL;
use SDL::App; use SDLx::App;
use SDL::Event; use SDL::Event;
use SDL::Events; use SDL::Events;


my $app = SDL::App->new( my $app = SDLx::App->new(
-title => 'Application Title', -title => 'Application Title',
-width => 640, -width => 640,
-height => 480, -height => 480,
Expand All @@ -34,21 +34,21 @@ This is the manual way of doing things
exit if $type == SDL_QUIT; exit if $type == SDL_QUIT;
} }


An alternative to the manual Event processing is the L<SDL::App::loop> . An alternative to the manual Event processing is the L<SDLx::App::loop> .


=head1 DESCRIPTION =head1 DESCRIPTION


L<SDL::App> controls the root window of the of your SDL based application. L<SDLx::App> controls the root window of the of your SDL based application.
It extends the L<SDL::Surface> class, and provides an interface to the window It extends the L<SDL::Surface> class, and provides an interface to the window
manager oriented functions. manager oriented functions.


=head1 METHODS =head1 METHODS


=head2 new =head2 new


C<SDL::App::new> initializes the SDL, creates a new screen, C<SDLx::App::new> initializes the SDL, creates a new screen,
and initializes some of the window manager properties. and initializes some of the window manager properties.
C<SDL::App::new> takes a series of named parameters: C<SDLx::App::new> takes a series of named parameters:


=over 4 =over 4


Expand Down Expand Up @@ -88,41 +88,41 @@ C<SDL::App::new> takes a series of named parameters:


=head2 title =head2 title


C<SDL::App::title> takes 0, 1, or 2 arguments. It returns the current C<SDLx::App::title> takes 0, 1, or 2 arguments. It returns the current
application window title. If one parameter is passed, both the window application window title. If one parameter is passed, both the window
title and icon title will be set to its value. If two parameters are title and icon title will be set to its value. If two parameters are
passed the window title will be set to the first, and the icon title passed the window title will be set to the first, and the icon title
to the second. to the second.


=head2 delay =head2 delay


C<SDL::App::delay> takes 1 argument, and will sleep the application for C<SDLx::App::delay> takes 1 argument, and will sleep the application for
that many ms. that many ms.


=head2 ticks =head2 ticks


C<SDL::App::ticks> returns the number of ms since the application began. C<SDLx::App::ticks> returns the number of ms since the application began.


=head2 error =head2 error


C<SDL::App::error> returns the last error message set by the SDL. C<SDLx::App::error> returns the last error message set by the SDL.


=head2 resize =head2 resize


C<SDL::App::resize> takes a new height and width of the application C<SDLx::App::resize> takes a new height and width of the application
if the application was originally created with the -resizable option. if the application was originally created with the -resizable option.


=head2 fullscreen =head2 fullscreen


C<SDL::App::fullscreen> toggles the application in and out of fullscreen mode. C<SDLx::App::fullscreen> toggles the application in and out of fullscreen mode.


=head2 iconify =head2 iconify


C<SDL::App::iconify> iconifies the applicaiton window. C<SDLx::App::iconify> iconifies the applicaiton window.


=head2 grab_input =head2 grab_input


C<SDL::App::grab_input> can be used to change the input focus behavior of C<SDLx::App::grab_input> can be used to change the input focus behavior of
the application. It takes one argument, which should be one of the following: the application. It takes one argument, which should be one of the following:


=over 4 =over 4
Expand All @@ -140,14 +140,14 @@ SDL_GRAB_OFF


=head2 loop =head2 loop


C<SDL::App::loop> is a simple event loop method which takes a reference to a hash C<SDLx::App::loop> is a simple event loop method which takes a reference to a hash
of event handler subroutines. The keys of the hash must be SDL event types such of event handler subroutines. The keys of the hash must be SDL event types such
as SDL_QUIT(), SDL_KEYDOWN(), and the like. The event method recieves as its parameter as SDL_QUIT(), SDL_KEYDOWN(), and the like. The event method recieves as its parameter
the event object used in the loop. the event object used in the loop.


Example: Example:


my $app = SDL::App->new( my $app = SDLx::App->new(
-title => "test.app", -title => "test.app",
-width => 800, -width => 800,
-height => 600, -height => 600,
Expand All @@ -163,13 +163,13 @@ Example:


=head2 sync =head2 sync


C<SDL::App::sync> encapsulates the various methods of syncronizing the screen with the C<SDLx::App::sync> encapsulates the various methods of syncronizing the screen with the
current video buffer. C<SDL::App::sync> will do a fullscreen update, using the double buffer current video buffer. C<SDLx::App::sync> will do a fullscreen update, using the double buffer
or OpenGL buffer if applicable. This is prefered to calling flip on the application window. or OpenGL buffer if applicable. This is prefered to calling flip on the application window.


=head2 attribute ( attr, [value] ) =head2 attribute ( attr, [value] )


C<SDL::App::attribute> allows one to set and get GL attributes. By passing a value C<SDLx::App::attribute> allows one to set and get GL attributes. By passing a value
in addition to the attribute selector, the value will be set. C<SDL:::App::attribute> in addition to the attribute selector, the value will be set. C<SDL:::App::attribute>
always returns the current value of the given attribute, or croaks on failure. always returns the current value of the given attribute, or croaks on failure.


Expand Down
16 changes: 8 additions & 8 deletions lib/pods/SDL/Cookbook/PDL.pod
Expand Up @@ -30,7 +30,7 @@ For example, here is a very poorly implemented hack (read - don't do this at hom
use strict; use strict;


use SDL; use SDL;
use SDL::App; use SDLx::App;
use SDL::Rect; use SDL::Rect;
use SDL::Color; use SDL::Color;
use SDL::Video; use SDL::Video;
Expand All @@ -39,7 +39,7 @@ For example, here is a very poorly implemented hack (read - don't do this at hom
my $nib_size = 3; my $nib_size = 3;


# Create the SDL App # Create the SDL App
my $app = SDL::App->new( my $app = SDLx::App->new(
-width => 640, -width => 640,
-height => 480, -height => 480,
-depth => 16, -depth => 16,
Expand Down Expand Up @@ -118,13 +118,13 @@ We next need to figure out how the application is actually going to run and disp
Here's some initialization code to get started; put this below the code already supplied above: Here's some initialization code to get started; put this below the code already supplied above:


use SDL; use SDL;
use SDL::App; use SDLx::App;
use SDL::Rect; use SDL::Rect;
use SDL::Color; use SDL::Color;
use SDL::Video; use SDL::Video;


# Create the SDL App # Create the SDL App
my $app = SDL::App->new( -width => $side_length, -height => $side_length, my $app = SDLx::App->new( -width => $side_length, -height => $side_length,
-title => "Simple Simulation!", -depth => 16, ); -title => "Simple Simulation!", -depth => 16, );


# white particles on a black background # white particles on a black background
Expand Down Expand Up @@ -335,13 +335,13 @@ Before moving into getting user interaction, I first want to be sure we're worki
package main; package main;


use SDL; use SDL;
use SDL::App; use SDLx::App;
use SDL::Rect; use SDL::Rect;
use SDL::Color; use SDL::Color;
use SDL::Video; use SDL::Video;


# Create the SDL App # Create the SDL App
my $app = SDL::App->new( -width => $side_length, -height => $side_length, my $app = SDLx::App->new( -width => $side_length, -height => $side_length,
-title => "Simple Simulation!", -depth => 16, ); -title => "Simple Simulation!", -depth => 16, );


# white particles on a black background # white particles on a black background
Expand Down Expand Up @@ -509,15 +509,15 @@ Just so that you've got a complete working example, here is the final state of t
package main; package main;


use SDL; use SDL;
use SDL::App; use SDLx::App;
use SDL::Rect; use SDL::Rect;
use SDL::Color; use SDL::Color;
use SDL::Video; use SDL::Video;
use SDL::Event; use SDL::Event;
use SDL::Events; use SDL::Events;


# Create the SDL App # Create the SDL App
my $app = SDL::App->new( -width => $side_length, -height => $side_length, my $app = SDLx::App->new( -width => $side_length, -height => $side_length,
-title => "Simple Simulation!", -depth => 16, ); -title => "Simple Simulation!", -depth => 16, );


# white particles on a black background # white particles on a black background
Expand Down
2 changes: 1 addition & 1 deletion lib/pods/SDL/GFX/Primitives.pod
Expand Up @@ -9,7 +9,7 @@ GFX
=head1 DESCRIPTION =head1 DESCRIPTION


All functions take an SDL::Surface object as first parameter. This can be a new surface that will be blittet afterwads, can be an surface All functions take an SDL::Surface object as first parameter. This can be a new surface that will be blittet afterwads, can be an surface
obtained by L<SDL::Video::set_video_mode> or can be an L<SDL::App>. obtained by L<SDL::Video::set_video_mode> or can be an L<SDLx::App>.


The C<color> values for the C<_color> functions are C<0xRRGGBBAA> (32bit), even if the surface uses e. g. 8bit colors. The C<color> values for the C<_color> functions are C<0xRRGGBBAA> (32bit), even if the surface uses e. g. 8bit colors.


Expand Down
2 changes: 1 addition & 1 deletion lib/pods/SDL/OpenGL.pod
Expand Up @@ -67,6 +67,6 @@ David J. Goehrig


=head1 SEE ALSO =head1 SEE ALSO


L<perl> L<SDL::App> L<perl> L<SDLx::App>


=cut =cut
12 changes: 6 additions & 6 deletions lib/pods/SDL/Tutorial.pod
Expand Up @@ -26,7 +26,7 @@ though. Here's how to get up and running as quickly as possible.
=head2 Surfaces =head2 Surfaces


All graphics in SDL live on a surface. You'll need at least one. That's what All graphics in SDL live on a surface. You'll need at least one. That's what
L<SDL::App> provides. L<SDLx::App> provides.


Of course, before you can get a surface, you need to initialize your video Of course, before you can get a surface, you need to initialize your video
mode. SDL gives you several options, including whether to run in a window or mode. SDL gives you several options, including whether to run in a window or
Expand All @@ -36,12 +36,12 @@ something really simple.


=head2 Initialization =head2 Initialization


SDL::App makes it easy to initialize video and create a surface. Here's how to SDLx::App makes it easy to initialize video and create a surface. Here's how to
ask for a windowed surface with 640x480x16 resolution: ask for a windowed surface with 640x480x16 resolution:


use SDL::App; use SDLx::App;


my $app = SDL::App->new( my $app = SDLx::App->new(
-width => 640, -width => 640,
-height => 480, -height => 480,
-depth => 16, -depth => 16,
Expand All @@ -51,9 +51,9 @@ You can get more creative, especially if you use the C<-title> and C<-icon>
attributes in a windowed application. Here's how to set the window title of attributes in a windowed application. Here's how to set the window title of
the application to C<My SDL Program>: the application to C<My SDL Program>:


use SDL::App; use SDLx::App;


my $app = SDL::App->new( my $app = SDLx::App->new(
-height => 640, -height => 640,
-width => 480, -width => 480,
-depth => 16, -depth => 16,
Expand Down

0 comments on commit c3d720d

Please sign in to comment.