docs for surface
[sdlgit/SDL-Site.git] / pages / SDL-Video.html-inc
CommitLineData
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>
162a0989 7<li><a href="#DESCRIPTION">DESCRIPTION</a></li>
8<li><a href="#METHODS">METHODS</a>
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>
162a0989 18<li><a href="#update_rect_surface_x_y_width_height">update_rect(surface,x,y,width,height)</a></li>
19<li><a href="#update_rects_surface_rects">update_rects(surface,rects) </a></li>
20<li><a href="#flip_surface">flip(surface)</a></li>
21<li><a href="#set_colors_surface_start_colors">set_colors(surface,start,colors)</a></li>
22<li><a href="#set_palette_surface_flags_start_colo">set_palette(surface,flags,start,colors)</a></li>
23<li><a href="#set_gamma_r_g_b">set_gamma(r,g,b)</a></li>
24<li><a href="#get_gamma_ramp_rt_gt_bt_to_be_coded">get_gamma_ramp(rt,gt,bt) * to be coded</a></li>
25<li><a href="#set_gamma_ramp_rt_gt_bt">set_gamma_ramp(rt,gt,bt)</a></li>
26<li><a href="#map_RGB_pixel_format_r_g_b">map_RGB(pixel_format,r,g,b)</a></li>
27<li><a href="#map_RGBA_pixel_format_r_g_b_a">map_RGBA(pixel_format,r,g,b,a)</a></li>
28<li><a href="#get_RGB_pixel_format_pixel">get_RGB(pixel_format,pixel)</a></li>
29<li><a href="#get_RGBA_pixel_format_pixel">get_RGBA(pixel_format,pixel)</a></li>
30<li><a href="#create_RGB_surface_from">create_RGB_surface_from ***</a></li>
31<li><a href="#lock_surface_surface">lock_surface(surface)</a></li>
32<li><a href="#unlock_surface_surface">unlock_surface(surface)</a></li>
33<li><a href="#convert_surface_surface_format_flags">convert_surface(surface,format,flags)</a></li>
34<li><a href="#display_format">display_format</a></li>
35<li><a href="#display_format_alpha">display_format_alpha</a></li>
36<li><a href="#load_BMP_filename">load_BMP(filename)</a></li>
37<li><a href="#save_BMP_surface_filename">save_BMP(surface,filename)</a></li>
38<li><a href="#set_color_key_surface_flag_key">set_color_key(surface,flag,key)</a></li>
39<li><a href="#set_alpha_surface_flag_key">set_alpha(surface,flag,key)</a></li>
40<li><a href="#set_clip_rect_surface_rect">set_clip_rect(surface,rect)</a></li>
41<li><a href="#get_clip_rect_surface_rect">get_clip_rect(surface,rect)</a></li>
42<li><a href="#blit_surface_src_src_rect_dest_dest_">blit_surface(src,src_rect,dest,dest_rect)</a></li>
43<li><a href="#fill_rect_dest_dest_rect_pixel">fill_rect(dest,dest_rect,pixel)</a></li>
44<li><a href="#GL_load_library_path">GL_load_library(path)</a></li>
45<li><a href="#GL_get_proc_address_proc">GL_get_proc_address(proc)</a></li>
46<li><a href="#GL_get_attribute_attr">GL_get_attribute(attr)</a></li>
47<li><a href="#GL_set_attribute_attr_value">GL_set_attribute(attr,value)</a></li>
48<li><a href="#GL_swap_buffers">GL_swap_buffers</a></li>
49<li><a href="#GL_attr_to_be_coded">GL_attr *** to be coded</a></li>
50<li><a href="#lock_YUV_overlay_overlay">lock_YUV_overlay(overlay)</a></li>
51<li><a href="#unlock_YUV_overlay_overlay">unlock_YUV_overlay(overlay)</a></li>
52<li><a href="#display_YUV_overlay_overlay_dstrect">display_YUV_overlay(overlay,dstrect)</a></li>
53</ul>
54</li>
55<li><a href="#SEE_ALSO">SEE ALSO</a>
56<ul><li><a href="#Category_Objects">Category Objects</a>
57</li>
58</ul>
59</li>
60</ul><hr />
61<!-- INDEX END -->
62
63<h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
64<div id="NAME_CONTENT">
65<p>SDL::Video - Bindings to the video category in SDL API</p>
66
67</div>
bfdd9c2e 68<h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
69<div id="CATEGORY_CONTENT">
70<p>Core, Video</p>
162a0989 71
72</div>
73<h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
74<div id="DESCRIPTION_CONTENT">
75
76
77
78
79
80</div>
81<h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
82<div id="METHODS_CONTENT">
83
84</div>
85<h2 id="get_video_surface">get_video_surface</h2>
86<div id="get_video_surface_CONTENT">
cbc85b7f 87<p>It return the current SDL::Surface on succés or undef on error.
162a0989 88get_video_surface doesn't take any parameters.</p>
89
90</div>
91<h2 id="get_video_info">get_video_info</h2>
92<div id="get_video_info_CONTENT">
93<p>Returns a SDL::VideoInfo about the video hardware.
94It doesn't take any parameters.</p>
95
96</div>
97<h2 id="video_driver_name">video_driver_name</h2>
98<div id="video_driver_name_CONTENT">
99<p>Return the 1024 first char of name of the video driver.
100It doesn't take any parameters.</p>
101
102</div>
103<h2 id="list_modes_formats_flags">list_modes(formats,flags)</h2>
104<div id="list_modes_formats_flags_CONTENT">
105<p>Returns a pointer to an array of available screen dimensions for the given format and video flags,
106or it return undef if no modes are avalaibles.</p>
107
108</div>
109<h2 id="video_mode_ok_width_height_bpp_flags">video_mode_ok(width,height,bpp,flags)</h2>
110<div id="video_mode_ok_width_height_bpp_flags-2">
111<p>Checks to see if a particular video mode of the given width,height,bpp and flags is supported.
112It returns 0 if the mode is not supported at all, or the suggested bpp.</p>
113
114</div>
115<h2 id="set_video_mode_width_height_bpp_flag">set_video_mode(width,height,bpp,flags)</h2>
116<div id="set_video_mode_width_height_bpp_flag-2">
117<p>Sets up a video mode with the specified width, height, bits-per-pixel and flags.
cbc85b7f 118set_video_mode returns a SDL::Surface on succés or it returns undef on error, the error message is retrieved using <code>SDL::get_error</code>.</p>
162a0989 119
120</div>
449a007b 121<h3 id="List_of_avalaibles_flags">List of avalaibles flags</h3>
162a0989 122<div id="List_of_avalaibles_flags_CONTENT">
449a007b 123<dl>
124 <dt>SDL_SWSURFACE</dt>
125 <dd>
126 <p>Create the video surface in system memory</p>
127 </dd>
128 <dt>SDL_HWSURFACE</dt>
129 <dd>
130 <p>Create the video surface in video memory</p>
131 </dd>
132 <dt>SDL_ASYNCBLIT</dt>
133 <dd>
134 <p>Enables the use of asynchronous updates of the display surface.
135This will usually slow down blitting on single CPU machines, but may provide a speed increase on SMP systems.</p>
136 </dd>
137 <dt>SDL_ANYFORMAT</dt>
138 <dd>
139 <p>Normally, if a video surface of the requested bits-per-pixel (bpp) is not available, SDL will emulate one with a shadow surface.
140Passing SDL_ANYFORMAT prevents this and causes SDL to use the video surface, regardless of its pixel depth.</p>
141 </dd>
142 <dt>SDL_HWPALETTE</dt>
143 <dd>
144 <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>
145 </dd>
146 <dt>SDL_DOUBLEBUF</dt>
147 <dd>
148 <p>Enable hardware double buffering; only valid with SDL_HWSURFACE. Calling SDL::flip will flip the buffers and update the screen.
149All drawing will take place on the surface that is not displayed at the moment.
150If double buffering could not be enabled then SDL_Flip will just perform a SDL::update_rect on the entire screen.</p>
151 </dd>
152 <dt>SDL_FULLSCREEN</dt>
153 <dd>
154 <p>SDL will attempt to use a fullscreen mode. If a hardware resolution change is not possible (for whatever reason),
155the next higher resolution will be used and the display window centered on a black background.</p>
156 </dd>
157 <dt>SDL_OPENGL</dt>
158 <dd>
159 <p>Create an OpenGL rendering context. You should have previously set OpenGL video attributes with SDL::gl_setattribute.</p>
160 </dd>
161 <dt>SDL_OPENGLBLIT</dt>
162 <dd>
163 <p>Create an OpenGL rendering context, like above, but allow normal blitting operations.
164The screen (2D) surface may have an alpha channel, and SDL::update_rects must be used for updating changes to the screen surface.
165NOTE: This option is kept for compatibility only, and will be removed in next versions. Is not recommended for new code.</p>
166 </dd>
167 <dt>SDL_RESIZABLE</dt>
168 <dd>
169 <p>Create a resizable window.
170When the window is resized by the user a SDL_VIDEORESIZE event is generated and SDL::set_video_mode can be called again with the new size.</p>
171
172
173
174
175 </dd>
176 <dt>SDL_NOFRAME</dt>
177 <dd>
178 <p>If possible, SDL_NOFRAME causes SDL to create a window with no title bar or frame decoration.
179Fullscreen modes automatically have this flag set.</p>
180 </dd>
181</dl>
162a0989 182<p>Note 1: Use SDL_SWSURFACE if you plan on doing per-pixel manipulations, or blit surfaces with alpha channels, and require a high framerate. When you use hardware surfaces (by passing the flag SDL_HWSURFACE as parameter), SDL copies the surfaces from video memory to system memory 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, but receive a software surface because the video driver doesn't support hardware surface. Many platforms can only provide a hardware surface when using SDL_FULLSCREEN. The SDL_HWSURFACE flag is best used when the surfaces you'll be blitting can also be stored in video memory.</p>
183<p>Note 2: If you want to control the position on the screen when creating a windowed surface, you may do so by setting the environment variables SDL_VIDEO_CENTERED=center or SDL_VIDEO_WINDOW_POS=x,y. You can also set them via <code>SDL::putenv</code>.</p>
184<p>Note 3: This function should be called in the main thread of your application.</p>
185<p>User note 1: Some have found that enabling OpenGL attributes like SDL_GL_STENCIL_SIZE (the stencil buffer size) before the video mode has been set causes the application to simply ignore those attributes, while enabling attributes after the video mode has been set works fine.</p>
186<p>User note 2: Also note that, in Windows, setting the video mode resets the current OpenGL context. You must execute again the OpenGL initialization code (set the clear color or the shade model, or reload textures, for example) after calling SDL::set_video_mode. In Linux, however, it works fine, and the initialization code only needs to be executed after the first call to SDL::set_video_mode (although there is no harm in executing the initialization code after each call to SDL::set_video_mode, for example for a multiplatform application). </p>
187
188
189
190
191
192
193
194
195
196
197
198</div>
199<h2 id="update_rect_surface_x_y_width_height">update_rect(surface,x,y,width,height)</h2>
200<div id="update_rect_surface_x_y_width_height-2">
201<p>Makes sure the given area is updated on the given screen.
202The rectangle must be confined within the screen boundaries because there's no clipping.
203update_rect doesn't returns any value.</p>
204<p>Note : This function should not be called while screen is locked by SDL::lock_surface
205Note2 : If x, y, width and height are all equal to 0, SDL_UpdateRect will update the entire screen. </p>
206
207</div>
208<h2 id="update_rects_surface_rects">update_rects(surface,rects) </h2>
209<div id="update_rects_surface_rects_CONTENT">
210<p>Makes sure the given list of rectangles is updated on the given screen.
211The rectangle must be confined within the screen boundaries because there's no clipping.
212update_rects doesn't returns any value.</p>
213<p>Note : This function should not be called while screen is locked by SDL::lock_surface</p>
214
215</div>
216<h2 id="flip_surface">flip(surface)</h2>
217<div id="flip_surface_CONTENT">
218<p>On hardware that supports double-buffering, this function sets up a flip and returns.
219The hardware will wait for vertical retrace, and then swap video buffers before the next video surface blit or lock will return.
220On hardware that doesn't support double-buffering or if SDL_SWSURFACE was set, this is equivalent to calling SDL::update_rect(screen, 0, 0, 0, 0)</p>
221<p>A software screen surface is also updated automatically when parts of a SDL window are redrawn, caused by overlapping windows or by restoring from an iconified state. As a result there is no proper double buffer behavior in windowed mode for a software screen, in contrast to a full screen software mode.</p>
222<p>The SDL_DOUBLEBUF flag must have been passed to SDL::set_video_mode, when setting the video mode for this function to perform hardware flipping.
cbc85b7f 223flip returns 0 on succés or -1 on error.</p>
162a0989 224<p>Note : If you want to swap the buffers of an initialized OpenGL context, use the function SDL::gl_swap_buffers instead. </p>
225
226</div>
227<h2 id="set_colors_surface_start_colors">set_colors(surface,start,colors)</h2>
228<div id="set_colors_surface_start_colors_CONT">
229<p>Sets a portion of the colormap for the given 8-bit surface. </p>
230<p>When surface is the surface associated with the current display, the display colormap will be updated with the requested colors.
231If SDL_HWPALETTE was set in SDL::set_video_mode flags, SDL::set_colors will always return 1, and the palette is guaranteed to be set the way you desire, even if the window colormap has to be warped or run under emulation.
232The color components of a SDL::Color structure are 8-bits in size, giving you a total of 2563 = 16777216 colors.
233Palettized (8-bit) screen surfaces with the SDL_HWPALETTE flag have two palettes, a logical palette that is used for mapping blits to/from the surface and a physical palette (that determines how the hardware will map the colors to the display).
234SDL::SetColors modifies both palettes (if present), and is equivalent to calling SDL::SetPalette with the flags set to (SDL_LOGPAL | SDL_PHYSPAL). </p>
235<p>If surface is not a palettized surface, this function does nothing, returning 0.
236If all of the colors were set as passed to SDL::set_colors, it will return 1.
237If 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 actual color palette.</p>
238
239</div>
240<h2 id="set_palette_surface_flags_start_colo">set_palette(surface,flags,start,colors)</h2>
241<div id="set_palette_surface_flags_start_colo-2">
242<p>Sets a portion of the palette for the given 8-bit surface.</p>
243<p>Palettized (8-bit) screen surfaces with the SDL_HWPALETTE flag have two palettes, a logical palette that is used for mapping blits to/from the surface and a physical palette (that determines how the hardware will map the colors to the display).
244Non screen surfaces have a logical palette only. SDL::blit_surface always uses the logical palette when blitting surfaces (if it has to convert between surface pixel formats). Because of this, it is often useful to modify only one or the other palette to achieve various special color effects (e.g., screen fading, color flashes, screen dimming).</p>
245<p>This function can modify either the logical or physical palette by specifying SDL_LOGPAL or SDL_PHYSPAL the in the flags parameter.</p>
246<p>When surface is the surface associated with the current display, the display colormap will be updated with the requested colors.
247If SDL_HWPALETTE was set in SDL::set_video_mode flags, SDL::set_palette will always return 1, and the palette is guaranteed to be set the way you desire, even if the window colormap has to be warped or run under emulation.
248The color components of a SDL::Color structure are 8-bits in size, giving you a total of 2563 = 16777216 colors. </p>
249<p>If surface is not a palettized surface, this function does nothing, returning 0. If all of the colors were set as passed to SDL_SetPalette, it will return 1. 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 actual color palette.</p>
250
251</div>
252<h2 id="set_gamma_r_g_b">set_gamma(r,g,b)</h2>
253<div id="set_gamma_r_g_b_CONTENT">
254<p>Sets the &quot;gamma function&quot; for the display of each color component. Gamma controls the brightness/contrast of colors displayed on the screen.
255A gamma value of 1.0 is identity (i.e., no adjustment is made).</p>
256<p>This function adjusts the gamma based on the &quot;gamma function&quot; parameter, you can directly specify lookup tables for gamma adjustment with SDL::set_gamma_ramp.</p>
257<p>Not all display hardware is able to change gamma.
258SDL::set_gamma returns -1 on error.</p>
259<p>Warning: Under Linux (X.org Gnome and Xfce), gamma settings affects the entire display (including the desktop)! </p>
260
261</div>
262<h2 id="get_gamma_ramp_rt_gt_bt_to_be_coded">get_gamma_ramp(rt,gt,bt) * to be coded</h2>
263<div id="get_gamma_ramp_rt_gt_bt_to_be_coded_">
264<p>Gets the gamma translation lookup tables currently used by the display. Each table is an array of 256 Uint16 values.
265SDL::get_gamma_ramp returns -1 on error.</p>
266
267</div>
268<h2 id="set_gamma_ramp_rt_gt_bt">set_gamma_ramp(rt,gt,bt)</h2>
269<div id="set_gamma_ramp_rt_gt_bt_CONTENT">
270<p>Sets the gamma lookup tables for the display for each color component. Each table is an array of 256 Uint16 values, representing a mapping between the input and output for that channel.
271The 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.
272You may pass NULL to any of the channels to leave them unchanged.</p>
273<p>This function adjusts the gamma based on lookup tables, you can also have the gamma calculated based on a &quot;gamma function&quot; parameter with SDL::set_gamma.</p>
274<p>Not all display hardware is able to change gamma.
275SDL::set_gamma_ramp returns -1 on error.</p>
276
277</div>
278<h2 id="map_RGB_pixel_format_r_g_b">map_RGB(pixel_format,r,g,b)</h2>
279<div id="map_RGB_pixel_format_r_g_b_CONTENT">
280<p>Maps the RGB color value to the specified SDL::pixel_format and returns the pixel value as a 32-bit int.
281If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.
282If the specified pixel format has an alpha component it will be returned as all 1 bits (fully opaque). </p>
283<p>SDL::map_RGP returns a pixel value best approximating the given RGB color value for a given pixel format.
284If the SDL::pixel_format's bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (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>
285
286</div>
287<h2 id="map_RGBA_pixel_format_r_g_b_a">map_RGBA(pixel_format,r,g,b,a)</h2>
288<div id="map_RGBA_pixel_format_r_g_b_a_CONTEN">
289<p>Maps the RGBA color value to the specified SDL::pixel_format and returns the pixel value as a 32-bit int.
290If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.
291If the specified pixel format has no alpha component the alpha value will be ignored (as it will be in formats with a palette). </p>
292<p>A pixel value best approximating the given RGBA color value for a given pixel format.
293If 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., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).</p>
294
295</div>
296<h2 id="get_RGB_pixel_format_pixel">get_RGB(pixel_format,pixel)</h2>
297<div id="get_RGB_pixel_format_pixel_CONTENT">
298<p>Returns RGB values from a pixel in the specified pixel format.
299This function uses the entire 8-bit [0..255] range when converting color components from pixel formats with less than 8-bits per RGB component (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).</p>
300
301</div>
302<h2 id="get_RGBA_pixel_format_pixel">get_RGBA(pixel_format,pixel)</h2>
303<div id="get_RGBA_pixel_format_pixel_CONTENT">
304<p>Gets RGBA values from a pixel in the specified pixel format.
305This function uses the entire 8-bit [0..255] range when converting color components from pixel formats with less than 8-bits per RGB component (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).</p>
306<p>If the surface has no alpha component, the alpha will be returned as 0xff (100% opaque). </p>
307
308</div>
309<h2 id="create_RGB_surface_from">create_RGB_surface_from ***</h2>
310<div id="create_RGB_surface_from_CONTENT">
311<p>Creates an empty SDL::Surface from pixel data
312Allocate an empty surface (must be called after SDL::set_video_mode)
313If bitsPerPixel is 8 an empty palette is allocated for the surface, otherwise a 'packed-pixel' SDL::pixel_format is created using the [RGBA]mask's provided (see SDL::pixel_format). The flags specifies the type of surface that should be created, it is an OR'd combination of the following possible values. </p>
449a007b 314<dl>
315 <dt>SDL_SWSURFACE</dt>
316 <dd>
317 <p>SDL will create the surface in system memory.
318This improves the performance of pixel level access, however you may not be able to take advantage of some types of hardware blitting.</p>
319 </dd>
320 <dt>SDL_HWSURFACE</dt>
321 <dd>
322 <p>SDL will attempt to create the surface in video memory.
323This will allow SDL to take advantage of Video-&gt;Video blits (which are often accelerated).</p>
324 </dd>
325 <dt>SDL_SRCCOLORKEY</dt>
326 <dd>
327 <p>This flag turns on color keying for blits from this surface.
328If SDL_HWSURFACE is also specified and color keyed blits are hardware-accelerated, then SDL will attempt to place the surface in video memory.
329If the screen is a hardware surface and color keyed blits are hardware-accelerated then the SDL_HWSURFACE flag will be set.
330Use SDL_SetColorKey to set or clear this flag after surface creation.</p>
331 </dd>
332 <dt>SDL_SRCALPHA</dt>
333 <dd>
334 <p>This flag turns on alpha-blending for blits from this surface.
335If SDL_HWSURFACE is also specified and alpha-blending blits are hardware-accelerated,
336then the surface will be placed in video memory if possible.
337If the screen is a hardware surface and alpha-blending blits are hardware-accelerated then the SDL_HWSURFACE flag will be set.
338Use SDL_SetAlpha to set or clear this flag after surface creation.</p>
339 </dd>
340</dl>
162a0989 341
342
343
344
162a0989 345<p>[RGBA]mask are the bitmasks used to extract that colour from a pixel.
346For instance, Rmask being FF000000 means the red data is stored in the most significant byte.
347Using zeros for the RGB masks sets a default value, based on the depth. (e.g. SDL::create_RGB_surface(flags,w,h,32,0,0,0,0);).
348However, using zero for the Amask results in an Amask of 0.
349It returns a SDL::Surface on success or undef on error.
350Notes: If an alpha-channel is specified (that is, if Amask is nonzero), then the SDL_SRCALPHA flag is automatically set.
351You may remove this flag by calling SDL::set_alpha after surface creation.
352Also, if the SDL_HWSURFACE flag is set on the returned surface, its format might not match the requested format. </p>
353<p>Notes: Sometimes specifying an Alpha mask value could cause strange results.
354This can be worked around by setting the Amask parameter to 0, but still including the SDL_SRCALPHA flag, and then using SDL::set_alpha, also with the SDL_SRCALPHA flag. </p>
355
356</div>
357<h2 id="lock_surface_surface">lock_surface(surface)</h2>
358<div id="lock_surface_surface_CONTENT">
359<p>SDL::lock_surface sets up the given SDL::surface for directly accessing the pixels.
360Between calls to SDL::lock_surface and SDL::unlock_surface, you can write to and read from surface-&gt;pixels, using the pixel format stored in surface-&gt;format.
361Once you are done accessing the surface, you should use SDL::unlock_surface to release the lock.</p>
362<p>Not all surfaces require locking. If SDL::MUSTLOCK(surface) evaluates to 0, then reading and writing pixels to the surface can be performed at any time, and the pixel format of the surface will not change.
363No operating system or library calls should be made between the lock/unlock pairs, as critical system locks may be held during this time.
cbc85b7f 364SDL::lock_surface returns 0 on succés or -1 on error.</p>
162a0989 365<p>Note : 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 a matching unlock.</p>
366
367</div>
368<h2 id="unlock_surface_surface">unlock_surface(surface)</h2>
369<div id="unlock_surface_surface_CONTENT">
370<p>Surfaces that were previously locked using SDL::lock_surface must be unlocked with SDL::unlock_surface. Surfaces should be unlocked as soon as possible.
371SDL::unlock_surface doesn't return anything.</p>
372<p>Note : Since 1.1.8, the surface locks are recursive. See <code>SDL::lock_surface</code> for more information. </p>
373
374</div>
375<h2 id="convert_surface_surface_format_flags">convert_surface(surface,format,flags)</h2>
376<div id="convert_surface_surface_format_flags-2">
377<p>Creates a new SDL::surface of the specified SDL::pixel_format, and then copies and maps the given surface to it.
378It is also useful for making a copy of a surface.</p>
379<p>The flags parameter is passed to SDL::create_RGB_surface and has those semantics.
380This function is used internally by SDL::display_format.
381This function can only be called after SDL::init. </p>
cbc85b7f 382<p>it returns a SDL::surface on succés or undef on error.</p>
162a0989 383
384</div>
385<h2 id="display_format">display_format</h2>
386<div id="display_format_CONTENT">
387<p>Converts a surface to the display format </p>
388
389</div>
390<h2 id="display_format_alpha">display_format_alpha</h2>
391<div id="display_format_alpha_CONTENT">
392<p>Converts a surface to the display format </p>
393
394</div>
395<h2 id="load_BMP_filename">load_BMP(filename)</h2>
396<div id="load_BMP_filename_CONTENT">
397<p>Loads a SDL::surface from a named Windows BMP file.
cbc85b7f 398SDL::load_BMP returns a SDL::surface on succés or undef on error.</p>
162a0989 399<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>
400
401
402
403
404
405
406
407
408</div>
409<h2 id="save_BMP_surface_filename">save_BMP(surface,filename)</h2>
410<div id="save_BMP_surface_filename_CONTENT">
411<p>Saves the given SDL::Surface surface as a Windows BMP file named filename.
cbc85b7f 412it returns 0 on succés or -1 on error.</p>
162a0989 413
414</div>
415<h2 id="set_color_key_surface_flag_key">set_color_key(surface,flag,key)</h2>
416<div id="set_color_key_surface_flag_key_CONTE">
417<p>Sets the color key (transparent pixel) in a blittable surface and enables or disables RLE blit acceleration.</p>
418<p>RLE acceleration can substantially speed up blitting of images with large horizontal runs of transparent pixels (i.e., pixels that match the key value).
419The key must be of the same pixel format as the surface, SDL::map_RGB is often useful for obtaining an acceptable value.
420If flag is SDL_SRCCOLORKEY then key is the transparent pixel value in the source image of a blit.</p>
421<p>If flag is OR'd with SDL_RLEACCEL then the surface will be drawn using RLE acceleration when drawn with SDL::Blit_surface.
422The surface will actually be encoded for RLE acceleration the first time SDL::blit_surface or SDL::display_format is called on the surface.
423If flag is 0, this function clears any current color key. </p>
cbc85b7f 424<p>SDL::set_color_key returns 0 on succés or -1 on error.</p>
162a0989 425
426
427
428
429
430</div>
431<h2 id="set_alpha_surface_flag_key">set_alpha(surface,flag,key)</h2>
432<div id="set_alpha_surface_flag_key_CONTENT">
433<p>SDL::set_alpha is used for setting the per-surface alpha value and/or enabling and disabling alpha blending.</p>
434<p>The surface parameter specifies which SDL::surface whose alpha attributes you wish to adjust.
435flags is used to specify whether alpha blending should be used (SDL_SRCALPHA) and whether the surface should use RLE acceleration for blitting (SDL_RLEACCEL).
436flags can be an OR'd combination of these two options, one of these options or 0.
437If SDL_SRCALPHA is not passed as a flag then all alpha information is ignored when blitting the surface.
438The alpha parameter is the per-surface alpha value; a surface need not have an alpha channel to use per-surface alpha and blitting can still be accelerated with SDL_RLEACCEL.</p>
439<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>
440<p>Alpha affects surface blitting in the following ways: </p>
449a007b 441<dl>
442 <dt>RGBA-&gt;RGB with SDL_SRCALPHA</dt>
443 <dd>
444 <p>The source is alpha-blended with the destination, using the alpha channel.
445SDL_SRCCOLORKEY and the per-surface alpha are ignored.</p>
446 </dd>
447 <dt>RGBA-&gt;RGB without SDL_SRCALPHA</dt>
448 <dd>
449 <p>The RGB data is copied from the source. The source alpha channel and the per-surface alpha value are ignored.
450If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.</p>
451 </dd>
452 <dt>RGB-&gt;RGBA with SDL_SRCALPHA</dt>
453 <dd>
454 <p>The source is alpha-blended with the destination using the per-surface alpha value.
455If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.
456The alpha channel of the copied pixels is set to opaque.</p>
457 </dd>
458 <dt>RGB-&gt;RGBA without SDL_SRCALPHA</dt>
459 <dd>
460 <p>The RGB data is copied from the source and the alpha value of the copied pixels is set to opaque.
461If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.</p>
462 </dd>
463 <dt>RGBA-&gt;RGBA with SDL_SRCALPHA</dt>
464 <dd>
465 <p>The source is alpha-blended with the destination using the source alpha channel.
466The alpha channel in the destination surface is left untouched. SDL_SRCCOLORKEY is ignored.</p>
467 </dd>
468 <dt>RGBA-&gt;RGBA without SDL_SRCALPHA</dt>
469 <dd>
470 <p>The RGBA data is copied to the destination surface.
471If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.</p>
472 </dd>
473 <dt>RGB-&gt;RGB with SDL_SRCALPHA</dt>
474 <dd>
475 <p>The source is alpha-blended with the destination using the per-surface alpha value.
476If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.</p>
477 </dd>
478 <dt>RGB-&gt;RGB without SDL_SRCALPHA</dt>
479 <dd>
480 <p>The RGB data is copied from the source.
481If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.</p>
482 </dd>
483</dl>
162a0989 484<p>Note: When blitting, the presence or absence of SDL_SRCALPHA is relevant only on the source surface, not the destination.
485Note: Note that RGBA-&gt;RGBA blits (with SDL_SRCALPHA set) keep the alpha of the destination surface. This means that you cannot compose two arbitrary RGBA surfaces this way and get the result you would expect from &quot;overlaying&quot; them; the destination alpha will work as a mask.</p>
486<p>Note: Also note that per-pixel and per-surface alpha cannot be combined; the per-pixel alpha is always used if available. </p>
cbc85b7f 487<p>SDL::set_alpha returns 0 on succés or -1 on error.</p>
162a0989 488
489</div>
490<h2 id="set_clip_rect_surface_rect">set_clip_rect(surface,rect)</h2>
491<div id="set_clip_rect_surface_rect_CONTENT">
492<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 rectangle will be drawn into.
493The 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 outside the edges of the surface.
494If rect is NULL the clipping rectangle will be set to the full size of the surface.
495SDL::set_clip_rect doesn't returns anything.</p>
496
497</div>
498<h2 id="get_clip_rect_surface_rect">get_clip_rect(surface,rect)</h2>
499<div id="get_clip_rect_surface_rect_CONTENT">
500<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 rectangle is drawn into.
501The rectangle pointed to by rect will be filled with the clipping rectangle of the surface.
502SDL::get_clip_rect doesn't returns anything;</p>
503
504
505
506
507
508</div>
509<h2 id="blit_surface_src_src_rect_dest_dest_">blit_surface(src,src_rect,dest,dest_rect)</h2>
510<div id="blit_surface_src_src_rect_dest_dest_-2">
511<p>This performs a fast blit from the given source SDL::surface to the given destination SDL::surface.
512The width and height in srcrect determine the size of the copied rectangle. Only the position is used in the dstrect (the width and height are ignored). Blits with negative dstrect coordinates will be clipped properly.
513If srcrect is NULL, the entire surface is copied. If dstrect is NULL, then the destination position (upper left corner) is (0, 0).
514The final blit rectangle is saved in dstrect after all clipping is performed (srcrect is not modified).
515The 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, 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>
516<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 how this affects your results. Colorkeying and alpha attributes also interact with surface blitting.
517SDL::blit_surface doesn't returns anything.</p>
518
519</div>
520<h2 id="fill_rect_dest_dest_rect_pixel">fill_rect(dest,dest_rect,pixel)</h2>
521<div id="fill_rect_dest_dest_rect_pixel_CONTE">
522<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 will be filled with color.</p>
523<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.
524If the color value contains an alpha value then the destination is simply &quot;filled&quot; with that alpha information, no blending takes place.</p>
525<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 of the clip rectangle and the dstrect rectangle, and the dstrect rectangle will be modified to represent the area actually filled.</p>
526<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 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>
cbc85b7f 527<p>SDL::fill_rect returns 0 on succés or -1 on error.</p>
162a0989 528
529</div>
530<h2 id="GL_load_library_path">GL_load_library(path)</h2>
531<div id="GL_load_library_path_CONTENT">
532<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.
533The 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 SDL::GL_get_proc_address to retrieve function pointers to GL functions. </p>
cbc85b7f 534<p>SDL::GL_load_library returns 0 on succés or -1 or error.</p>
162a0989 535
536</div>
537<h2 id="GL_get_proc_address_proc">GL_get_proc_address(proc)</h2>
538<div id="GL_get_proc_address_proc_CONTENT">
539<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 SDL::GL_load_library, then all GL functions must be retrieved this way. Usually this is used to retrieve function pointers to OpenGL extensions. Note that this function needs an OpenGL context to function properly, so it should be called after SDL::set_video_mode has been called (with the SDL_OPENGL flag).</p>
540<p>OpenGL function pointers must be declared APIENTRY . This will ensure the proper calling convention is followed on platforms where this matters (Win32) thereby avoiding stack corruption. In a Win32 build environment, APIENTRY should be defined as __stdcall. </p>
541<p>it returns undef if the function is not found.</p>
542
543</div>
544<h2 id="GL_get_attribute_attr">GL_get_attribute(attr)</h2>
545<div id="GL_get_attribute_attr_CONTENT">
546<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 as you expected.
547SDL::GL_get_attribute returns undef if the attribute is not found.</p>
548
549</div>
550<h2 id="GL_set_attribute_attr_value">GL_set_attribute(attr,value)</h2>
551<div id="GL_set_attribute_attr_value_CONTENT">
552<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.
553You 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 requested ones.
554See SDL_GLattr for the full list of available attributes.
cbc85b7f 555SDL::GL_set_attribute returns 0 on succés or -1 on error.</p>
162a0989 556<p>Note : The SDL_DOUBLEBUF flag is not required to enable double buffering when setting an OpenGL video mode. Double buffering is enabled or disabled using the SDL_GL_DOUBLEBUFFER attribute. </p>
557
558</div>
559<h2 id="GL_swap_buffers">GL_swap_buffers</h2>
560<div id="GL_swap_buffers_CONTENT">
561<p>Swap the OpenGL buffers, if double-buffering is supported.
562SDL::GL_swap_buffers doesn't returns any value.</p>
563
564</div>
565<h2 id="GL_attr_to_be_coded">GL_attr *** to be coded</h2>
566<div id="GL_attr_to_be_coded_CONTENT">
567
568
569
570
571
572</div>
573<h2 id="lock_YUV_overlay_overlay">lock_YUV_overlay(overlay)</h2>
574<div id="lock_YUV_overlay_overlay_CONTENT">
575<p>Much the same as <code>SDL::lock_surface</code>, SDL::lock_YUV_overlay locks the overlay for direct access to pixel data.
cbc85b7f 576It returns 0 on succés or -1 on error.</p>
162a0989 577
578</div>
579<h2 id="unlock_YUV_overlay_overlay">unlock_YUV_overlay(overlay)</h2>
580<div id="unlock_YUV_overlay_overlay_CONTENT">
449a007b 581<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.
cbc85b7f 582It returns 0 on succés or -1 on error.</p>
162a0989 583
584</div>
585<h2 id="display_YUV_overlay_overlay_dstrect">display_YUV_overlay(overlay,dstrect)</h2>
586<div id="display_YUV_overlay_overlay_dstrect_">
587<p>Blit the overlay to the display surface specified when the overlay was created. The SDL::rect structure, dstrect, specifies a rectangle on the display where the overlay is drawn. The .x and .y fields of dstrect specify the upper left location in display coordinates. The overlay is scaled (independently in x and y dimensions) to the size specified by dstrect, and is optimized for 2x scaling</p>
cbc85b7f 588<p>It returns 0 on succés or -1 on error.</p>
162a0989 589
590
591
592
593
594</div>
595<h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
596<div id="SEE_ALSO_CONTENT">
597
598</div>
599<h2 id="Category_Objects">Category Objects</h2>
600<div id="Category_Objects_CONTENT">
46beffd8 601<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>,
602<a href="/SDL-Rect.html">SDL::Rect</a>, <a href="/SDL-Palette.html">SDL::Palette</a>, <a href="/SDL-PixelFormat.html">SDL::PixelFormat</a>,
603<a href="/SDL-VideoInfo.html">SDL::VideoInfo</a></p>
162a0989 604
605</div>
606</div>