Commit | Line | Data |
162a0989 |
1 | <div class="pod"> |
2 | <!-- INDEX START --> |
3 | <h3 id="TOP">Index</h3> |
4 | |
c5cfaf97 |
5 | <ul><li><a href="#NAME">NAME</a></li> |
6 | <li><a href="#CATEGORY">CATEGORY</a></li> |
162a0989 |
7 | <li><a href="#SYNOPSIS">SYNOPSIS</a></li> |
8 | <li><a href="#DESCRIPTION">DESCRIPTION</a></li> |
5da56497 |
9 | <li><a href="#CONSTANTS">CONSTANTS</a></li> |
162a0989 |
10 | <li><a href="#METHODS">METHODS</a> |
801213bd |
11 | <ul><li><a href="#new">new</a></li> |
12 | <li><a href="#new_from">new_from</a></li> |
162a0989 |
13 | <li><a href="#w">w</a></li> |
14 | <li><a href="#h">h</a></li> |
0d76f1af |
15 | <li><a href="#format">format</a></li> |
16 | <li><a href="#pitch">pitch</a></li> |
0d76f1af |
17 | </ul> |
18 | </li> |
19 | <li><a href="#Direct_Write_to_Surface_Pixel">Direct Write to Surface Pixel</a> |
f373167e |
20 | <ul><li><a href="#get_pixel">get_pixel</a></li> |
801213bd |
21 | <li><a href="#set_pixels">set_pixels</a></li> |
0d76f1af |
22 | <li><a href="#get_pixels_ptr">get_pixels_ptr</a></li> |
162a0989 |
23 | </ul> |
24 | </li> |
c7e8d3c6 |
25 | <li><a href="#SEE_ALSO">SEE ALSO</a></li> |
26 | <li><a href="#AUTHORS">AUTHORS</a> |
162a0989 |
27 | </li> |
28 | </ul><hr /> |
29 | <!-- INDEX END --> |
30 | |
31 | <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p> |
32 | <div id="NAME_CONTENT"> |
801213bd |
33 | <p>SDL::Surface - Graphic surface structure</p> |
162a0989 |
34 | |
35 | </div> |
c5cfaf97 |
36 | <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p> |
bfdd9c2e |
37 | <div id="CATEGORY_CONTENT"> |
38 | <p>Core, Video, Structure</p> |
39 | |
bfdd9c2e |
40 | </div> |
162a0989 |
41 | <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
42 | <div id="SYNOPSIS_CONTENT"> |
801213bd |
43 | <pre> use SDL; |
44 | use SDL::Video; |
45 | use SDL::Surface; |
162a0989 |
46 | |
801213bd |
47 | # Create the main surface (display) |
48 | SDL::init(SDL_INIT_VIDEO); |
49 | my $display = SDL::Video::set_video_mode(640, 480, 16, SDL_SWSURFACE); |
50 | |
51 | # Create other surfaces attached to the $display. |
52 | my $surface = SDL::Surface->new(SDL_ASYNCBLIT | SDL_HWSURFACE, 640, 480, 16, 0, 0, 0, 0); |
53 | my $surface2 = SDL::Surface->new_from($surface, 100, 100, 8, 0, 0, 0, 0); |
162a0989 |
54 | |
55 | </pre> |
56 | |
57 | </div> |
58 | <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p> |
59 | <div id="DESCRIPTION_CONTENT"> |
60 | <p>An <code>SDL_Surface</code> defines a surfaceangular area of pixels.</p> |
61 | |
62 | </div> |
5da56497 |
63 | <h1 id="CONSTANTS">CONSTANTS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
64 | <div id="CONSTANTS_CONTENT"> |
801213bd |
65 | <p>The constants for SDL::Surface belong to SDL::Video, under the export tag of <code>':surface'</code>.</p> |
0d76f1af |
66 | <dl> |
0d76f1af |
67 | <dt>SDL_ASYNCBLIT</dt> |
68 | <dd> |
69 | <p>Use asynchronous blit if possible</p> |
70 | </dd> |
0d76f1af |
71 | <dt>SDL_SWSURFACE</dt> |
72 | <dd> |
801213bd |
73 | <p>Store in system memory</p> |
0d76f1af |
74 | </dd> |
5da56497 |
75 | <dt>SDL_HWSURFACE</dt> |
0d76f1af |
76 | <dd> |
801213bd |
77 | <p>Store in video memory</p> |
0d76f1af |
78 | </dd> |
79 | </dl> |
162a0989 |
80 | |
162a0989 |
81 | </div> |
801213bd |
82 | <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
83 | <div id="METHODS_CONTENT"> |
84 | |
85 | </div> |
86 | <h2 id="new">new</h2> |
87 | <div id="new_CONTENT"> |
88 | <pre> my $surface = SDL::Surface->new( |
89 | $flags, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask |
90 | ); |
91 | |
92 | </pre> |
93 | <p>The constructor creates a new surface with the specified parameter values.</p> |
94 | <p>The four mask values are the bits that the channel will ignore. |
95 | For example, an Rmask of <code>0xFF</code> will ignore that channel completely, making everything on the surface more green/blue.</p> |
96 | |
97 | </div> |
98 | <h2 id="new_from">new_from</h2> |
99 | <div id="new_from_CONTENT"> |
100 | <pre> my $surface = SDL::Surface->new_from( |
101 | $surface, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask |
102 | ); |
103 | |
104 | </pre> |
105 | <p>The constructor creates a new surface with the specified parameter values. |
106 | The flags are taken from the specified <code>$surface</code>.</p> |
107 | |
108 | </div> |
162a0989 |
109 | <h2 id="w">w</h2> |
110 | <div id="w_CONTENT"> |
801213bd |
111 | <pre> my $w = $surface->w; |
162a0989 |
112 | |
113 | </pre> |
801213bd |
114 | <p>Returns the width of the surface. |
115 | SDL::Surface width is defined at construction so this is read-only.</p> |
162a0989 |
116 | |
117 | </div> |
118 | <h2 id="h">h</h2> |
119 | <div id="h_CONTENT"> |
801213bd |
120 | <pre> my $h = $surface->h; |
162a0989 |
121 | |
122 | </pre> |
801213bd |
123 | <p>Returns the height of the surface. |
124 | SDL::Surface height is defined at construction so this is read-only.</p> |
162a0989 |
125 | |
126 | </div> |
0d76f1af |
127 | <h2 id="format">format</h2> |
128 | <div id="format_CONTENT"> |
0d76f1af |
129 | <pre> my $format = $surface->format; |
130 | |
131 | </pre> |
801213bd |
132 | <p>The format of the pixels stored in the surface. |
133 | See <a href="SDL-PixelFormat.html">SDL::PixelFormat</a></p> |
0d76f1af |
134 | |
135 | </div> |
136 | <h2 id="pitch">pitch</h2> |
137 | <div id="pitch_CONTENT"> |
138 | <pre> my $pitch = $surface->pitch; |
139 | |
140 | </pre> |
801213bd |
141 | <p>The scanline length in bytes.</p> |
0d76f1af |
142 | |
143 | </div> |
144 | <h1 id="Direct_Write_to_Surface_Pixel">Direct Write to Surface Pixel</h1><p><a href="#TOP" class="toplink">Top</a></p> |
145 | <div id="Direct_Write_to_Surface_Pixel_CONTEN"> |
801213bd |
146 | <p><strong>Disclaimer:</strong> The following methods can be very slow, making them suitable for creating surfaces, but not for animations</p> |
0d76f1af |
147 | |
148 | </div> |
f373167e |
149 | <h2 id="get_pixel">get_pixel</h2> |
150 | <div id="get_pixel_CONTENT"> |
801213bd |
151 | <pre> my $pixel = $surface->get_pixel( $offset ) |
0d76f1af |
152 | |
153 | </pre> |
801213bd |
154 | <p>Returns the pixel value for the given <code>$offset</code>. |
155 | The pixel value depends on current pixel format.</p> |
156 | <p><strong>Note:</strong> For surfaces with a palette (1 byte per pixel) the palette index is returned instead of color values.</p> |
0d76f1af |
157 | |
158 | </div> |
159 | <h2 id="set_pixels">set_pixels</h2> |
160 | <div id="set_pixels_CONTENT"> |
161 | <pre> $surface->set_pixels( $offset, $value ); |
162 | |
163 | </pre> |
801213bd |
164 | <p>Sets the pixel <code>$value</code> to the given <code>$offset</code>. |
165 | The pixel value must fit the pixel format of the surface.</p> |
f373167e |
166 | <p><strong>Note</strong>: For surfaces with a palette (1 byte per pixel) the palette index must be passed instead of color values.</p> |
801213bd |
167 | <p>Example:</p> |
168 | <pre> sub putpixel { |
169 | my ($x, $y, $color) = @_; |
170 | $display->set_pixels( $x + $y * $display->w, $color); |
f373167e |
171 | } |
0d76f1af |
172 | |
173 | </pre> |
801213bd |
174 | <p>See also <cite>examples/pixel_operations/sols/ch02.pl</cite>!</p> |
0d76f1af |
175 | |
176 | </div> |
177 | <h2 id="get_pixels_ptr">get_pixels_ptr</h2> |
178 | <div id="get_pixels_ptr_CONTENT"> |
801213bd |
179 | <pre> my $ptr = $surface->get_pixels_ptr; |
0d76f1af |
180 | |
181 | </pre> |
801213bd |
182 | <p>Returns a reference to the surface's pixels.</p> |
0d76f1af |
183 | |
184 | </div> |
162a0989 |
185 | <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p> |
186 | <div id="SEE_ALSO_CONTENT"> |
55bbf7a2 |
187 | <p><a href="SDL.html">SDL</a>, <a href="SDL-PixelFormat.html">SDL::PixelFormat</a>, <a href="SDL-Video.html">SDL::Video</a>, <a href="SDL-Rect.html">SDL::Rect</a></p> |
162a0989 |
188 | |
189 | </div> |
c7e8d3c6 |
190 | <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
191 | <div id="AUTHORS_CONTENT"> |
1dbe1697 |
192 | <p>See <a href="/SDL.html#AUTHORS">/SDL.html#AUTHORS</a>.</p> |
c7e8d3c6 |
193 | |
194 | </div> |
162a0989 |
195 | </div> |