Added patch for die error
[sdlgit/SDL_perl.git] / lib / SDL / App.pm
index f28eb03..f13d227 100644 (file)
@@ -3,7 +3,8 @@
 #      The application object, sort of like a surface
 #
 #      Copyright (C) 2000,2002,2003,2004 David J. Goehrig
-
+#      Copyright (C) 2009 Kartik Thakore
+#
 package SDL::App;
 
 use strict;
@@ -26,10 +27,13 @@ sub new {
                                -red_accum_size -ras -blue_accum_size -bas 
                                -green_accum_sizee -gas -alpha_accum_size -aas
                                -double_buffer -db -buffer_size -bs -stencil_size -st
-                               -asyncblit
+                               -asyncblit -init
                / ) if ($SDL::DEBUG);
 
-       SDL::Init(SDL_INIT_EVERYTHING());
+        # SDL_INIT_VIDEO() is 0, so check defined instead of truth.
+       my $init = defined $options{-init} ? $options{-init} : SDL_INIT_EVERYTHING();
+
+       SDL::Init($init);
        
        my $t = $options{-title}        || $options{-t}         || $0;
        my $it = $options{-icon_title}  || $options{-it}        || $t;
@@ -76,8 +80,8 @@ sub new {
        } else {
                $SDL::App::USING_OPENGL = 0;
        }
-
-       my $self = \SDL::SetVideoMode($w,$h,$d,$f)
+       my $self = SDL::SetVideoMode($w,$h,$d,$f);
+               $$self
                or die SDL::GetError();
        
        if ($ic and -e $ic) {
@@ -96,7 +100,7 @@ sub resize ($$$) {
        my $flags = SDL::SurfaceFlags($$self);
        if ( $flags & SDL::SDL_RESIZABLE()) {
                my $bpp = SDL::SurfaceBitsPerPixel($$self);
-               $self = \SDL::SetVideoMode($w,$h,$bpp,$flags);
+               $$self = SDL::SetVideoMode($w,$h,$bpp,$flags);
        }
 }