update
[sdlgit/SDL-Site.git] / pages / SDLx-Surface.html-inc
1 <div class="pod">
2 <!-- INDEX START -->
3 <h3 id="TOP">Index</h3>
4
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>
13 </ul>
14 </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>
19 </ul>
20 </li>
21 <li><a href="#AUTHOR">AUTHOR</a>
22 </li>
23 </ul><hr />
24 <!-- INDEX END -->
25
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>
29
30 </div>
31 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
32 <div id="CATEGORY_CONTENT">
33 <p>Extension</p>
34
35 </div>
36 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
37 <div id="SYNOPSIS_CONTENT">
38 <pre> use SDL;
39  use SDL::Video;
40  use SDLx::Surface;
41
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);
45
46  my $surf_matrix = SDLx::Surface-&gt;new( surface =&gt; $display);
47
48  $surf__matrix-&gt;[10][10] = 0xFFFF; #for 16bpp write white at x = 10 and y=10
49
50  $surf_matrix-&gt;surface( $new_surface );
51
52  my $orig_surface = $surf_matrix-&gt;surface();
53
54 </pre>
55
56 </div>
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>
60
61 </div>
62 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
63 <div id="METHODS_CONTENT">
64
65 </div>
66 <h2 id="new">new</h2>
67 <div id="new_CONTENT">
68 <p>Takes a SDL::Surface in hash format.</p>
69 <p>If a surface is passed to 'surface =&gt;' that is loaded. Otherwise you can define at least a width and a height. </p>
70 <pre>   SDLx::Surface-&gt;new(  surface =&gt; $surface) # The $surface is loaded
71
72         SDLx::Surface-&gt;new( width=&gt; 400, height=&gt;200) 
73                 # A SDL::Surface-&gt;new( SDL_ANYFORMAT, 400, 200, 32) is loaded
74
75         SDLx::Surface-&gt;new( width=&gt; 400, height=&gt;200, flags=&gt; SDL_SWSURFACE, depth=&gt;24 ) 
76                 # A SDL::Surface-&gt;new( SDL_SWSURFACE, 400, 200, 24) is loaded 
77
78         SDLx::Surface-&gt;new( width=&gt; 400, height=&gt;200, flags=&gt; SDL_SWSURFACE, depth=&gt;32, greenmask=&gt;0xFF000000 )
79                 # A SDL::Surface-&gt;new( SDL_ANYFORMAT, 400, 200, 32, 0, 0xFF000000,0, 0, 0 ) is loaded
80
81 </pre>
82
83 </div>
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>
87
88 </div>
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(); 
93
94 </pre>
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 =&gt; 20, height =&gt; 20) #depth =&gt; 32 and SDL_ANYFORMAT used
97
98 </pre>
99 <p>or you can also pass flags and depth. </p>
100 <pre> SDLx::Surface::get_display( width =&gt; 20, height =&gt; 20, flags=&gt; SDL_HWSURFACE, depth=&gt;24) 
101
102 </pre>
103 <p>Get or create the main display surface and attach to a SDLx::Surface.</p>
104
105 </div>
106 <h1 id="EXTENSIONS">EXTENSIONS</h1><p><a href="#TOP" class="toplink">Top</a></p>
107 <div id="EXTENSIONS_CONTENT">
108
109 </div>
110 <h2 id="blit">blit </h2>
111 <div id="blit_CONTENT">
112 <pre> $sdlx_surface-&gt;blit( $dest, $src_rect, $dest_rect );
113
114 </pre>
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>
117 <p>Returns $self</p>
118
119 </div>
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>
123 <p>Returns $self</p>
124
125 </div>
126 <h2 id="update">update</h2>
127 <div id="update_CONTENT">
128 <pre> $sdlx_surface-&gt;update(); # whole surface is updated
129  $sdlx_surface-&gt;update([0,0,1,1]); # only that area (0,0,1,1) is updated
130
131  $sdlx_surface-&gt;update( [ SDL::Rect-&gt;new(0,0,1,2) ... ]); # defined rects are updated
132
133 </pre>
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>
135 <p>Returns $self</p>
136
137 </div>
138 <h1 id="AUTHOR">AUTHOR</h1><p><a href="#TOP" class="toplink">Top</a></p>
139 <div id="AUTHOR_CONTENT">
140 <pre> kthakore 
141
142
143
144
145 </pre>
146
147 </div>
148 </div>