3 <h3 id="TOP">Index</h3>
5 <ul><li><a href="#NAME">NAME</a></li>
6 <li><a href="#CATEGORY">CATEGORY</a></li>
7 <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
8 <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
9 <li><a href="#METHODS">METHODS</a>
10 <ul><li><a href="#new">new</a></li>
11 <li><a href="#surface">surface</a></li>
12 <li><a href="#get_display">get_display</a></li>
15 <li><a href="#EXTENSIONS">EXTENSIONS</a>
16 <ul><li><a href="#blit">blit </a></li>
17 <li><a href="#flip">flip</a></li>
18 <li><a href="#update">update</a></li>
21 <li><a href="#AUTHOR">AUTHOR</a>
26 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
27 <div id="NAME_CONTENT">
28 <p>SDLx::Surface - Graphic surface matrix extension</p>
31 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
32 <div id="CATEGORY_CONTENT">
36 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
37 <div id="SYNOPSIS_CONTENT">
42 # Create the main surface (display)
43 SDL::init(SDL_INIT_VIDEO);
44 my $display = SDL::Video::set_video_mode(640, 480, 16, SDL_SWSURFACE);
46 my $surf_matrix = SDLx::Surface->new( surface => $display);
48 $surf__matrix->[10][10] = 0xFFFF; #for 16bpp write white at x = 10 and y=10
50 $surf_matrix->surface( $new_surface );
52 my $orig_surface = $surf_matrix->surface();
57 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
58 <div id="DESCRIPTION_CONTENT">
59 <p>An <code>SDLx::Surface</code> allows matrix read and write to a surface, safely. </p>
62 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
63 <div id="METHODS_CONTENT">
67 <div id="new_CONTENT">
68 <p>Takes a SDL::Surface in hash format.</p>
69 <p>If a surface is passed to 'surface =>' that is loaded. Otherwise you can define at least a width and a height. </p>
70 <pre> SDLx::Surface->new( surface => $surface) # The $surface is loaded
72 SDLx::Surface->new( width=> 400, height=>200)
73 # A SDL::Surface->new( SDL_ANYFORMAT, 400, 200, 32) is loaded
75 SDLx::Surface->new( width=> 400, height=>200, flags=> SDL_SWSURFACE, depth=>24 )
76 # A SDL::Surface->new( SDL_SWSURFACE, 400, 200, 24) is loaded
78 SDLx::Surface->new( width=> 400, height=>200, flags=> SDL_SWSURFACE, depth=>32, greenmask=>0xFF000000 )
79 # A SDL::Surface->new( SDL_ANYFORMAT, 400, 200, 32, 0, 0xFF000000,0, 0, 0 ) is loaded
84 <h2 id="surface">surface</h2>
85 <div id="surface_CONTENT">
86 <p>If a SDL::Surface is passed it is attached to the matrix. Returns the SDL::Surface that is currently attached to this SDLx::Surface</p>
89 <h2 id="get_display">get_display</h2>
90 <div id="get_display_CONTENT">
91 <p>If <a href="http://search.cpan.org/perldoc?SDLx::App::new">SDLx::App::new</a> or <a href="/SDL-Video.html#get_video_mode">SDL::Video::get_video_mode</a> called before then:</p>
92 <pre> my $appx = SDLx::Surface::get_display();
95 <p>gets the display if it is already made. Passed options are ignored. Otherwise you can quickly make the display with :</p>
96 <pre> SDLx::Surface::get_display( width => 20, height => 20) #depth => 32 and SDL_ANYFORMAT used
99 <p>or you can also pass flags and depth. </p>
100 <pre> SDLx::Surface::get_display( width => 20, height => 20, flags=> SDL_HWSURFACE, depth=>24)
103 <p>Get or create the main display surface and attach to a SDLx::Surface.</p>
106 <h1 id="EXTENSIONS">EXTENSIONS</h1><p><a href="#TOP" class="toplink">Top</a></p>
107 <div id="EXTENSIONS_CONTENT">
110 <h2 id="blit">blit </h2>
111 <div id="blit_CONTENT">
112 <pre> $sdlx_surface->blit( $dest, $src_rect, $dest_rect );
115 <p>Blits SDLx::Surface onto $dest surface.
116 $src_rect or $dest_rect are optional. $src_rect or $dest_rect can be array refs or SDL::Rect. $dest can be SDLx::Surface or SDL::Surface. </p>
120 <h2 id="flip">flip</h2>
121 <div id="flip_CONTENT">
122 <p>Applies <a href="/SDL-Video.html#flip">SDL::Video::flip</a> to the Surface, with error checking.</p>
126 <h2 id="update">update</h2>
127 <div id="update_CONTENT">
128 <pre> $sdlx_surface->update(); # whole surface is updated
129 $sdlx_surface->update([0,0,1,1]); # only that area (0,0,1,1) is updated
131 $sdlx_surface->update( [ SDL::Rect->new(0,0,1,2) ... ]); # defined rects are updated
134 <p>Applies <a href="/SDL-Video.html#update_rect">SDL::Video::update_rect</a> for no rect or 1 array ref. Applies <a href="/SDL-Video.html#update_rects">SDL::Video::update_rects</a> for array of <a href="SDL-Rect.html">SDL::Rect</a>s. </p>
138 <h1 id="AUTHOR">AUTHOR</h1><p><a href="#TOP" class="toplink">Top</a></p>
139 <div id="AUTHOR_CONTENT">