Commit | Line | Data |
162a0989 |
1 | <div class="pod"> |
2 | <!-- INDEX START --> |
3 | <h3 id="TOP">Index</h3> |
4 | |
5 | <ul><li><a href="#NAME">NAME</a></li> |
bfdd9c2e |
6 | <li><a href="#CATEGORY">CATEGORY</a></li> |
7067312b |
7 | <li><a href="#SYNOPSIS">SYNOPSIS</a></li> |
3540cbee |
8 | <li><a href="#Core_Functions">Core Functions</a> |
162a0989 |
9 | <ul><li><a href="#get_video_surface">get_video_surface</a></li> |
10 | <li><a href="#get_video_info">get_video_info</a></li> |
11 | <li><a href="#video_driver_name">video_driver_name</a></li> |
12 | <li><a href="#list_modes_formats_flags">list_modes(formats,flags)</a></li> |
13 | <li><a href="#video_mode_ok_width_height_bpp_flags">video_mode_ok(width,height,bpp,flags)</a></li> |
14 | <li><a href="#set_video_mode_width_height_bpp_flag">set_video_mode(width,height,bpp,flags)</a> |
162a0989 |
15 | <ul><li><a href="#List_of_avalaibles_flags">List of avalaibles flags</a></li> |
16 | </ul> |
17 | </li> |
b968d0e8 |
18 | <li><a href="#convert_surface_surface_format_flags">convert_surface(surface,format,flags)</a></li> |
19 | <li><a href="#display_format">display_format</a></li> |
20 | <li><a href="#display_format_alpha">display_format_alpha</a></li> |
21 | <li><a href="#load_BMP_filename">load_BMP(filename)</a></li> |
22 | <li><a href="#save_BMP_surface_filename">save_BMP(surface,filename)</a></li> |
23 | <li><a href="#set_color_key_surface_flag_key">set_color_key(surface,flag,key)</a></li> |
24 | <li><a href="#set_alpha_surface_flag_key">set_alpha(surface,flag,key)</a></li> |
25 | <li><a href="#fill_rect_dest_dest_rect_pixel">fill_rect(dest,dest_rect,pixel)</a></li> |
26 | </ul> |
27 | </li> |
28 | <li><a href="#Surface_locking_and_unlocking">Surface locking and unlocking</a> |
29 | <ul><li><a href="#lock_surface_surface">lock_surface(surface)</a></li> |
30 | <li><a href="#unlock_surface_surface">unlock_surface(surface)</a></li> |
31 | <li><a href="#MUSTLOCK_surface">MUSTLOCK(surface)</a></li> |
32 | </ul> |
33 | </li> |
34 | <li><a href="#Screen_Updating_Functions">Screen Updating Functions</a> |
35 | <ul><li><a href="#set_clip_rect_surface_rect">set_clip_rect(surface,rect)</a></li> |
36 | <li><a href="#get_clip_rect_surface_rect">get_clip_rect(surface,rect)</a></li> |
37 | <li><a href="#blit_surface_src_src_rect_dest_dest_">blit_surface(src,src_rect,dest,dest_rect)</a></li> |
162a0989 |
38 | <li><a href="#update_rect_surface_x_y_width_height">update_rect(surface,x,y,width,height)</a></li> |
39 | <li><a href="#update_rects_surface_rects">update_rects(surface,rects) </a></li> |
40 | <li><a href="#flip_surface">flip(surface)</a></li> |
b968d0e8 |
41 | </ul> |
42 | </li> |
43 | <li><a href="#Palette_Color_and_Pixel_Functions">Palette, Color and Pixel Functions</a> |
44 | <ul><li><a href="#set_colors_surface_start_colors">set_colors(surface,start,colors)</a></li> |
162a0989 |
45 | <li><a href="#set_palette_surface_flags_start_colo">set_palette(surface,flags,start,colors)</a></li> |
46 | <li><a href="#set_gamma_r_g_b">set_gamma(r,g,b)</a></li> |
904171e2 |
47 | <li><a href="#get_gamma_ramp_rt_gt_bt">get_gamma_ramp(rt,gt,bt)</a></li> |
162a0989 |
48 | <li><a href="#set_gamma_ramp_rt_gt_bt">set_gamma_ramp(rt,gt,bt)</a></li> |
49 | <li><a href="#map_RGB_pixel_format_r_g_b">map_RGB(pixel_format,r,g,b)</a></li> |
50 | <li><a href="#map_RGBA_pixel_format_r_g_b_a">map_RGBA(pixel_format,r,g,b,a)</a></li> |
51 | <li><a href="#get_RGB_pixel_format_pixel">get_RGB(pixel_format,pixel)</a></li> |
52 | <li><a href="#get_RGBA_pixel_format_pixel">get_RGBA(pixel_format,pixel)</a></li> |
3540cbee |
53 | </ul> |
54 | </li> |
55 | <li><a href="#GL_Methods">GL Methods</a> |
56 | <ul><li><a href="#GL_load_library_path">GL_load_library(path)</a></li> |
162a0989 |
57 | <li><a href="#GL_get_proc_address_proc">GL_get_proc_address(proc)</a></li> |
58 | <li><a href="#GL_get_attribute_attr">GL_get_attribute(attr)</a></li> |
59 | <li><a href="#GL_set_attribute_attr_value">GL_set_attribute(attr,value)</a></li> |
60 | <li><a href="#GL_swap_buffers">GL_swap_buffers</a></li> |
61 | <li><a href="#GL_attr_to_be_coded">GL_attr *** to be coded</a></li> |
3540cbee |
62 | </ul> |
63 | </li> |
b1795fa6 |
64 | <li><a href="#Video_Overlay_Functions">Video Overlay Functions</a> |
3540cbee |
65 | <ul><li><a href="#lock_YUV_overlay_overlay">lock_YUV_overlay(overlay)</a></li> |
162a0989 |
66 | <li><a href="#unlock_YUV_overlay_overlay">unlock_YUV_overlay(overlay)</a></li> |
67 | <li><a href="#display_YUV_overlay_overlay_dstrect">display_YUV_overlay(overlay,dstrect)</a></li> |
68 | </ul> |
69 | </li> |
b968d0e8 |
70 | <li><a href="#Window_Management_Functions">Window Management Functions</a> |
71 | <ul><li><a href="#wm_set_caption_title_icon">wm_set_caption(title,icon)</a></li> |
72 | <li><a href="#wm_get_caption">wm_get_caption()</a></li> |
73 | <li><a href="#wm_set_icon_icon">wm_set_icon(icon)</a></li> |
74 | <li><a href="#wm_grab_input_mode">wm_grab_input(mode)</a></li> |
75 | <li><a href="#wm_iconify_window">wm_iconify_window()</a></li> |
76 | <li><a href="#wm_toggle_fullscreen_surface">wm_toggle_fullscreen(surface)</a></li> |
77 | </ul> |
78 | </li> |
162a0989 |
79 | <li><a href="#SEE_ALSO">SEE ALSO</a> |
80 | <ul><li><a href="#Category_Objects">Category Objects</a> |
81 | </li> |
82 | </ul> |
83 | </li> |
84 | </ul><hr /> |
3774ca11 |
85 | <!-- INDEX END --><a href="assets/Video.png" target="_blank"><img src="assets/Video.png" style="height: 160px" alt="Video.png"/></a><hr /> |
162a0989 |
86 | |
87 | <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p> |
88 | <div id="NAME_CONTENT"> |
89 | <p>SDL::Video - Bindings to the video category in SDL API</p> |
90 | |
91 | </div> |
bfdd9c2e |
92 | <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p> |
93 | <div id="CATEGORY_CONTENT"> |
94 | <p>Core, Video</p> |
162a0989 |
95 | |
96 | </div> |
7067312b |
97 | <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
98 | <div id="SYNOPSIS_CONTENT"> |
99 | <pre> use SDL; |
100 | use SDL::Video; |
101 | use SDL::Surface; |
102 | use SDL::Rect; |
162a0989 |
103 | |
7067312b |
104 | # the size of the window box or the screen resolution if fullscreen |
105 | my $screen_width = 800; |
106 | my $screen_height = 600; |
162a0989 |
107 | |
7067312b |
108 | SDL::init(SDL_INIT_VIDEO); |
162a0989 |
109 | |
7067312b |
110 | # setting video mode |
111 | my $screen_surface = SDL::Video::set_video_mode($screen_width, $screen_height, 32, SDL_SWSURFACE); |
162a0989 |
112 | |
7067312b |
113 | # drawing something somewhere |
114 | my $mapped_color = SDL::Video::map_RGB($screen_surface->format(), 0, 0, 255); # blue |
115 | SDL::Video::fill_rect($screen_surface, |
116 | SDL::Rect->new($screen_width / 4, $screen_height / 4, |
117 | $screen_width / 2, $screen_height / 2), $mapped_color); |
118 | |
119 | # update an area on the screen so its visible |
120 | SDL::Video::update_rect($screen_surface, 0, 0, $screen_width, $screen_height); |
121 | |
122 | sleep(5); # just to have time to see it |
123 | |
52432657 |
124 | SDL::quit(); |
125 | |
7067312b |
126 | </pre> |
162a0989 |
127 | |
128 | </div> |
3540cbee |
129 | <h1 id="Core_Functions">Core Functions</h1><p><a href="#TOP" class="toplink">Top</a></p> |
130 | <div id="Core_Functions_CONTENT"> |
162a0989 |
131 | |
132 | </div> |
133 | <h2 id="get_video_surface">get_video_surface</h2> |
134 | <div id="get_video_surface_CONTENT"> |
7067312b |
135 | <pre> my $surface = SDL::Video::get_video_surface(); |
136 | |
137 | </pre> |
52432657 |
138 | <p>This function returns the current display <a href="/SDL-Surface.html">SDL::Surface</a>. If SDL is doing format conversion on the display surface, this |
7067312b |
139 | function returns the publicly visible surface, not the real video surface.</p> |
52432657 |
140 | <p>Example:</p> |
141 | <pre> # somewhere after you set the video mode |
142 | my $surface = SDL::Video::get_video_surface(); |
143 | |
144 | printf( "our screen is %d pixels wide and %d pixels high\n", $surface->w, $surface->h ); |
145 | |
146 | </pre> |
162a0989 |
147 | |
148 | </div> |
149 | <h2 id="get_video_info">get_video_info</h2> |
150 | <div id="get_video_info_CONTENT"> |
52432657 |
151 | <pre> my $video_info = SDL::Video::get_video_info(); |
152 | |
153 | </pre> |
154 | <p>This function returns a read-only <a href="/SDL-VideoInfo.html">SDL::VideoInfo</a> containing information about the video hardware. If it is called before |
155 | <a href="#set_video_mode_width_height_bpp_flag">SDL::Video::set_video_mode</a>, the <code>vfmt</code> member of the returned structure will contain the pixel |
156 | format of the <strong>best</strong> video mode. </p> |
157 | <p>Example:</p> |
158 | <pre> use SDL; |
159 | use SDL::Video; |
160 | use SDL::VideoInfo; |
161 | use SDL::PixelFormat; |
162 | |
163 | SDL::init(SDL_INIT_VIDEO); |
164 | |
165 | my $video_info = SDL::Video::get_video_info(); |
166 | |
167 | printf( "we can have %dbits per pixel\n", $video_info->vfmt->BitsPerPixel ); |
168 | |
169 | SDL::quit(); |
170 | |
171 | </pre> |
162a0989 |
172 | |
173 | </div> |
174 | <h2 id="video_driver_name">video_driver_name</h2> |
175 | <div id="video_driver_name_CONTENT"> |
52432657 |
176 | <pre> my $driver_name = SDL::Video::video_driver_name(); |
177 | |
178 | </pre> |
179 | <p>This function will return the name of the initialized video driver up to a maximum of 1024 characters. The driver name is a simple one |
180 | word identifier like <code>"x11"</code>, <code>"windib"</code> or <code>"directx"</code>.</p> |
181 | <p><strong>Note</strong>: Some platforms allow selection of the video driver through the <code>SDL_VIDEODRIVER</code> environment variable. </p> |
182 | <p>Example:</p> |
183 | <pre> use SDL; |
184 | use SDL::Video; |
185 | |
186 | SDL::init(SDL_INIT_VIDEO); |
187 | |
188 | print SDL::Video::video_driver_name() . "\n"; |
189 | |
190 | SDL::quit(); |
191 | |
192 | </pre> |
162a0989 |
193 | |
194 | </div> |
195 | <h2 id="list_modes_formats_flags">list_modes(formats,flags)</h2> |
196 | <div id="list_modes_formats_flags_CONTENT"> |
096d8dc8 |
197 | <pre> my @modes = @{ SDL::Video::list_modes( $pixel_format, $flags ) }; |
52432657 |
198 | |
199 | </pre> |
096d8dc8 |
200 | <p>Returns a ref to an array of available screen dimensions for the given format and video flags, |
201 | or it return undef if no modes are available.</p> |
52432657 |
202 | <p>Example:</p> |
203 | <pre> use SDL; |
204 | use SDL::Video; |
205 | use SDL::VideoInfo; |
206 | use SDL::PixelFormat; |
207 | use SDL::Rect; |
208 | |
209 | SDL::init(SDL_INIT_VIDEO); |
210 | |
211 | my $video_info = SDL::Video::get_video_info(); |
212 | |
213 | my @modes = @{ SDL::Video::list_modes($video_info->vfmt, SDL_NOFRAME) }; |
214 | |
215 | if($#modes > 0) |
216 | { |
217 | print("available modes:\n"); |
218 | foreach my $index ( @modes ) |
219 | { |
220 | printf("%03d: %d x %d\n", $index, $modes[$index]->w, $modes[$index]->h ); |
221 | } |
222 | } |
223 | elsif($#modes == 0) |
224 | { |
225 | printf("%s video modes available\n", $modes[0]); |
226 | } |
227 | |
228 | SDL::quit(); |
229 | |
230 | </pre> |
162a0989 |
231 | |
232 | </div> |
233 | <h2 id="video_mode_ok_width_height_bpp_flags">video_mode_ok(width,height,bpp,flags)</h2> |
234 | <div id="video_mode_ok_width_height_bpp_flags-2"> |
096d8dc8 |
235 | <pre> my $bpp_ok = SDL::Video::video_mode_ok( $width, $height, $bpp, $flags ); |
236 | |
237 | </pre> |
238 | <p>This function is used to check whether the requested mode is supported by the current video device. The arguments passed to this function |
239 | are the same as those you would pass to <a href="#set_video_mode_width_height_bpp_flag">SDL::Video::set_video_mode</a>. |
240 | It returns <code>0</code> if the mode is not supported at all, otherwise the suggested <code>bpp</code>.</p> |
241 | <p>Example:</p> |
242 | <pre> use SDL; |
243 | use SDL::Video; |
244 | |
245 | SDL::init(SDL_INIT_VIDEO); |
246 | |
247 | my $video_mode_ok = SDL::Video::video_mode_ok( 800, 600, 32, SDL_SWSURFACE ); |
248 | |
249 | unless($video_mode_ok) |
250 | { |
251 | printf("this video mode ist not supported\n" ); |
252 | } |
253 | |
254 | SDL::quit(); |
255 | |
256 | |
257 | |
258 | |
259 | </pre> |
162a0989 |
260 | |
261 | </div> |
262 | <h2 id="set_video_mode_width_height_bpp_flag">set_video_mode(width,height,bpp,flags)</h2> |
263 | <div id="set_video_mode_width_height_bpp_flag-2"> |
7067312b |
264 | <pre> my $surface = SDL::Video::set_video_mode( 800, 600, 32, SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN); |
265 | |
266 | </pre> |
096d8dc8 |
267 | <p>Sets up a video mode with the specified width, height, bits-per-pixel and flags. |
268 | <code>set_video_mode</code> returns a <a href="/SDL-Surface.html">SDL::Surface</a> on success otherwise it returns undef on error, the error message is retrieved |
269 | using <code>SDL::get_error</code>.</p> |
162a0989 |
270 | |
271 | </div> |
449a007b |
272 | <h3 id="List_of_avalaibles_flags">List of avalaibles flags</h3> |
162a0989 |
273 | <div id="List_of_avalaibles_flags_CONTENT"> |
449a007b |
274 | <dl> |
7067312b |
275 | <dt><code>SDL_SWSURFACE</code></dt> |
449a007b |
276 | <dd> |
277 | <p>Create the video surface in system memory</p> |
278 | </dd> |
7067312b |
279 | <dt><code>SDL_HWSURFACE</code></dt> |
449a007b |
280 | <dd> |
281 | <p>Create the video surface in video memory</p> |
282 | </dd> |
7067312b |
283 | <dt><code>SDL_ASYNCBLIT</code></dt> |
449a007b |
284 | <dd> |
285 | <p>Enables the use of asynchronous updates of the display surface. |
286 | This will usually slow down blitting on single CPU machines, but may provide a speed increase on SMP systems.</p> |
287 | </dd> |
7067312b |
288 | <dt><code>SDL_ANYFORMAT</code></dt> |
449a007b |
289 | <dd> |
290 | <p>Normally, if a video surface of the requested bits-per-pixel (bpp) is not available, SDL will emulate one with a shadow surface. |
7067312b |
291 | Passing <code>SDL_ANYFORMAT</code> prevents this and causes SDL to use the video surface, regardless of its pixel depth.</p> |
449a007b |
292 | </dd> |
7067312b |
293 | <dt><code>SDL_HWPALETTE</code></dt> |
449a007b |
294 | <dd> |
295 | <p>Give SDL exclusive palette access. Without this flag you may not always get the colors you request with SDL::set_colors or SDL::set_palette.</p> |
296 | </dd> |
7067312b |
297 | <dt><code>SDL_DOUBLEBUF</code></dt> |
449a007b |
298 | <dd> |
7067312b |
299 | <p>Enable hardware double buffering; only valid with <code>SDL_HWSURFACE</code>. Calling <a href="#flip_surface">SDL::Video::flip</a> will flip the buffers and update |
300 | the screen. |
449a007b |
301 | All drawing will take place on the surface that is not displayed at the moment. |
7067312b |
302 | If double buffering could not be enabled then <a href="#flip_surface">SDL::Video::flip</a> will just perform a |
303 | <a href="#update_rect_surface_x_y_width_height">SDL::Video::update_rect</a> on the entire screen.</p> |
449a007b |
304 | </dd> |
7067312b |
305 | <dt><code>SDL_FULLSCREEN</code></dt> |
449a007b |
306 | <dd> |
307 | <p>SDL will attempt to use a fullscreen mode. If a hardware resolution change is not possible (for whatever reason), |
308 | the next higher resolution will be used and the display window centered on a black background.</p> |
309 | </dd> |
7067312b |
310 | <dt><code>SDL_OPENGL</code></dt> |
449a007b |
311 | <dd> |
7067312b |
312 | <p>Create an OpenGL rendering context. You should have previously set OpenGL video attributes with |
313 | <a href="#GL_set_attribute_attr_value">SDL::Video::GL_set_attribute</a>.</p> |
449a007b |
314 | </dd> |
7067312b |
315 | <dt><code>SDL_OPENGLBLIT</code></dt> |
449a007b |
316 | <dd> |
317 | <p>Create an OpenGL rendering context, like above, but allow normal blitting operations. |
318 | The screen (2D) surface may have an alpha channel, and SDL::update_rects must be used for updating changes to the screen surface. |
319 | NOTE: This option is kept for compatibility only, and will be removed in next versions. Is not recommended for new code.</p> |
320 | </dd> |
7067312b |
321 | <dt><code>SDL_RESIZABLE</code></dt> |
449a007b |
322 | <dd> |
323 | <p>Create a resizable window. |
7067312b |
324 | When the window is resized by the user a <code>SDL_VIDEORESIZE</code> event is generated and |
325 | <a href="#set_video_mode_width_height_bpp_flag">SDL::Video::set_video_mode</a> can be called again with the new size.</p> |
449a007b |
326 | </dd> |
7067312b |
327 | <dt><code>SDL_NOFRAME</code></dt> |
449a007b |
328 | <dd> |
329 | <p>If possible, SDL_NOFRAME causes SDL to create a window with no title bar or frame decoration. |
330 | Fullscreen modes automatically have this flag set.</p> |
331 | </dd> |
332 | </dl> |
096d8dc8 |
333 | <p><strong>Note 1</strong>: Use <code>SDL_SWSURFACE</code> if you plan on doing per-pixel manipulations, or blit surfaces with alpha channels, and require a high framerate. |
334 | When you use hardware surfaces (by passing the flag <code>SDL_HWSURFACE</code> as parameter), SDL copies the surfaces from video memory to system memory |
7067312b |
335 | when you lock them, and back when you unlock them. This can cause a major performance hit. Be aware that you may request a hardware surface, |
336 | but receive a software surface because the video driver doesn't support hardware surface. Many platforms can only provide a hardware surface |
096d8dc8 |
337 | when using <code>SDL_FULLSCREEN</code>. The <code>SDL_HWSURFACE</code> flag is best used when the surfaces you'll be blitting can also be stored in video memory.</p> |
338 | <p><strong>Note 2</strong>: If you want to control the position on the screen when creating a windowed surface, you may do so by setting the environment |
339 | variables <code>SDL_VIDEO_CENTERED=center</code> or <code>SDL_VIDEO_WINDOW_POS=x,y</code>. You can also set them via <code>SDL::putenv</code>.</p> |
340 | <p><strong>Note 3</strong>: This function should be called in the main thread of your application.</p> |
341 | <p><strong>User note 1</strong>: Some have found that enabling OpenGL attributes like <code>SDL_GL_STENCIL_SIZE</code> (the stencil buffer size) before the video mode has |
7067312b |
342 | been set causes the application to simply ignore those attributes, while enabling attributes after the video mode has been set works fine.</p> |
096d8dc8 |
343 | <p><strong>User note 2</strong>: Also note that, in Windows, setting the video mode resets the current OpenGL context. You must execute again the OpenGL |
7067312b |
344 | initialization code (set the clear color or the shade model, or reload textures, for example) after calling SDL::set_video_mode. In Linux, |
096d8dc8 |
345 | however, it works fine, and the initialization code only needs to be executed after the first call to |
346 | <a href="#set_video_mode_width_height_bpp_flag">SDL::Video::set_video_mode</a> (although there is no harm in executing the initialization code after |
347 | each call to <a href="#set_video_mode_width_height_bpp_flag">SDL::Video::set_video_mode</a>, for example for a multiplatform application). </p> |
162a0989 |
348 | |
349 | </div> |
b968d0e8 |
350 | <h2 id="convert_surface_surface_format_flags">convert_surface(surface,format,flags)</h2> |
351 | <div id="convert_surface_surface_format_flags-2"> |
352 | <p>Creates a new SDL::surface of the specified SDL::pixel_format, and then copies and maps the given surface to it. |
353 | It is also useful for making a copy of a surface.</p> |
354 | <p>The flags parameter is passed to SDL::create_RGB_surface and has those semantics. |
355 | This function is used internally by SDL::display_format. |
356 | This function can only be called after SDL::init. </p> |
357 | <p>it returns a SDL::surface on success or undef on error.</p> |
358 | |
359 | </div> |
360 | <h2 id="display_format">display_format</h2> |
361 | <div id="display_format_CONTENT"> |
362 | <p>Converts a surface to the display format </p> |
363 | |
364 | </div> |
365 | <h2 id="display_format_alpha">display_format_alpha</h2> |
366 | <div id="display_format_alpha_CONTENT"> |
367 | <p>Converts a surface to the display format </p> |
368 | |
369 | </div> |
370 | <h2 id="load_BMP_filename">load_BMP(filename)</h2> |
371 | <div id="load_BMP_filename_CONTENT"> |
372 | <p>Loads a SDL::surface from a named Windows BMP file. |
373 | SDL::load_BMP returns a SDL::surface on success or undef on error.</p> |
374 | <p>Note: When loading a 24-bit Windows BMP file, pixel data points are loaded as blue, green, red, and NOT red, green, blue (as one might expect). </p> |
375 | |
376 | |
377 | |
378 | |
379 | |
380 | </div> |
381 | <h2 id="save_BMP_surface_filename">save_BMP(surface,filename)</h2> |
382 | <div id="save_BMP_surface_filename_CONTENT"> |
383 | <p>Saves the given SDL::Surface surface as a Windows BMP file named filename. |
384 | it returns 0 on success or -1 on error.</p> |
385 | |
386 | </div> |
387 | <h2 id="set_color_key_surface_flag_key">set_color_key(surface,flag,key)</h2> |
388 | <div id="set_color_key_surface_flag_key_CONTE"> |
389 | <p>Sets the color key (transparent pixel) in a blittable surface and enables or disables RLE blit acceleration.</p> |
390 | <p>RLE acceleration can substantially speed up blitting of images with large horizontal runs of transparent pixels (i.e., pixels that match |
391 | the key value). |
392 | The key must be of the same pixel format as the surface, SDL::map_RGB is often useful for obtaining an acceptable value. |
393 | If flag is SDL_SRCCOLORKEY then key is the transparent pixel value in the source image of a blit.</p> |
394 | <p>If flag is OR'd with SDL_RLEACCEL then the surface will be drawn using RLE acceleration when drawn with SDL::Blit_surface. |
395 | The surface will actually be encoded for RLE acceleration the first time SDL::blit_surface or SDL::display_format is called on the surface. |
396 | If flag is 0, this function clears any current color key. </p> |
397 | <p>SDL::set_color_key returns 0 on success or -1 on error.</p> |
398 | |
399 | |
400 | |
401 | |
402 | |
403 | </div> |
404 | <h2 id="set_alpha_surface_flag_key">set_alpha(surface,flag,key)</h2> |
405 | <div id="set_alpha_surface_flag_key_CONTENT"> |
406 | <p>SDL::set_alpha is used for setting the per-surface alpha value and/or enabling and disabling alpha blending.</p> |
407 | <p>The surface parameter specifies which SDL::surface whose alpha attributes you wish to adjust. |
408 | flags is used to specify whether alpha blending should be used (SDL_SRCALPHA) and whether the surface should use RLE acceleration for |
409 | blitting (SDL_RLEACCEL). |
410 | flags can be an OR'd combination of these two options, one of these options or 0. |
411 | If SDL_SRCALPHA is not passed as a flag then all alpha information is ignored when blitting the surface. |
412 | The alpha parameter is the per-surface alpha value; a surface need not have an alpha channel to use per-surface alpha and blitting can |
413 | still be accelerated with SDL_RLEACCEL.</p> |
414 | <p>Note: The per-surface alpha value of 128 is considered a special case and is optimised, so it's much faster than other per-surface values.</p> |
415 | <p>Alpha affects surface blitting in the following ways: </p> |
416 | <dl> |
417 | <dt>RGBA->RGB with SDL_SRCALPHA</dt> |
418 | <dd> |
419 | <p>The source is alpha-blended with the destination, using the alpha channel. |
420 | SDL_SRCCOLORKEY and the per-surface alpha are ignored.</p> |
421 | </dd> |
422 | <dt>RGBA->RGB without SDL_SRCALPHA</dt> |
423 | <dd> |
424 | <p>The RGB data is copied from the source. The source alpha channel and the per-surface alpha value are ignored. |
425 | If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.</p> |
426 | </dd> |
427 | <dt>RGB->RGBA with SDL_SRCALPHA</dt> |
428 | <dd> |
429 | <p>The source is alpha-blended with the destination using the per-surface alpha value. |
430 | If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied. |
431 | The alpha channel of the copied pixels is set to opaque.</p> |
432 | </dd> |
433 | <dt>RGB->RGBA without SDL_SRCALPHA</dt> |
434 | <dd> |
435 | <p>The RGB data is copied from the source and the alpha value of the copied pixels is set to opaque. |
436 | If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.</p> |
437 | </dd> |
438 | <dt>RGBA->RGBA with SDL_SRCALPHA</dt> |
439 | <dd> |
440 | <p>The source is alpha-blended with the destination using the source alpha channel. |
441 | The alpha channel in the destination surface is left untouched. SDL_SRCCOLORKEY is ignored.</p> |
442 | </dd> |
443 | <dt>RGBA->RGBA without SDL_SRCALPHA</dt> |
444 | <dd> |
445 | <p>The RGBA data is copied to the destination surface. |
446 | If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.</p> |
447 | </dd> |
448 | <dt>RGB->RGB with SDL_SRCALPHA</dt> |
449 | <dd> |
450 | <p>The source is alpha-blended with the destination using the per-surface alpha value. |
451 | If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.</p> |
452 | </dd> |
453 | <dt>RGB->RGB without SDL_SRCALPHA</dt> |
454 | <dd> |
455 | <p>The RGB data is copied from the source. |
456 | If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.</p> |
457 | </dd> |
458 | </dl> |
459 | <p>Note: When blitting, the presence or absence of SDL_SRCALPHA is relevant only on the source surface, not the destination. |
460 | Note: Note that RGBA->RGBA blits (with SDL_SRCALPHA set) keep the alpha of the destination surface. This means that you cannot compose |
461 | two arbitrary RGBA surfaces this way and get the result you would expect from "overlaying" them; the destination alpha will work as a mask.</p> |
462 | <p>Note: Also note that per-pixel and per-surface alpha cannot be combined; the per-pixel alpha is always used if available. </p> |
463 | <p>SDL::set_alpha returns 0 on success or -1 on error.</p> |
464 | |
465 | </div> |
466 | <h2 id="fill_rect_dest_dest_rect_pixel">fill_rect(dest,dest_rect,pixel)</h2> |
467 | <div id="fill_rect_dest_dest_rect_pixel_CONTE"> |
468 | <p>This function performs a fast fill of the given SDL::rectangle with the given SDL::pixel_format. If dstrect is NULL, the whole surface |
469 | will be filled with color.</p> |
470 | <p>The color should be a pixel of the format used by the surface, and can be generated by the SDL::MapRGB or SDL::map_RGBA functions. |
471 | If the color value contains an alpha value then the destination is simply "filled" with that alpha information, no blending takes place.</p> |
472 | <p>If there is a clip rectangle set on the destination (set via SDL::set_clip_rect), then this function will clip based on the intersection |
473 | of the clip rectangle and the dstrect rectangle, and the dstrect rectangle will be modified to represent the area actually filled.</p> |
474 | <p>If you call this on the video surface (ie: the value of SDL::get_video_surface()) you may have to update the video surface to see the |
475 | result. This can happen if you are using a shadowed surface that is not double buffered in Windows XP using build 1.2.9. </p> |
476 | <p>SDL::fill_rect returns 0 on success or -1 on error.</p> |
477 | |
478 | </div> |
479 | <h1 id="Surface_locking_and_unlocking">Surface locking and unlocking</h1><p><a href="#TOP" class="toplink">Top</a></p> |
480 | <div id="Surface_locking_and_unlocking_CONTEN"> |
481 | |
482 | </div> |
483 | <h2 id="lock_surface_surface">lock_surface(surface)</h2> |
484 | <div id="lock_surface_surface_CONTENT"> |
485 | <pre> int SDL::Video::lock_surface( $surface ); |
486 | |
487 | </pre> |
488 | <p><code>SDL::Video::lock_surface</code> sets up the given <a href="/SDL-Surface.html">SDL::Surface</a> for directly accessing the pixels. |
489 | Between calls to SDL::lock_surface and SDL::unlock_surface, you can write to ( <code>surface-</code>set_pixels>) and read from ( <code>surface-</code>get_pixels> ), |
490 | using the pixel format stored in <code>surface-</code>format>. |
491 | Once you are done accessing the surface, you should use <code>SDL::Video::unlock_surface</code> to release the lock.</p> |
492 | <p>Not all surfaces require locking. If <code>SDL::Video::MUSTLOCK(surface)</code> evaluates to <code>0</code>, then reading and writing pixels to the surface can |
493 | be performed at any time, and the pixel format of the surface will not change. |
494 | No operating system or library calls should be made between the lock/unlock pairs, as critical system locks may be held during this time. |
495 | <code>SDL::Video::lock_surface</code> returns <code>0</code> on success or <code>-1</code> on error.</p> |
496 | <p><strong>Note</strong>: Since SDL 1.1.8, the surface locks are recursive. This means that you can lock a surface multiple times, but each lock must have |
497 | a matching unlock.</p> |
498 | <pre> use SDL; |
499 | use SDL::Video; |
500 | use SDL::Surface; |
501 | |
502 | SDL::init(SDL_INIT_VIDEO); |
503 | |
504 | my $screen_surface = SDL::Video::set_video_mode(640, 480, 16, SDL_HWSURFACE); |
505 | |
506 | if(SDL::Video::MUSTLOCK($screen_surface)) |
507 | { |
508 | print( "the surface must be locked\n" ); |
509 | |
510 | if(0 == SDL::Video::lock_surface($screen_surface)) |
511 | { |
512 | print( "lock succesful\n" ); |
513 | } |
514 | else |
515 | { |
516 | print( "error while locking surface" ); |
517 | } |
518 | |
519 | # pixel manipulation goes here |
520 | |
521 | SDL::Video::unlock_surface($screen_surface); # unlock_surface returns nothing |
522 | } |
523 | else |
524 | { |
525 | print( "the surface need not to be locked" ); |
526 | } |
527 | |
528 | SDL::quit(); |
529 | |
530 | </pre> |
531 | |
532 | </div> |
533 | <h2 id="unlock_surface_surface">unlock_surface(surface)</h2> |
534 | <div id="unlock_surface_surface_CONTENT"> |
535 | <pre> void SDL::Video::unlock_surface( $surface ); |
536 | |
537 | </pre> |
538 | <p>Surfaces that were previously locked using <code>SDL::Video::lock_surface</code> must be unlocked with <code>SDL::Video::unlock_surface</code>. Surfaces should |
539 | be unlocked as soon as possible. |
540 | <code>SDL::Video::unlock_surface</code> doesn't return anything.</p> |
541 | <p><strong>Note</strong>: Since 1.1.8, the surface locks are recursive. See <code>SDL::Video::lock_surface</code> for more information. </p> |
542 | |
543 | </div> |
544 | <h2 id="MUSTLOCK_surface">MUSTLOCK(surface)</h2> |
545 | <div id="MUSTLOCK_surface_CONTENT"> |
546 | <pre> int SDL::Video::MUSTLOCK( $surface ); |
547 | |
548 | </pre> |
549 | <p><code>MUSTLOCK</code> returns <code>0</code> if the surface does not have to be locked during pixel operations, otherwise <code>1</code>.</p> |
550 | |
551 | </div> |
552 | <h1 id="Screen_Updating_Functions">Screen Updating Functions</h1><p><a href="#TOP" class="toplink">Top</a></p> |
553 | <div id="Screen_Updating_Functions_CONTENT"> |
554 | |
555 | </div> |
556 | <h2 id="set_clip_rect_surface_rect">set_clip_rect(surface,rect)</h2> |
557 | <div id="set_clip_rect_surface_rect_CONTENT"> |
558 | <p>Sets the clipping rectangle for the given SDL::surface. When this surface is the destination of a blit, only the area within the clip |
559 | rectangle will be drawn into. |
560 | The rectangle pointed to by rect will be clipped to the edges of the surface so that the clip rectangle for a surface can never fall |
561 | outside the edges of the surface. |
562 | If rect is NULL the clipping rectangle will be set to the full size of the surface. |
563 | SDL::set_clip_rect doesn't returns anything.</p> |
564 | |
565 | </div> |
566 | <h2 id="get_clip_rect_surface_rect">get_clip_rect(surface,rect)</h2> |
567 | <div id="get_clip_rect_surface_rect_CONTENT"> |
568 | <p>Gets the clipping rectangle for the given SDL::surface. When this surface is the destination of a blit, only the area within the clip |
569 | rectangle is drawn into. |
570 | The rectangle pointed to by rect will be filled with the clipping rectangle of the surface. |
571 | SDL::get_clip_rect doesn't returns anything;</p> |
572 | |
573 | |
574 | |
575 | |
576 | |
577 | </div> |
578 | <h2 id="blit_surface_src_src_rect_dest_dest_">blit_surface(src,src_rect,dest,dest_rect)</h2> |
579 | <div id="blit_surface_src_src_rect_dest_dest_-2"> |
580 | <p>This performs a fast blit from the given source SDL::surface to the given destination SDL::surface. |
581 | The width and height in srcrect determine the size of the copied rectangle. Only the position is used in the dstrect (the width and height |
582 | are ignored). Blits with negative dstrect coordinates will be clipped properly. |
583 | If srcrect is NULL, the entire surface is copied. If dstrect is NULL, then the destination position (upper left corner) is (0, 0). |
584 | The final blit rectangle is saved in dstrect after all clipping is performed (srcrect is not modified). |
585 | The blit function should not be called on a locked surface. I.e. when you use your own drawing functions you may need to lock a surface, |
586 | but this is not the case with SDL::blit_surface. Like most surface manipulation functions in SDL, it should not be used together with OpenGL.</p> |
587 | <p>The results of blitting operations vary greatly depending on whether SDL_SRCALPHA is set or not. See SDL::set_alpha for an explanation of |
588 | how this affects your results. Colorkeying and alpha attributes also interact with surface blitting. |
589 | SDL::blit_surface doesn't returns anything.</p> |
590 | |
591 | </div> |
162a0989 |
592 | <h2 id="update_rect_surface_x_y_width_height">update_rect(surface,x,y,width,height)</h2> |
593 | <div id="update_rect_surface_x_y_width_height-2"> |
096d8dc8 |
594 | <pre> update_rect( $surface, $left, $top, $width, $height ); |
595 | |
596 | </pre> |
162a0989 |
597 | <p>Makes sure the given area is updated on the given screen. |
598 | The rectangle must be confined within the screen boundaries because there's no clipping. |
599 | update_rect doesn't returns any value.</p> |
096d8dc8 |
600 | <p><strong>Note</strong>: This function should not be called while screen is locked by <a href="#lock_surface_surface">SDL::Video::lock_surface</a></p> |
601 | <p><strong>Note2</strong>: If <code>x</code>, <code>y</code>, <code>width</code> and <code>height</code> are all equal to 0, <code>update_rect</code> will update the entire screen. </p> |
602 | <p>For an example see <a href="#SYNOPSIS">SYNOPSIS</a></p> |
162a0989 |
603 | |
604 | </div> |
605 | <h2 id="update_rects_surface_rects">update_rects(surface,rects) </h2> |
606 | <div id="update_rects_surface_rects_CONTENT"> |
096d8dc8 |
607 | <pre> update_rects( $surface, @rects ); |
608 | |
609 | </pre> |
162a0989 |
610 | <p>Makes sure the given list of rectangles is updated on the given screen. |
611 | The rectangle must be confined within the screen boundaries because there's no clipping. |
096d8dc8 |
612 | <code>update_rects</code> doesn't returns any value.</p> |
613 | <p><strong>Note</strong>: This function should not be called while screen is locked by <a href="#lock_surface_surface">SDL::Video::lock_surface</a>.</p> |
614 | <p>Example:</p> |
615 | <pre> use SDL; |
616 | use SDL::Video; |
617 | use SDL::Surface; |
618 | use SDL::Rect; |
619 | |
620 | # the size of the window box or the screen resolution if fullscreen |
621 | my $screen_width = 800; |
622 | my $screen_height = 600; |
623 | |
624 | SDL::init(SDL_INIT_VIDEO); |
625 | |
626 | # setting video mode |
627 | my $screen_surface = SDL::Video::set_video_mode($screen_width, $screen_height, 32, SDL_SWSURFACE); |
628 | |
629 | # drawing the whole screen blue |
630 | my $mapped_color = SDL::Video::map_RGB($screen_surface->format(), 0, 0, 255); # blue |
631 | SDL::Video::fill_rect($screen_surface, |
632 | SDL::Rect->new(0, 0, $screen_width, $screen_height), |
633 | $mapped_color); |
634 | |
635 | my @rects = (); |
636 | push(@rects, SDL::Rect->new(200, 0, 400, 600)); |
637 | push(@rects, SDL::Rect->new( 0, 150, 800, 300)); |
638 | |
639 | # updating parts of the screen (should look like a cross) |
640 | SDL::Video::update_rects($screen_surface, @rects); |
641 | |
642 | sleep(2); |
643 | |
644 | SDL::quit(); |
645 | |
646 | </pre> |
162a0989 |
647 | |
648 | </div> |
649 | <h2 id="flip_surface">flip(surface)</h2> |
650 | <div id="flip_surface_CONTENT"> |
904171e2 |
651 | <pre> $flip = SDL::Video::flip( $screen_surface ); |
652 | |
653 | </pre> |
162a0989 |
654 | <p>On hardware that supports double-buffering, this function sets up a flip and returns. |
655 | The hardware will wait for vertical retrace, and then swap video buffers before the next video surface blit or lock will return. |
904171e2 |
656 | On hardware that doesn't support double-buffering or if <code>SDL_SWSURFACE</code> was set, this is equivalent to calling |
657 | <code>SDL::Video::update_rect( $screen, 0, 0, 0, 0 )</code>.</p> |
7067312b |
658 | <p>A software screen surface is also updated automatically when parts of a SDL window are redrawn, caused by overlapping windows or by |
659 | restoring from an iconified state. As a result there is no proper double buffer behavior in windowed mode for a software screen, in |
660 | contrast to a full screen software mode.</p> |
904171e2 |
661 | <p>The <code>SDL_DOUBLEBUF</code> flag must have been passed to <code>SDL::Video::set_video_mode</code>, when setting the video mode for this function to |
662 | perform hardware flipping.</p> |
663 | <p><code>flip</code> returns <code>0</code> on success or <code>-1</code> on error.</p> |
664 | <p><strong>Note</strong>: If you want to swap the buffers of an initialized OpenGL context, use the function <code>SDL::Video::GL_swap_buffers</code> instead. </p> |
665 | <p>Example:</p> |
666 | <pre> use SDL; |
667 | use SDL::Video; |
668 | use SDL::Surface; |
669 | |
670 | # the size of the window box or the screen resolution if fullscreen |
671 | my $screen_width = 800; |
672 | my $screen_height = 600; |
673 | |
674 | SDL::init(SDL_INIT_VIDEO); |
675 | |
676 | # setting video mode |
677 | my $screen_surface = SDL::Video::set_video_mode($screen_width, $screen_height, 32, SDL_DOUBLEBUF|SDL_FULLSCREEN); |
678 | |
679 | # do some video operations here |
680 | |
681 | # doing page flipping |
682 | unless( SDL::Video::flip($screen_surface) == 0 ) |
683 | { |
684 | printf( STDERR "failed to swap buffers: %s\n", SDL::get_error() ); |
685 | } |
686 | |
687 | SDL::quit(); |
688 | |
689 | </pre> |
162a0989 |
690 | |
691 | </div> |
b968d0e8 |
692 | <h1 id="Palette_Color_and_Pixel_Functions">Palette, Color and Pixel Functions</h1><p><a href="#TOP" class="toplink">Top</a></p> |
693 | <div id="Palette_Color_and_Pixel_Functions_CO"> |
694 | |
695 | </div> |
162a0989 |
696 | <h2 id="set_colors_surface_start_colors">set_colors(surface,start,colors)</h2> |
697 | <div id="set_colors_surface_start_colors_CONT"> |
904171e2 |
698 | <pre> $set_colors = SDL::Video::set_colors( $surface, $start, $color1, $color2, ... ) |
699 | |
700 | </pre> |
162a0989 |
701 | <p>Sets a portion of the colormap for the given 8-bit surface. </p> |
702 | <p>When surface is the surface associated with the current display, the display colormap will be updated with the requested colors. |
904171e2 |
703 | If <code>SDL_HWPALETTE</code> was set in <code>SDL::Video::set_video_mode</code> flags, <code>SDL::Video::set_colors</code> will always return 1, and the palette is |
704 | guaranteed to be set the way you desire, even if the window colormap has to be warped or run under emulation. |
705 | The color components of a <a href="/SDL-Color.html">SDL::Color</a> structure are 8-bits in size, giving you a total of 2563 = 16777216 colors. |
706 | Palettized (8-bit) screen surfaces with the <code>SDL_HWPALETTE</code> flag have two palettes, a logical palette that is used for mapping blits to/from |
7067312b |
707 | the surface and a physical palette (that determines how the hardware will map the colors to the display). |
904171e2 |
708 | <code>SDL::Video::set_colors</code> modifies both palettes (if present), and is equivalent to calling <code>SDL::Video::set_palette</code> with the flags set to |
709 | ( <code>SDL_LOGPAL | SDL_PHYSPAL</code> ). </p> |
710 | <p>If <code>surface</code> is not a palettized surface, this function does nothing, returning 0. |
711 | If all of the colors were set as passed to <code>SDL::Video::set_colors</code>, it will return 1. |
7067312b |
712 | If not all the color entries were set exactly as given, it will return 0, and you should look at the surface palette to determine the |
713 | actual color palette.</p> |
162a0989 |
714 | |
715 | </div> |
716 | <h2 id="set_palette_surface_flags_start_colo">set_palette(surface,flags,start,colors)</h2> |
717 | <div id="set_palette_surface_flags_start_colo-2"> |
904171e2 |
718 | <pre> $set_palette = set_palette( $surface, $flags, $start, $color1, $color2, ... ); |
719 | |
720 | </pre> |
162a0989 |
721 | <p>Sets a portion of the palette for the given 8-bit surface.</p> |
904171e2 |
722 | <p>Palettized (8-bit) screen surfaces with the <code>SDL_HWPALETTE</code> flag have two palettes, a logical palette that is used for mapping blits to/from |
7067312b |
723 | the surface and a physical palette (that determines how the hardware will map the colors to the display). |
904171e2 |
724 | Non screen surfaces have a logical palette only. <code>SDL::Video::blit</code> always uses the logical palette when blitting surfaces (if it has to |
7067312b |
725 | convert between surface pixel formats). Because of this, it is often useful to modify only one or the other palette to achieve various |
726 | special color effects (e.g., screen fading, color flashes, screen dimming).</p> |
904171e2 |
727 | <p>This function can modify either the logical or physical palette by specifying <code>SDL_LOGPAL</code> or <code>SDL_PHYSPAL</code> the in the flags parameter.</p> |
162a0989 |
728 | <p>When surface is the surface associated with the current display, the display colormap will be updated with the requested colors. |
904171e2 |
729 | If <code>SDL_HWPALETTE</code> was set in <code>SDL::Video::set_video_mode</code> flags, <code>SDL::Video::set_palette</code> will always return 1, and the palette is |
730 | guaranteed to be set the way you desire, even if the window colormap has to be warped or run under emulation. |
731 | The color components of a <code>SDL::Color</code> structure are 8-bits in size, giving you a total of 2563 = 16777216 colors. </p> |
732 | <p>If <code>surface</code> is not a palettized surface, this function does nothing, returning <code>0</code>. If all of the colors were set as passed to <code>set_palette</code>, |
733 | it will return <code>1</code>. If not all the color entries were set exactly as given, it will return <code>0</code>, and you should look at the surface palette |
7067312b |
734 | to determine the actual color palette.</p> |
162a0989 |
735 | |
736 | </div> |
737 | <h2 id="set_gamma_r_g_b">set_gamma(r,g,b)</h2> |
738 | <div id="set_gamma_r_g_b_CONTENT"> |
904171e2 |
739 | <pre> $set_gamma = SDL::Video::set_gamma( $red_gamma, $green_gamma, $blue_gamma ); |
740 | |
741 | </pre> |
162a0989 |
742 | <p>Sets the "gamma function" for the display of each color component. Gamma controls the brightness/contrast of colors displayed on the screen. |
743 | A gamma value of 1.0 is identity (i.e., no adjustment is made).</p> |
7067312b |
744 | <p>This function adjusts the gamma based on the "gamma function" parameter, you can directly specify lookup tables for gamma adjustment |
745 | with SDL::set_gamma_ramp.</p> |
904171e2 |
746 | <p><strong>Note</strong>: Not all display hardware is able to change gamma.</p> |
747 | <p><code>SDL::Video::set_gamma</code> returns <code>-1</code> on error.</p> |
748 | <p><strong>Warning</strong>: Under Linux (X.org Gnome and Xfce), gamma settings affects the entire display (including the desktop)! </p> |
749 | <p>Example:</p> |
750 | <pre> use SDL; |
751 | use SDL::Video; |
752 | use SDL::Surface; |
753 | use SDL::Rect; |
754 | use Time::HiRes qw( usleep ); |
755 | |
756 | # the size of the window box or the screen resolution if fullscreen |
757 | my $screen_width = 800; |
758 | my $screen_height = 600; |
759 | |
760 | SDL::init(SDL_INIT_VIDEO); |
761 | |
762 | # setting video mode |
763 | my $screen_surface = SDL::Video::set_video_mode($screen_width, $screen_height, 32, SDL_SWSURFACE); |
764 | |
765 | # drawing something somewhere |
766 | my $mapped_color = SDL::Video::map_RGB($screen_surface->format(), 128, 128, 128); # gray |
767 | SDL::Video::fill_rect($screen_surface, |
768 | SDL::Rect->new($screen_width / 4, $screen_height / 4, $screen_width / 2, $screen_height / 2), |
769 | $mapped_color); |
770 | |
771 | # update the whole screen |
772 | SDL::Video::update_rect($screen_surface, 0, 0, $screen_width, $screen_height); |
773 | |
774 | usleep(500000); |
775 | |
776 | for(1..20) |
777 | { |
778 | SDL::Video::set_gamma( 1 - $_ / 20, 1, 1 ); |
779 | usleep(40000); |
780 | } |
781 | |
782 | for(1..20) |
783 | { |
784 | SDL::Video::set_gamma( $_ / 20, 1, 1 ); |
785 | usleep(40000); |
786 | } |
787 | |
788 | SDL::Video::set_gamma( 1, 1, 1 ); |
789 | |
790 | usleep(500000); |
791 | |
792 | SDL::quit(); |
793 | |
794 | </pre> |
162a0989 |
795 | |
796 | </div> |
904171e2 |
797 | <h2 id="get_gamma_ramp_rt_gt_bt">get_gamma_ramp(rt,gt,bt)</h2> |
798 | <div id="get_gamma_ramp_rt_gt_bt_CONTENT"> |
799 | <pre> $get_gamma_ramp = SDL::Video::get_gamma_ramp( \@red_table, \@green_table, \@blue_table ); |
800 | |
801 | </pre> |
162a0989 |
802 | <p>Gets the gamma translation lookup tables currently used by the display. Each table is an array of 256 Uint16 values. |
803 | SDL::get_gamma_ramp returns -1 on error.</p> |
904171e2 |
804 | <pre> use SDL; |
805 | use SDL::Video; |
806 | |
807 | SDL::init(SDL_INIT_VIDEO); |
808 | |
809 | my (@red, @green, @blue); |
810 | |
811 | my $ret = SDL::Video::get_gamma_ramp( \@red, \@green, \@blue ); |
812 | |
813 | if( -1 == $ret ) |
814 | { |
815 | print( "an error occoured" ); |
816 | } |
817 | else |
818 | { |
819 | printf( "for gamma = 1.0: red=0x%04X, green=0x%04X, blue=0x%04X\n", $red[255], $green[255], $blue[255] ); |
820 | printf( "for gamma = 0.5: red=0x%04X, green=0x%04X, blue=0x%04X\n", $red[127], $green[127], $blue[127] ); |
821 | printf( "for gamma = 0.0: red=0x%04X, green=0x%04X, blue=0x%04X\n", $red[0], $green[0], $blue[0] ); |
822 | } |
823 | |
824 | SDL::quit(); |
825 | |
826 | </pre> |
162a0989 |
827 | |
828 | </div> |
829 | <h2 id="set_gamma_ramp_rt_gt_bt">set_gamma_ramp(rt,gt,bt)</h2> |
830 | <div id="set_gamma_ramp_rt_gt_bt_CONTENT"> |
3774ca11 |
831 | <pre> $set_gamma_ramp = SDL::Video::set_gamma_ramp( \@red_table, \@green_table, \@blue_table ); |
832 | |
833 | </pre> |
834 | <p>Sets the gamma lookup tables for the display for each color component. Each table is an array ref of 256 Uint16 values, representing a |
7067312b |
835 | mapping between the input and output for that channel. |
162a0989 |
836 | The input is the index into the array, and the output is the 16-bit gamma value at that index, scaled to the output color precision. |
837 | You may pass NULL to any of the channels to leave them unchanged.</p> |
7067312b |
838 | <p>This function adjusts the gamma based on lookup tables, you can also have the gamma calculated based on a "gamma function" parameter |
3774ca11 |
839 | with <code>SDL::Video::set_gamma</code>.</p> |
162a0989 |
840 | <p>Not all display hardware is able to change gamma. |
3774ca11 |
841 | <code>SDL::Video::set_gamma_ramp</code> returns <code>-1</code> on error (or if gamma adjustment is not supported).</p> |
842 | <p>Example:</p> |
843 | <pre> use SDL; |
844 | use SDL::Video; |
845 | |
846 | SDL::init(SDL_INIT_VIDEO); |
847 | |
848 | my (@red, @green, @blue); |
849 | |
850 | my $ret = SDL::Video::get_gamma_ramp( \@red, \@green, \@blue ); |
851 | |
852 | $red[127] = 0xFF00; |
853 | |
854 | $ret = SDL::Video::set_gamma_ramp( \@red, \@green, \@blue ); |
855 | |
856 | $ret = SDL::Video::get_gamma_ramp( \@red, \@green, \@blue ); |
857 | |
858 | if( -1 == $ret ) |
859 | { |
860 | print( "an error occoured" ); |
861 | } |
862 | else |
863 | { |
864 | printf( "for gamma = 1.0: red=0x%04X, green=0x%04X, blue=0x%04X\n", $red[255], $green[255], $blue[255] ); |
865 | printf( "for gamma = 0.5: red=0x%04X, green=0x%04X, blue=0x%04X\n", $red[127], $green[127], $blue[127] ); |
866 | printf( "for gamma = 0.0: red=0x%04X, green=0x%04X, blue=0x%04X\n", $red[0], $green[0], $blue[0] ); |
867 | } |
868 | |
869 | SDL::quit(); |
870 | |
871 | </pre> |
162a0989 |
872 | |
873 | </div> |
874 | <h2 id="map_RGB_pixel_format_r_g_b">map_RGB(pixel_format,r,g,b)</h2> |
875 | <div id="map_RGB_pixel_format_r_g_b_CONTENT"> |
3774ca11 |
876 | <pre> $pixel = SDL::Video::map_RGB( $pixel_format, $r, $g, $b ); |
877 | |
878 | </pre> |
879 | <p>Maps the RGB color value to the specified <a href="/SDL-PixelFormat.html">SDL::PixelFormat</a> and returns the pixel value as a 32-bit int. |
162a0989 |
880 | If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned. |
881 | If the specified pixel format has an alpha component it will be returned as all 1 bits (fully opaque). </p> |
3774ca11 |
882 | <p><code>SDL::Video::map_RGB</code> returns a pixel value best approximating the given RGB color value for a given pixel format. |
883 | If the <a href="/SDL-PixelFormat.html">SDL::PixelFormat</a>'s bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored |
7067312b |
884 | (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).</p> |
3774ca11 |
885 | <pre> use SDL; |
886 | use SDL::Video; |
887 | use SDL::PixelFormat; |
888 | use SDL::Surface; |
889 | |
890 | SDL::init(SDL_INIT_VIDEO); |
891 | |
892 | my $screen_surface = SDL::Video::set_video_mode(640, 480, 16, SDL_SWSURFACE); |
893 | # ^-- 16 bits per pixel |
894 | |
895 | $r = 0x9C; |
896 | $g = 0xDC; |
897 | $b = 0x67; |
898 | |
899 | printf( "for 24bpp it is: 0x%02X 0x%02X 0x%02X\n", $r, $g, $b); |
900 | |
901 | my $_16bit = SDL::Video::map_RGB( $screen_surface->format, $r, $g, $b ); |
902 | |
903 | # 16bpp is 5 bits red, 6 bits green and 5 bits blue |
b968d0e8 |
904 | # we will obtain the values for each color and calculating them back to 24/32bit color system |
905 | ($r, $g, $b) = @{ SDL::Video::get_RGB( $screen_surface->format, $_16bit ) }; |
3774ca11 |
906 | |
907 | printf( "for 16bpp it is: 0x%02X 0x%02X 0x%02X\n", $r, $g, $b ); |
908 | |
b968d0e8 |
909 | # so color #9CDC67 becomes #9CDF63 |
3774ca11 |
910 | |
911 | SDL::quit(); |
912 | |
913 | </pre> |
162a0989 |
914 | |
915 | </div> |
916 | <h2 id="map_RGBA_pixel_format_r_g_b_a">map_RGBA(pixel_format,r,g,b,a)</h2> |
917 | <div id="map_RGBA_pixel_format_r_g_b_a_CONTEN"> |
b968d0e8 |
918 | <pre> $pixel = SDL::Video::map_RGB( $pixel_format, $r, $g, $b, $a ); |
919 | |
920 | </pre> |
921 | <p>Maps the RGBA color value to the specified <a href="/SDL-PixelFormat.html">SDL::PixelFormat</a> and returns the pixel value as a 32-bit int. |
162a0989 |
922 | If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned. |
923 | If the specified pixel format has no alpha component the alpha value will be ignored (as it will be in formats with a palette). </p> |
924 | <p>A pixel value best approximating the given RGBA color value for a given pixel format. |
7067312b |
925 | If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., |
926 | with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).</p> |
162a0989 |
927 | |
928 | </div> |
929 | <h2 id="get_RGB_pixel_format_pixel">get_RGB(pixel_format,pixel)</h2> |
930 | <div id="get_RGB_pixel_format_pixel_CONTENT"> |
b968d0e8 |
931 | <pre> $rgb_array_ref = SDL::Video::get_RGB( $pixel_format, $pixel ); |
932 | |
933 | </pre> |
934 | <p>Returns RGB values from a pixel in the specified pixel format. The pixel is an integer (e.g. 16bit RGB565, 24/32bit RGB888). |
7067312b |
935 | This function uses the entire 8-bit [0..255] range when converting color components from pixel formats with less than 8-bits per RGB |
936 | component (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).</p> |
b968d0e8 |
937 | <p>For an example see <code>SDL::Video::map_RGB</code>.</p> |
162a0989 |
938 | |
939 | </div> |
940 | <h2 id="get_RGBA_pixel_format_pixel">get_RGBA(pixel_format,pixel)</h2> |
941 | <div id="get_RGBA_pixel_format_pixel_CONTENT"> |
b968d0e8 |
942 | <pre> $rgba_array_ref = SDL::Video::get_RGBA( $pixel_format, $pixel ); |
943 | |
944 | </pre> |
162a0989 |
945 | <p>Gets RGBA values from a pixel in the specified pixel format. |
7067312b |
946 | This function uses the entire 8-bit [0..255] range when converting color components from pixel formats with less than 8-bits per RGB |
947 | component (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).</p> |
162a0989 |
948 | <p>If the surface has no alpha component, the alpha will be returned as 0xff (100% opaque). </p> |
949 | |
950 | </div> |
3540cbee |
951 | <h1 id="GL_Methods">GL Methods</h1><p><a href="#TOP" class="toplink">Top</a></p> |
952 | <div id="GL_Methods_CONTENT"> |
953 | |
954 | </div> |
162a0989 |
955 | <h2 id="GL_load_library_path">GL_load_library(path)</h2> |
956 | <div id="GL_load_library_path_CONTENT"> |
957 | <p>If you wish, you may load the OpenGL library from the given path at runtime, this must be done before SDL::set_video_mode is called. |
7067312b |
958 | The path of the GL library is passed to SDL::GL_load_library and it returns 0 on success, or -1 on an error. You must then use |
959 | SDL::GL_get_proc_address to retrieve function pointers to GL functions. </p> |
960 | <p>SDL::GL_load_library returns 0 on success or -1 or error.</p> |
162a0989 |
961 | |
962 | </div> |
963 | <h2 id="GL_get_proc_address_proc">GL_get_proc_address(proc)</h2> |
964 | <div id="GL_get_proc_address_proc_CONTENT"> |
7067312b |
965 | <p>Returns the address of the GL function proc, or NULL if the function is not found. If the GL library is loaded at runtime, with |
966 | SDL::GL_load_library, then all GL functions must be retrieved this way. Usually this is used to retrieve function pointers to OpenGL |
967 | extensions. Note that this function needs an OpenGL context to function properly, so it should be called after SDL::set_video_mode |
968 | has been called (with the SDL_OPENGL flag).</p> |
969 | <p>OpenGL function pointers must be declared APIENTRY . This will ensure the proper calling convention is followed on platforms where this |
970 | matters (Win32) thereby avoiding stack corruption. In a Win32 build environment, APIENTRY should be defined as __stdcall. </p> |
162a0989 |
971 | <p>it returns undef if the function is not found.</p> |
972 | |
973 | </div> |
974 | <h2 id="GL_get_attribute_attr">GL_get_attribute(attr)</h2> |
975 | <div id="GL_get_attribute_attr_CONTENT"> |
7067312b |
976 | <p>It returns SDL/OpenGL attribute attr . This is useful after a call to SDL::set_video_mode to check whether your attributes have been set |
977 | as you expected. |
162a0989 |
978 | SDL::GL_get_attribute returns undef if the attribute is not found.</p> |
979 | |
980 | </div> |
981 | <h2 id="GL_set_attribute_attr_value">GL_set_attribute(attr,value)</h2> |
982 | <div id="GL_set_attribute_attr_value_CONTENT"> |
983 | <p>This function sets the given OpenGL attribute attr to value. The requested attributes will take effect after a call to SDL::set_video_mode. |
7067312b |
984 | You should use SDL::GL_get_attribute to check the values after a SDL::set_video_mode call, since the values obtained can differ from the |
985 | requested ones. |
162a0989 |
986 | See SDL_GLattr for the full list of available attributes. |
7067312b |
987 | SDL::GL_set_attribute returns 0 on success or -1 on error.</p> |
988 | <p>Note : The SDL_DOUBLEBUF flag is not required to enable double buffering when setting an OpenGL video mode. Double buffering is enabled |
989 | or disabled using the SDL_GL_DOUBLEBUFFER attribute. </p> |
162a0989 |
990 | |
991 | </div> |
992 | <h2 id="GL_swap_buffers">GL_swap_buffers</h2> |
993 | <div id="GL_swap_buffers_CONTENT"> |
994 | <p>Swap the OpenGL buffers, if double-buffering is supported. |
995 | SDL::GL_swap_buffers doesn't returns any value.</p> |
996 | |
997 | </div> |
998 | <h2 id="GL_attr_to_be_coded">GL_attr *** to be coded</h2> |
999 | <div id="GL_attr_to_be_coded_CONTENT"> |
1000 | |
1001 | |
1002 | |
1003 | |
1004 | |
1005 | </div> |
b1795fa6 |
1006 | <h1 id="Video_Overlay_Functions">Video Overlay Functions</h1><p><a href="#TOP" class="toplink">Top</a></p> |
1007 | <div id="Video_Overlay_Functions_CONTENT"> |
1008 | <p>see <a href="/SDL-Overlay.html">SDL::Overlay</a> </p> |
3540cbee |
1009 | |
1010 | </div> |
162a0989 |
1011 | <h2 id="lock_YUV_overlay_overlay">lock_YUV_overlay(overlay)</h2> |
1012 | <div id="lock_YUV_overlay_overlay_CONTENT"> |
1013 | <p>Much the same as <code>SDL::lock_surface</code>, SDL::lock_YUV_overlay locks the overlay for direct access to pixel data. |
7067312b |
1014 | It returns 0 on success or -1 on error.</p> |
162a0989 |
1015 | |
1016 | </div> |
1017 | <h2 id="unlock_YUV_overlay_overlay">unlock_YUV_overlay(overlay)</h2> |
1018 | <div id="unlock_YUV_overlay_overlay_CONTENT"> |
449a007b |
1019 | <p>The opposite to <code>SDL::lock_YUV_overlay</code>. Unlocks a previously locked overlay. An overlay must be unlocked before it can be displayed. |
7067312b |
1020 | It returns 0 on success or -1 on error.</p> |
162a0989 |
1021 | |
1022 | </div> |
1023 | <h2 id="display_YUV_overlay_overlay_dstrect">display_YUV_overlay(overlay,dstrect)</h2> |
1024 | <div id="display_YUV_overlay_overlay_dstrect_"> |
7067312b |
1025 | <p>Blit the overlay to the display surface specified when the overlay was created. The SDL::rect structure, dstrect, specifies a rectangle |
1026 | on the display where the overlay is drawn. The .x and .y fields of dstrect specify the upper left location in display coordinates. |
1027 | The overlay is scaled (independently in x and y dimensions) to the size specified by dstrect, and is optimized for 2x scaling</p> |
1028 | <p>It returns 0 on success or -1 on error.</p> |
162a0989 |
1029 | |
b968d0e8 |
1030 | </div> |
1031 | <h1 id="Window_Management_Functions">Window Management Functions</h1><p><a href="#TOP" class="toplink">Top</a></p> |
1032 | <div id="Window_Management_Functions_CONTENT"> |
162a0989 |
1033 | |
b968d0e8 |
1034 | </div> |
1035 | <h2 id="wm_set_caption_title_icon">wm_set_caption(title,icon)</h2> |
1036 | <div id="wm_set_caption_title_icon_CONTENT"> |
162a0989 |
1037 | |
b968d0e8 |
1038 | </div> |
1039 | <h2 id="wm_get_caption">wm_get_caption()</h2> |
1040 | <div id="wm_get_caption_CONTENT"> |
162a0989 |
1041 | |
b968d0e8 |
1042 | </div> |
1043 | <h2 id="wm_set_icon_icon">wm_set_icon(icon)</h2> |
1044 | <div id="wm_set_icon_icon_CONTENT"> |
1045 | |
1046 | </div> |
1047 | <h2 id="wm_grab_input_mode">wm_grab_input(mode)</h2> |
1048 | <div id="wm_grab_input_mode_CONTENT"> |
1049 | |
1050 | </div> |
1051 | <h2 id="wm_iconify_window">wm_iconify_window()</h2> |
1052 | <div id="wm_iconify_window_CONTENT"> |
1053 | |
1054 | </div> |
1055 | <h2 id="wm_toggle_fullscreen_surface">wm_toggle_fullscreen(surface)</h2> |
1056 | <div id="wm_toggle_fullscreen_surface_CONTENT"> |
162a0989 |
1057 | |
1058 | </div> |
1059 | <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p> |
1060 | <div id="SEE_ALSO_CONTENT"> |
1061 | |
1062 | </div> |
1063 | <h2 id="Category_Objects">Category Objects</h2> |
1064 | <div id="Category_Objects_CONTENT"> |
46beffd8 |
1065 | <p><a href="/SDL-Surface.html">SDL::Surface</a>, <a href="/SDL-Overlay.html">SDL::Overlay</a>, <a href="/SDL-Color.html">SDL::Color</a>, |
1066 | <a href="/SDL-Rect.html">SDL::Rect</a>, <a href="/SDL-Palette.html">SDL::Palette</a>, <a href="/SDL-PixelFormat.html">SDL::PixelFormat</a>, |
1067 | <a href="/SDL-VideoInfo.html">SDL::VideoInfo</a></p> |
162a0989 |
1068 | |
1069 | </div> |
1070 | </div> |