/[VRac]/Screen.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /Screen.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 73 by dpavlin, Tue Jul 31 21:43:57 2007 UTC revision 75 by dpavlin, Wed Aug 1 12:40:20 2007 UTC
# Line 8  use warnings; Line 8  use warnings;
8  use SDL::App;  use SDL::App;
9  use SDL::Rect;  use SDL::Rect;
10  use SDL::Color;  use SDL::Color;
11    use SDL::Constants;
12    
13  use Carp qw/confess/;  use Carp qw/confess/;
14    use Data::Dump qw/dump/;
15    
16  use base qw(Class::Accessor Prefs);  use base qw(Class::Accessor Prefs);
17  __PACKAGE__->mk_accessors(qw(app));  __PACKAGE__->mk_accessors(qw(app));
# Line 41  sub open_screen { Line 43  sub open_screen {
43                  -height => 256 * $self->scale,                  -height => 256 * $self->scale,
44                  -depth  => 16,                  -depth  => 16,
45          );          );
46          #$app->grab_input( 0 );          #$app->grab_input( SDL_GRAB_QUERY );
47            $app->grab_input( SDL_GRAB_OFF );
48    
49          warn "# created SDL::App\n";          warn "# created SDL::App\n";
50          $self->app( $app );          $self->app( $app );
# Line 177  sub render { Line 180  sub render {
180    
181          die "this function isn't supported if scale isn't 1" unless $self->scale == 1;          die "this function isn't supported if scale isn't 1" unless $self->scale == 1;
182    
183          $app->lock;          my $pixels = pack("C*", @_);
184    
185          my ( $x, $y ) = ( 0,0 );          my $vram = SDL::Surface->new(
186                    -width => 256,
187                    -height => 256,
188                    -depth => 1,    # 1 bit per pixel
189                    -pitch => 32,   # bytes per line
190                    -from => $pixels,
191            );
192            $vram->set_colors( 0, $black, $white, $red );
193            $vram->display_format;
194    
195          foreach my $b ( @_ ) {          my $rect = SDL::Rect->new( -x => 0, -y => 0, -width => 256, -height => 256 );
196                  foreach my $p ( split(//, unpack("B8",pack("C",$b)) ) ) {          $vram->blit( $rect, $app, $rect );
                         $app->pixel( $x, $y, $p ? $white : $black );  
                         $x++;  
                 }  
                 if ( $x == 256 ) {  
                         $x = 0;  
                         $y++;  
                 }  
         }  
197    
         $app->unlock;  
198          $app->sync;          $app->sync;
   
         warn "Screen::render over\n";  
199  }  }
200    
201  =head1 SEE ALSO  =head1 SEE ALSO

Legend:
Removed from v.73  
changed lines
  Added in v.75

  ViewVC Help
Powered by ViewVC 1.1.26