upd vid
[sdlgit/SDL-Site.git] / pages / SDL-Video.html-inc
index a4d04aa..1fba8b2 100644 (file)
@@ -5,7 +5,7 @@
 <ul><li><a href="#NAME">NAME</a></li>
 <li><a href="#CATEGORY">CATEGORY</a></li>
 <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
-<li><a href="#METHODS">METHODS</a>
+<li><a href="#Core_Functions">Core Functions</a>
 <ul><li><a href="#get_video_surface">get_video_surface</a></li>
 <li><a href="#get_video_info">get_video_info</a></li>
 <li><a href="#video_driver_name">video_driver_name</a></li>
 <li><a href="#set_colors_surface_start_colors">set_colors(surface,start,colors)</a></li>
 <li><a href="#set_palette_surface_flags_start_colo">set_palette(surface,flags,start,colors)</a></li>
 <li><a href="#set_gamma_r_g_b">set_gamma(r,g,b)</a></li>
-<li><a href="#get_gamma_ramp_rt_gt_bt_to_be_coded">get_gamma_ramp(rt,gt,bt) * to be coded</a></li>
+<li><a href="#get_gamma_ramp_rt_gt_bt">get_gamma_ramp(rt,gt,bt)</a></li>
 <li><a href="#set_gamma_ramp_rt_gt_bt">set_gamma_ramp(rt,gt,bt)</a></li>
 <li><a href="#map_RGB_pixel_format_r_g_b">map_RGB(pixel_format,r,g,b)</a></li>
 <li><a href="#map_RGBA_pixel_format_r_g_b_a">map_RGBA(pixel_format,r,g,b,a)</a></li>
 <li><a href="#get_RGB_pixel_format_pixel">get_RGB(pixel_format,pixel)</a></li>
 <li><a href="#get_RGBA_pixel_format_pixel">get_RGBA(pixel_format,pixel)</a></li>
-<li><a href="#create_RGB_surface_from">create_RGB_surface_from ***</a></li>
 <li><a href="#lock_surface_surface">lock_surface(surface)</a></li>
 <li><a href="#unlock_surface_surface">unlock_surface(surface)</a></li>
 <li><a href="#convert_surface_surface_format_flags">convert_surface(surface,format,flags)</a></li>
 <li><a href="#get_clip_rect_surface_rect">get_clip_rect(surface,rect)</a></li>
 <li><a href="#blit_surface_src_src_rect_dest_dest_">blit_surface(src,src_rect,dest,dest_rect)</a></li>
 <li><a href="#fill_rect_dest_dest_rect_pixel">fill_rect(dest,dest_rect,pixel)</a></li>
-<li><a href="#GL_load_library_path">GL_load_library(path)</a></li>
+</ul>
+</li>
+<li><a href="#GL_Methods">GL Methods</a>
+<ul><li><a href="#GL_load_library_path">GL_load_library(path)</a></li>
 <li><a href="#GL_get_proc_address_proc">GL_get_proc_address(proc)</a></li>
 <li><a href="#GL_get_attribute_attr">GL_get_attribute(attr)</a></li>
 <li><a href="#GL_set_attribute_attr_value">GL_set_attribute(attr,value)</a></li>
 <li><a href="#GL_swap_buffers">GL_swap_buffers</a></li>
 <li><a href="#GL_attr_to_be_coded">GL_attr *** to be coded</a></li>
-<li><a href="#lock_YUV_overlay_overlay">lock_YUV_overlay(overlay)</a></li>
+</ul>
+</li>
+<li><a href="#a_href_SDL_Overlay_html_SDL_Overlay_"><a href="/SDL-Overlay.html">SDL::Overlay</a> Functions</a>
+<ul><li><a href="#lock_YUV_overlay_overlay">lock_YUV_overlay(overlay)</a></li>
 <li><a href="#unlock_YUV_overlay_overlay">unlock_YUV_overlay(overlay)</a></li>
 <li><a href="#display_YUV_overlay_overlay_dstrect">display_YUV_overlay(overlay,dstrect)</a></li>
 </ul>
@@ -58,7 +63,7 @@
 </ul>
 </li>
 </ul><hr />
-<!-- INDEX END -->
+<!-- INDEX END --><a href="assets/Video.png" target="_blank"><img src="assets/Video.png" style="height: 160px" alt="Video.png"/></a><hr />
 
 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
 <div id="NAME_CONTENT">
 
  sleep(5); # just to have time to see it
 
+ SDL::quit();
+
 </pre>
 
 </div>
-<h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
-<div id="METHODS_CONTENT">
+<h1 id="Core_Functions">Core Functions</h1><p><a href="#TOP" class="toplink">Top</a></p>
+<div id="Core_Functions_CONTENT">
 
 </div>
 <h2 id="get_video_surface">get_video_surface</h2>
 <pre> my $surface = SDL::Video::get_video_surface();
 
 </pre>
-<p>This function returns the current display surface. If SDL is doing format conversion on the display surface, this 
+<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 
 function returns the publicly visible surface, not the real video surface.</p>
+<p>Example:</p>
+<pre> # somewhere after you set the video mode
+ my $surface = SDL::Video::get_video_surface();
+
+ printf( &quot;our screen is %d pixels wide and %d pixels high\n&quot;, $surface-&gt;w, $surface-&gt;h );
+
+</pre>
 
 </div>
 <h2 id="get_video_info">get_video_info</h2>
 <div id="get_video_info_CONTENT">
-<p>Returns a SDL::VideoInfo about the video hardware. 
-It doesn't take any parameters.</p>
+<pre> my $video_info = SDL::Video::get_video_info();
+
+</pre>
+<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 
+<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 
+format of the <strong>best</strong> video mode. </p>
+<p>Example:</p>
+<pre> use SDL;
+ use SDL::Video;
+ use SDL::VideoInfo;
+ use SDL::PixelFormat;
+
+ SDL::init(SDL_INIT_VIDEO);
+
+ my $video_info = SDL::Video::get_video_info();
+
+ printf( &quot;we can have %dbits per pixel\n&quot;, $video_info-&gt;vfmt-&gt;BitsPerPixel );
+
+ SDL::quit();
+
+</pre>
 
 </div>
 <h2 id="video_driver_name">video_driver_name</h2>
 <div id="video_driver_name_CONTENT">
-<p>Return the 1024 first char of name of the video driver. 
-It doesn't take any parameters.</p>
+<pre> my $driver_name = SDL::Video::video_driver_name();
+
+</pre>
+<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 
+word identifier like <code>&quot;x11&quot;</code>, <code>&quot;windib&quot;</code> or <code>&quot;directx&quot;</code>.</p>
+<p><strong>Note</strong>: Some platforms allow selection of the video driver through the <code>SDL_VIDEODRIVER</code> environment variable. </p>
+<p>Example:</p>
+<pre> use SDL;
+ use SDL::Video;
+
+ SDL::init(SDL_INIT_VIDEO);
+
+ print SDL::Video::video_driver_name() . &quot;\n&quot;;
+
+ SDL::quit();
+
+</pre>
 
 </div>
 <h2 id="list_modes_formats_flags">list_modes(formats,flags)</h2>
 <div id="list_modes_formats_flags_CONTENT">
-<p>Returns a pointer to an array of available screen dimensions for the given format and video flags,
-or it return undef if no modes are avalaibles.</p>
+<pre> my @modes = @{ SDL::Video::list_modes( $pixel_format, $flags ) };
+
+</pre>
+<p>Returns a ref to an array of available screen dimensions for the given format and video flags,
+or it return undef if no modes are available.</p>
+<p>Example:</p>
+<pre> use SDL;
+ use SDL::Video;
+ use SDL::VideoInfo;
+ use SDL::PixelFormat;
+ use SDL::Rect;
+
+ SDL::init(SDL_INIT_VIDEO);
+
+ my $video_info = SDL::Video::get_video_info();
+
+ my @modes = @{ SDL::Video::list_modes($video_info-&gt;vfmt, SDL_NOFRAME) };
+
+ if($#modes &gt; 0)
+ {
+     print(&quot;available modes:\n&quot;);
+     foreach my $index ( @modes )
+     {
+         printf(&quot;%03d: %d x %d\n&quot;, $index, $modes[$index]-&gt;w, $modes[$index]-&gt;h );
+     }
+ }
+ elsif($#modes == 0)
+ {
+     printf(&quot;%s video modes available\n&quot;, $modes[0]);
+ }
+
+ SDL::quit();
+
+</pre>
 
 </div>
 <h2 id="video_mode_ok_width_height_bpp_flags">video_mode_ok(width,height,bpp,flags)</h2>
 <div id="video_mode_ok_width_height_bpp_flags-2">
-<p>Checks to see if a particular video mode of the given width,height,bpp and flags is supported. 
-It returns 0 if the mode is not supported at all, or the suggested bpp.</p>
+<pre> my $bpp_ok = SDL::Video::video_mode_ok( $width, $height, $bpp, $flags );
+
+</pre>
+<p>This function is used to check whether the requested mode is supported by the current video device. The arguments passed to this function 
+are the same as those you would pass to <a href="#set_video_mode_width_height_bpp_flag">SDL::Video::set_video_mode</a>. 
+It returns <code>0</code> if the mode is not supported at all, otherwise the suggested <code>bpp</code>.</p>
+<p>Example:</p>
+<pre> use SDL;
+ use SDL::Video;
+
+ SDL::init(SDL_INIT_VIDEO);
+
+ my $video_mode_ok = SDL::Video::video_mode_ok( 800, 600, 32, SDL_SWSURFACE );
+
+ unless($video_mode_ok)
+ {
+     printf(&quot;this video mode ist not supported\n&quot; );
+ }
+
+ SDL::quit();
+
+
+
+
+</pre>
 
 </div>
 <h2 id="set_video_mode_width_height_bpp_flag">set_video_mode(width,height,bpp,flags)</h2>
@@ -142,8 +245,9 @@ It returns 0 if the mode is not supported at all, or the suggested bpp.</p>
 <pre> my $surface = SDL::Video::set_video_mode( 800, 600, 32, SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN);
 
 </pre>
-<p>Sets up a video mode with the specified width, height,  bits-per-pixel and flags. 
-<code>set_video_mode</code> returns a <a href="/SDL-Surface.html">SDL::Surface</a> on success or it returns undef on error, the error message is retrieved using <code>SDL::get_error</code>.</p>
+<p>Sets up a video mode with the specified width, height, bits-per-pixel and flags. 
+<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 
+using <code>SDL::get_error</code>.</p>
 
 </div>
 <h3 id="List_of_avalaibles_flags">List of avalaibles flags</h3>
@@ -207,135 +311,343 @@ When the window is resized by the user a <code>SDL_VIDEORESIZE</code> event is g
 Fullscreen modes automatically have this flag set.</p>
        </dd>
 </dl>
-<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 
+<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. 
+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 
 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>
-<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>
-<p>Note 3: This function should be called in the main thread of your application.</p>
-<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 
+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>
+<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 
+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>
+<p><strong>Note 3</strong>: This function should be called in the main thread of your application.</p>
+<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 
 been set causes the application to simply ignore those attributes, while enabling attributes after the video mode has been set works fine.</p>
-<p>User note 2: Also note that, in Windows, setting the video mode resets the current OpenGL context. You must execute again the OpenGL 
+<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 
 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>
-
-
-
-
-
-
-
-
-
-
+however, it works fine, and the initialization code only needs to be executed after the first call to 
+<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 
+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>
 
 </div>
 <h2 id="update_rect_surface_x_y_width_height">update_rect(surface,x,y,width,height)</h2>
 <div id="update_rect_surface_x_y_width_height-2">
+<pre> update_rect( $surface, $left, $top, $width, $height );
+
+</pre>
 <p>Makes sure the given area is updated on the given screen.  
 The rectangle must be confined within the screen boundaries because there's no clipping.
 update_rect doesn't returns any value.</p>
-<p>Note : This function should not be called while screen is locked by SDL::lock_surface
-Note2 : If x, y, width and height are all equal to 0, SDL_UpdateRect will update the entire screen. </p>
+<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>
+<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>
+<p>For an example see <a href="#SYNOPSIS">SYNOPSIS</a></p>
 
 </div>
 <h2 id="update_rects_surface_rects">update_rects(surface,rects) </h2>
 <div id="update_rects_surface_rects_CONTENT">
+<pre> update_rects( $surface, @rects );
+
+</pre>
 <p>Makes sure the given list of rectangles is updated on the given screen. 
 The rectangle must be confined within the screen boundaries because there's no clipping.
-update_rects doesn't returns any value.</p>
-<p>Note : This function should not be called while screen is locked by SDL::lock_surface</p>
+<code>update_rects</code> doesn't returns any value.</p>
+<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>
+<p>Example:</p>
+<pre> use SDL;
+ use SDL::Video;
+ use SDL::Surface;
+ use SDL::Rect;
+
+ # the size of the window box or the screen resolution if fullscreen
+ my $screen_width   = 800;
+ my $screen_height  = 600;
+
+ SDL::init(SDL_INIT_VIDEO);
+
+ # setting video mode
+ my $screen_surface = SDL::Video::set_video_mode($screen_width, $screen_height, 32, SDL_SWSURFACE);
+
+ # drawing the whole screen blue
+ my $mapped_color   = SDL::Video::map_RGB($screen_surface-&gt;format(), 0, 0, 255); # blue
+ SDL::Video::fill_rect($screen_surface, 
+                       SDL::Rect-&gt;new(0, 0, $screen_width, $screen_height),
+                       $mapped_color);
+
+ my @rects = ();
+ push(@rects, SDL::Rect-&gt;new(200,   0, 400, 600));
+ push(@rects, SDL::Rect-&gt;new(  0, 150, 800, 300));
+
+ # updating parts of the screen (should look like a cross)
+ SDL::Video::update_rects($screen_surface, @rects);
+
+ sleep(2);
+
+ SDL::quit();
+
+</pre>
 
 </div>
 <h2 id="flip_surface">flip(surface)</h2>
 <div id="flip_surface_CONTENT">
+<pre> $flip = SDL::Video::flip( $screen_surface );
+
+</pre>
 <p>On hardware that supports double-buffering, this function sets up a flip and returns. 
 The hardware will wait for vertical retrace, and then swap video buffers before the next video surface blit or lock will return. 
-On 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>
+On hardware that doesn't support double-buffering or if <code>SDL_SWSURFACE</code> was set, this is equivalent to calling 
+<code>SDL::Video::update_rect( $screen, 0, 0, 0, 0 )</code>.</p>
 <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>
-<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.
-flip returns 0 on success or -1 on error.</p>
-<p>Note : If you want to swap the buffers of an initialized OpenGL context, use the function SDL::gl_swap_buffers instead. </p>
+<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 
+perform hardware flipping.</p>
+<p><code>flip</code> returns <code>0</code> on success or <code>-1</code> on error.</p>
+<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>
+<p>Example:</p>
+<pre> use SDL;
+ use SDL::Video;
+ use SDL::Surface;
+
+ # the size of the window box or the screen resolution if fullscreen
+ my $screen_width   = 800;
+ my $screen_height  = 600;
+
+ SDL::init(SDL_INIT_VIDEO);
+
+ # setting video mode
+ my $screen_surface = SDL::Video::set_video_mode($screen_width, $screen_height, 32, SDL_DOUBLEBUF|SDL_FULLSCREEN);
+
+ # do some video operations here
+
+ # doing page flipping
+ unless( SDL::Video::flip($screen_surface) == 0 )
+ {
+     printf( STDERR &quot;failed to swap buffers: %s\n&quot;, SDL::get_error() );
+ }
+
+ SDL::quit();
+
+</pre>
 
 </div>
 <h2 id="set_colors_surface_start_colors">set_colors(surface,start,colors)</h2>
 <div id="set_colors_surface_start_colors_CONT">
+<pre> $set_colors = SDL::Video::set_colors( $surface, $start, $color1, $color2, ... )
+
+</pre>
 <p>Sets a portion of the colormap for the given 8-bit surface. </p>
 <p>When surface is the surface associated with the current display, the display colormap will be updated with the requested colors. 
-If 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.
-The color components of a SDL::Color structure are 8-bits in size, giving you a total of 2563 = 16777216 colors.
-Palettized (8-bit) screen surfaces with the SDL_HWPALETTE flag have two palettes, a logical palette that is used for mapping blits to/from 
+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 
+guaranteed to be set the way you desire, even if the window colormap has to be warped or run under emulation.
+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.
+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 
 the surface and a physical palette (that determines how the hardware will map the colors to the display). 
-SDL::SetColors modifies both palettes (if present), and is equivalent to calling SDL::SetPalette with the flags set to 
-(SDL_LOGPAL | SDL_PHYSPAL). </p>
-<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::set_colors, it will return 1.
+<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 
+( <code>SDL_LOGPAL | SDL_PHYSPAL</code> ). </p>
+<p>If <code>surface</code> is not a palettized surface, this function does nothing, returning 0. 
+If all of the colors were set as passed to <code>SDL::Video::set_colors</code>, 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>
 
 </div>
 <h2 id="set_palette_surface_flags_start_colo">set_palette(surface,flags,start,colors)</h2>
 <div id="set_palette_surface_flags_start_colo-2">
+<pre> $set_palette = set_palette( $surface, $flags, $start, $color1, $color2, ... );
+
+</pre>
 <p>Sets a portion of the palette for the given 8-bit surface.</p>
-<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 
+<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 
 the surface and a physical palette (that determines how the hardware will map the colors to the display). 
-Non screen surfaces have a logical palette only. SDL::blit_surface always uses the logical palette when blitting surfaces (if it has to 
+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 
 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>
-<p>This function can modify either the logical or physical palette by specifying SDL_LOGPAL or SDL_PHYSPAL the in the flags parameter.</p>
+<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>
 <p>When surface is the surface associated with the current display, the display colormap will be updated with the requested colors.
-If 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.
-The color components of a SDL::Color structure are 8-bits in size, giving you a total of 2563 = 16777216 colors. </p>
-<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 
+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 
+guaranteed to be set the way you desire, even if the window colormap has to be warped or run under emulation.
+The color components of a <code>SDL::Color</code> structure are 8-bits in size, giving you a total of 2563 = 16777216 colors. </p>
+<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>,
+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 
 to determine the actual color palette.</p>
 
 </div>
 <h2 id="set_gamma_r_g_b">set_gamma(r,g,b)</h2>
 <div id="set_gamma_r_g_b_CONTENT">
+<pre> $set_gamma = SDL::Video::set_gamma( $red_gamma, $green_gamma, $blue_gamma );
+
+</pre>
 <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. 
 A gamma value of 1.0 is identity (i.e., no adjustment is made).</p>
 <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>
-<p>Not all display hardware is able to change gamma.
-SDL::set_gamma returns -1 on error.</p>
-<p>Warning: Under Linux (X.org Gnome and Xfce), gamma settings affects the entire display (including the desktop)! </p>
+<p><strong>Note</strong>: Not all display hardware is able to change gamma.</p>
+<p><code>SDL::Video::set_gamma</code> returns <code>-1</code> on error.</p>
+<p><strong>Warning</strong>: Under Linux (X.org Gnome and Xfce), gamma settings affects the entire display (including the desktop)! </p>
+<p>Example:</p>
+<pre> use SDL;
+ use SDL::Video;
+ use SDL::Surface;
+ use SDL::Rect;
+ use Time::HiRes qw( usleep );
+
+ # the size of the window box or the screen resolution if fullscreen
+ my $screen_width   = 800;
+ my $screen_height  = 600;
+
+ SDL::init(SDL_INIT_VIDEO);
+
+ # setting video mode
+ my $screen_surface = SDL::Video::set_video_mode($screen_width, $screen_height, 32, SDL_SWSURFACE);
+
+ # drawing something somewhere
+ my $mapped_color   = SDL::Video::map_RGB($screen_surface-&gt;format(), 128, 128, 128); # gray
+ SDL::Video::fill_rect($screen_surface, 
+                       SDL::Rect-&gt;new($screen_width / 4, $screen_height / 4, $screen_width / 2, $screen_height / 2), 
+                       $mapped_color);
+
+ # update the whole screen
+ SDL::Video::update_rect($screen_surface, 0, 0, $screen_width, $screen_height);
+
+ usleep(500000);
+
+ for(1..20)
+ {
+    SDL::Video::set_gamma( 1 - $_ / 20, 1, 1 );
+       usleep(40000);
+ }
+
+ for(1..20)
+ {
+    SDL::Video::set_gamma( $_ / 20, 1, 1 );
+       usleep(40000);
+ }
+
+ SDL::Video::set_gamma( 1, 1, 1 );
+
+ usleep(500000);
+
+ SDL::quit();
+
+</pre>
 
 </div>
-<h2 id="get_gamma_ramp_rt_gt_bt_to_be_coded">get_gamma_ramp(rt,gt,bt) * to be coded</h2>
-<div id="get_gamma_ramp_rt_gt_bt_to_be_coded_">
+<h2 id="get_gamma_ramp_rt_gt_bt">get_gamma_ramp(rt,gt,bt)</h2>
+<div id="get_gamma_ramp_rt_gt_bt_CONTENT">
+<pre> $get_gamma_ramp = SDL::Video::get_gamma_ramp( \@red_table, \@green_table, \@blue_table );
+
+</pre>
 <p>Gets the gamma translation lookup tables currently used by the display. Each table is an array of 256 Uint16 values.
 SDL::get_gamma_ramp returns -1 on error.</p>
+<pre> use SDL;
+ use SDL::Video;
+
+ SDL::init(SDL_INIT_VIDEO);
+
+ my (@red, @green, @blue);
+
+ my $ret = SDL::Video::get_gamma_ramp( \@red, \@green, \@blue );
+
+ if( -1 == $ret )
+ {
+     print( &quot;an error occoured&quot; );
+ }
+ else
+ {
+     printf( &quot;for gamma = 1.0: red=0x%04X, green=0x%04X, blue=0x%04X\n&quot;, $red[255], $green[255], $blue[255] );
+     printf( &quot;for gamma = 0.5: red=0x%04X, green=0x%04X, blue=0x%04X\n&quot;, $red[127], $green[127], $blue[127] );
+     printf( &quot;for gamma = 0.0: red=0x%04X, green=0x%04X, blue=0x%04X\n&quot;, $red[0],   $green[0],   $blue[0]   );
+ }
+
+ SDL::quit();
+
+</pre>
 
 </div>
 <h2 id="set_gamma_ramp_rt_gt_bt">set_gamma_ramp(rt,gt,bt)</h2>
 <div id="set_gamma_ramp_rt_gt_bt_CONTENT">
-<p>Sets the gamma lookup tables for the display for each color component. Each table is an array of 256 Uint16 values, representing a 
+<pre> $set_gamma_ramp = SDL::Video::set_gamma_ramp( \@red_table, \@green_table, \@blue_table );
+
+</pre>
+<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 
 mapping between the input and output for that channel.
 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. 
 You may pass NULL to any of the channels to leave them unchanged.</p>
 <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>
+with <code>SDL::Video::set_gamma</code>.</p>
 <p>Not all display hardware is able to change gamma. 
-SDL::set_gamma_ramp returns -1 on error.</p>
+<code>SDL::Video::set_gamma_ramp</code> returns <code>-1</code> on error (or if gamma adjustment is not supported).</p>
+<p>Example:</p>
+<pre> use SDL;
+ use SDL::Video;
+
+ SDL::init(SDL_INIT_VIDEO);
+
+ my (@red, @green, @blue);
+
+ my $ret = SDL::Video::get_gamma_ramp( \@red, \@green, \@blue );
+
+ $red[127] = 0xFF00;
+
+    $ret = SDL::Video::set_gamma_ramp( \@red, \@green, \@blue );
+
+    $ret = SDL::Video::get_gamma_ramp( \@red, \@green, \@blue );
+
+ if( -1 == $ret )
+ {
+     print( &quot;an error occoured&quot; );
+ }
+ else
+ {
+     printf( &quot;for gamma = 1.0: red=0x%04X, green=0x%04X, blue=0x%04X\n&quot;, $red[255], $green[255], $blue[255] );
+     printf( &quot;for gamma = 0.5: red=0x%04X, green=0x%04X, blue=0x%04X\n&quot;, $red[127], $green[127], $blue[127] );
+     printf( &quot;for gamma = 0.0: red=0x%04X, green=0x%04X, blue=0x%04X\n&quot;, $red[0],   $green[0],   $blue[0]   );
+ }
+
+ SDL::quit();
+
+</pre>
 
 </div>
 <h2 id="map_RGB_pixel_format_r_g_b">map_RGB(pixel_format,r,g,b)</h2>
 <div id="map_RGB_pixel_format_r_g_b_CONTENT">
-<p>Maps the RGB color value to the specified SDL::pixel_format and returns the pixel value as a 32-bit int.
+<pre> $pixel = SDL::Video::map_RGB( $pixel_format, $r, $g, $b );
+
+</pre>
+<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.
 If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.
 If the specified pixel format has an alpha component it will be returned as all 1 bits (fully opaque). </p>
-<p>SDL::map_RGP returns a pixel value best approximating the given RGB color value for a given pixel format.
-If 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 
+<p><code>SDL::Video::map_RGB</code> returns a pixel value best approximating the given RGB color value for a given pixel format.
+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 
 (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>
+<pre> use SDL;
+ use SDL::Video;
+ use SDL::PixelFormat;
+ use SDL::Surface;
+
+ SDL::init(SDL_INIT_VIDEO);
+
+ my $screen_surface = SDL::Video::set_video_mode(640, 480, 16, SDL_SWSURFACE);
+ #                                                          ^-- 16 bits per pixel
+
+ $r = 0x9C;
+ $g = 0xDC;
+ $b = 0x67;
+
+ printf( &quot;for 24bpp it is: 0x%02X 0x%02X 0x%02X\n&quot;, $r, $g, $b);
+
+ my $_16bit = SDL::Video::map_RGB( $screen_surface-&gt;format, $r, $g, $b );
+
+ # 16bpp is 5 bits red, 6 bits green and 5 bits blue
+ # we will obtain the values for each color and calculating them back to 24bit color system
+ $r = (($_16bit &amp; 0b1111100000000000) &gt;&gt; 11) / 0b11111  * 0b11111111;
+ $g = (($_16bit &amp; 0b0000011111100000) &gt;&gt;  5) / 0b111111 * 0b11111111;
+ $b =  ($_16bit &amp; 0b0000000000011111)        / 0b11111  * 0b11111111;
+
+ printf( &quot;for 16bpp it is: 0x%02X 0x%02X 0x%02X\n&quot;, $r, $g, $b );
+
+ # so color #9CDC67 becomes #9CDE62
+
+ SDL::quit();
+
+</pre>
 
 </div>
 <h2 id="map_RGBA_pixel_format_r_g_b_a">map_RGBA(pixel_format,r,g,b,a)</h2>
@@ -363,57 +675,6 @@ component (e.g., a completely white pixel in 16-bit RGB565 format would return [
 <p>If the surface has no alpha component, the alpha will be returned as 0xff (100% opaque). </p>
 
 </div>
-<h2 id="create_RGB_surface_from">create_RGB_surface_from ***</h2>
-<div id="create_RGB_surface_from_CONTENT">
-<p>Creates an empty SDL::Surface from pixel data
-Allocate an empty surface (must be called after SDL::set_video_mode)
-If 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>
-<dl>
-       <dt>SDL_SWSURFACE</dt>
-       <dd>
-               <p>SDL will create the surface in system memory. 
-This improves the performance of pixel level access, however you may not be able to take advantage of some types of hardware blitting.</p>
-       </dd>
-       <dt>SDL_HWSURFACE</dt>
-       <dd>
-               <p>SDL will attempt to create the surface in video memory. 
-This will allow SDL to take advantage of Video-&gt;Video blits (which are often accelerated).</p>
-       </dd>
-       <dt>SDL_SRCCOLORKEY</dt>
-       <dd>
-               <p>This flag turns on color keying for blits from this surface. 
-If SDL_HWSURFACE is also specified and color keyed blits are hardware-accelerated, then SDL will attempt to place the surface in video memory.
-If the screen is a hardware surface and color keyed blits are hardware-accelerated then the SDL_HWSURFACE flag will be set. 
-Use SDL_SetColorKey to set or clear this flag after surface creation.</p>
-       </dd>
-       <dt>SDL_SRCALPHA</dt>
-       <dd>
-               <p>This flag turns on alpha-blending for blits from this surface. 
-If SDL_HWSURFACE is also specified and alpha-blending blits are hardware-accelerated, 
-then the surface will be placed in video memory if possible. 
-If the screen is a hardware surface and alpha-blending blits are hardware-accelerated then the SDL_HWSURFACE flag will be set. 
-Use SDL_SetAlpha to set or clear this flag after surface creation.</p>
-       </dd>
-</dl>
-
-
-
-
-<p>[RGBA]mask are the bitmasks used to extract that colour from a pixel.
-For instance, Rmask being FF000000 means the red data is stored in the most significant byte. 
-Using 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);).
-However, using zero for the Amask results in an Amask of 0.
-It returns a SDL::Surface on success or undef on error.
-Notes: If an alpha-channel is specified (that is, if Amask is nonzero), then the SDL_SRCALPHA flag is automatically set. 
-You may remove this flag by calling SDL::set_alpha after surface creation.
-Also, if the SDL_HWSURFACE flag is set on the returned surface, its format might not match the requested format. </p>
-<p>Notes: Sometimes specifying an Alpha mask value could cause strange results. 
-This 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>
-
-</div>
 <h2 id="lock_surface_surface">lock_surface(surface)</h2>
 <div id="lock_surface_surface_CONTENT">
 <p>SDL::lock_surface sets up the given SDL::surface for directly accessing the pixels.
@@ -466,9 +727,6 @@ SDL::load_BMP returns a SDL::surface on success or undef on error.</p>
 
 
 
-
-
-
 </div>
 <h2 id="save_BMP_surface_filename">save_BMP(surface,filename)</h2>
 <div id="save_BMP_surface_filename_CONTENT">
@@ -604,6 +862,10 @@ result. This can happen if you are using a shadowed surface that is not double b
 <p>SDL::fill_rect returns 0 on success or -1 on error.</p>
 
 </div>
+<h1 id="GL_Methods">GL Methods</h1><p><a href="#TOP" class="toplink">Top</a></p>
+<div id="GL_Methods_CONTENT">
+
+</div>
 <h2 id="GL_load_library_path">GL_load_library(path)</h2>
 <div id="GL_load_library_path_CONTENT">
 <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.
@@ -655,6 +917,14 @@ SDL::GL_swap_buffers doesn't returns any value.</p>
 
 
 </div>
+<h1 id="a_href_SDL_Overlay_html_SDL_Overlay_"><a href="/SDL-Overlay.html">SDL::Overlay</a> Functions</h1><p><a href="#TOP" class="toplink">Top</a></p>
+<div id="a_href_SDL_Overlay_html_SDL_Overlay_-2">
+
+
+
+
+
+</div>
 <h2 id="lock_YUV_overlay_overlay">lock_YUV_overlay(overlay)</h2>
 <div id="lock_YUV_overlay_overlay_CONTENT">
 <p>Much the same as <code>SDL::lock_surface</code>, SDL::lock_YUV_overlay locks the overlay for direct access to pixel data.