updated docs
[sdlgit/SDL-Site.git] / pages / SDL-Surface.html-inc
index 7772fc1..8cd7397 100644 (file)
@@ -6,39 +6,31 @@
 <li><a href="#CATEGORY">CATEGORY</a></li>
 <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
 <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
+<li><a href="#CONSTANTS">CONSTANTS</a></li>
 <li><a href="#METHODS">METHODS</a>
-<ul><li><a href="#new_flags_width_height_depth_Rmask_G">new ( flags, width, height, depth, Rmask, Gmask, Bmask, Amask )</a></li>
-<li><a href="#new_from_surface_width_height_depth_">new_from ( surface, width, height, depth, Rmask, Gmask, Bmask, Amask )</a>
-<ul><li><a href="#Construtor_Parameters">Construtor Parameters</a>
-<ul><li><a href="#flags">flags</a></li>
-</ul>
-</li>
-</ul>
-</li>
+<ul><li><a href="#new">new</a></li>
+<li><a href="#new_from">new_from</a></li>
 <li><a href="#w">w</a></li>
 <li><a href="#h">h</a></li>
 <li><a href="#format">format</a></li>
 <li><a href="#pitch">pitch</a></li>
-<li><a href="#clip_rect">clip_rect</a></li>
 </ul>
 </li>
 <li><a href="#Direct_Write_to_Surface_Pixel">Direct Write to Surface Pixel</a>
-<ul><li><a href="#get_pixels">get_pixels</a></li>
-<li><a href="#set_pixels">set_pixels</a>
-<ul><li><a href="#Usage">Usage</a></li>
-</ul>
-</li>
+<ul><li><a href="#get_pixel">get_pixel</a></li>
+<li><a href="#set_pixels">set_pixels</a></li>
 <li><a href="#get_pixels_ptr">get_pixels_ptr</a></li>
 </ul>
 </li>
-<li><a href="#SEE_ALSO">SEE ALSO</a>
+<li><a href="#SEE_ALSO">SEE ALSO</a></li>
+<li><a href="#AUTHORS">AUTHORS</a>
 </li>
 </ul><hr />
 <!-- INDEX END -->
 
 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
 <div id="NAME_CONTENT">
-<p>SDL::Surface - Graphic surface structure.</p>
+<p>SDL::Surface - Graphic surface structure</p>
 
 </div>
 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
 </div>
 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
 <div id="SYNOPSIS_CONTENT">
-<p>The main surface (display) is provided by <a href="/SDL-Video.html#set_video_mode">SDL::Video::set_video_mode</a>.
-  use SDL; #provides flags &amp; constants
-  use SDL::Video; #provides access to set_video_mode
-  use SDL::Surface; #provides access to SDL_Surface struct internals</p>
-<pre>  SDL::init(SDL_INIT_VIDEO); 
-  my $display = SDL::Video::set_video_mode(); 
+<pre> use SDL;
+ use SDL::Video;
+ use SDL::Surface;
 
-</pre>
-<p>All surfaces constructed from now on are attached to the $display. There are two constructors available to do this.</p>
-<pre>  my $surface  = SDL::Surface-&gt;new ( ... ); 
-  my $surface2 = SDL::Surface-&gt;new_from ( surface, ... ); 
+ # Create the main surface (display)
+ SDL::init(SDL_INIT_VIDEO);
+ my $display = SDL::Video::set_video_mode(640, 480, 16, SDL_SWSURFACE);
+
+ # Create other surfaces attached to the $display.
+ my $surface  = SDL::Surface-&gt;new(SDL_ASYNCBLIT | SDL_HWSURFACE, 640, 480, 16, 0, 0, 0, 0);
+ my $surface2 = SDL::Surface-&gt;new_from($surface, 100, 100, 8, 0, 0, 0, 0);
 
 </pre>
 
 <p>An <code>SDL_Surface</code> defines a surfaceangular area of pixels.</p>
 
 </div>
-<h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
-<div id="METHODS_CONTENT">
-
-</div>
-<h2 id="new_flags_width_height_depth_Rmask_G">new ( flags, width, height, depth, Rmask, Gmask, Bmask, Amask )</h2>
-<div id="new_flags_width_height_depth_Rmask_G-2">
-<p>The constructor creates a new surface with the specified parameter values.</p>
-<pre>    my $surface = SDL::Surface-&gt;new( ... );
-
-</pre>
-
-</div>
-<h2 id="new_from_surface_width_height_depth_">new_from ( surface, width, height, depth, Rmask, Gmask, Bmask, Amask )</h2>
-<div id="new_from_surface_width_height_depth_-2">
-<p>The constructor creates a new surface with the specified parameter values. </p>
-<pre>    my $surface = SDL::Surface-&gt;new_from( $old_surface, ... );
-
-
-
-
-</pre>
-
-</div>
-<h3 id="Construtor_Parameters">Construtor Parameters</h3>
-<div id="Construtor_Parameters_CONTENT">
-
-</div>
-<h4 id="flags">flags</h4>
-<div id="flags_CONTENT">
+<h1 id="CONSTANTS">CONSTANTS</h1><p><a href="#TOP" class="toplink">Top</a></p>
+<div id="CONSTANTS_CONTENT">
+<p>The constants for SDL::Surface belong to SDL::Video, under the export tag of <code>':surface'</code>.</p>
 <dl>
-       <dt>SDL_ANYFORMAT</dt>
-       <dd>
-               <p>Allow any pixel-format *</p>
-       </dd>
        <dt>SDL_ASYNCBLIT</dt>
        <dd>
                <p>Use asynchronous blit if possible</p>
        </dd>
-       <dt>SDL_DOUBLEBUF</dt>
-       <dd>
-               <p>Double buffered *</p>
-       </dd>
-       <dt>SDL_HWACCEL</dt>
-       <dd>
-               <p>Use hardware acceleration blit</p>
-       </dd>
-       <dt>SDL_HWPALETTE</dt>
-       <dd>
-               <p>Have an exclusive palette</p>
-       </dd>
-       <dt>SDL_HWSURFACE</dt>
-       <dd>
-               <p>Stored in video memory</p>
-       </dd>
-       <dt>SDL_FULLSCREEN</dt>
-       <dd>
-               <p>Full screen surface *</p>
-       </dd>
-       <dt>SDL_OPENGL</dt>
-       <dd>
-               <p>Have an OpenGL context *</p>
-       </dd>
-       <dt>SDL_OPENGLBLIT</dt>
-       <dd>
-               <p>Support OpenGL blitting *. NOTE: This option is kept for compatibility only, and is not recommended for new code.</p>
-       </dd>
-       <dt>SDL_RESIZABLE</dt>
-       <dd>
-               <p>Resizable surface *</p>
-       </dd>
-       <dt>SDL_RLEACCEL</dt>
-       <dd>
-               <p>Accelerated colorkey blitting with RLE</p>
-       </dd>
-       <dt>SDL_SRCALPHA</dt>
-       <dd>
-               <p>Use alpha blending blit</p>
-       </dd>
-       <dt>SDL_SRCCOLORKEY</dt>
-       <dd>
-               <p>Use colorkey blitting</p>
-       </dd>
        <dt>SDL_SWSURFACE</dt>
        <dd>
-               <p>Stored in the system memory. SDL_SWSURFACE is not actually a flag (it is defined as 0). A lack of SDL_HWSURFACE implies SDL_SWSURFACE</p>
+               <p>Store in system memory</p>
        </dd>
-       <dt>SDL_PREALLOC</dt>
+       <dt>SDL_HWSURFACE</dt>
        <dd>
-               <p>Use preallocated memory</p>
+               <p>Store in video memory</p>
        </dd>
 </dl>
 
+</div>
+<h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
+<div id="METHODS_CONTENT">
 
+</div>
+<h2 id="new">new</h2>
+<div id="new_CONTENT">
+<pre> my $surface = SDL::Surface-&gt;new(
+     $flags, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask
+ );
 
+</pre>
+<p>The constructor creates a new surface with the specified parameter values.</p>
+<p>The four mask values are the bits that the channel will ignore.
+For example, an Rmask of <code>0xFF</code> will ignore that channel completely, making everything on the surface more green/blue.</p>
 
+</div>
+<h2 id="new_from">new_from</h2>
+<div id="new_from_CONTENT">
+<pre> my $surface = SDL::Surface-&gt;new_from(
+     $surface, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask
+ );
+
+</pre>
+<p>The constructor creates a new surface with the specified parameter values.
+The flags are taken from the specified <code>$surface</code>.</p>
 
 </div>
 <h2 id="w">w</h2>
 <div id="w_CONTENT">
-<p>SDL::Surface width are defined at construction. Thus the following is read only. </p>
-<pre>  my $w = $surface-&gt;w; 
+<pre> my $w = $surface-&gt;w;
 
 </pre>
+<p>Returns the width of the surface.
+SDL::Surface width is defined at construction so this is read-only.</p>
 
 </div>
 <h2 id="h">h</h2>
 <div id="h_CONTENT">
-<p>SDL::Surface height are defined at construction. Thus the following is read only. </p>
-<pre>  my $h = $surface-&gt;h; 
+<pre> my $h = $surface-&gt;h;
 
 </pre>
+<p>Returns the height of the surface.
+SDL::Surface height is defined at construction so this is read-only.</p>
 
 </div>
 <h2 id="format">format</h2>
 <div id="format_CONTENT">
-<p>The format of the pixels stored in the surface. See <a href="SDL-PixelFormat">SDL::PixelFormat</a></p>
 <pre> my $format = $surface-&gt;format;
 
 </pre>
+<p>The format of the pixels stored in the surface.
+See <a href="SDL-PixelFormat.html">SDL::PixelFormat</a></p>
 
 </div>
 <h2 id="pitch">pitch</h2>
 <pre> my $pitch = $surface-&gt;pitch;
 
 </pre>
-<p>SDL::Surface's scanline length in bytes</p>
-
-</div>
-<h2 id="clip_rect">clip_rect</h2>
-<div id="clip_rect_CONTENT">
-<p>To get the surface's clip_rect we the following</p>
-<pre> my $clip_rect = SDL::Rect-&gt;new(0,0,0,0);
- SDL::Video::get_clip_rect($surface, $clip_rect);
-
-</pre>
-<p>To set the surface's clip_rect use the following</p>
-<pre> my $clip_rect = SDL::Rect-&gt;new(2,23,23,542);
- SDL::Video::set_clip_rect($surface, $clip_rect);
-
-</pre>
+<p>The scanline length in bytes.</p>
 
 </div>
 <h1 id="Direct_Write_to_Surface_Pixel">Direct Write to Surface Pixel</h1><p><a href="#TOP" class="toplink">Top</a></p>
 <div id="Direct_Write_to_Surface_Pixel_CONTEN">
-<p>Disclaimer: This can be very slow, it is suitable for creating surfaces one time and not for animations</p>
+<p><strong>Disclaimer:</strong> The following methods can be very slow, making them suitable for creating surfaces, but not for animations</p>
 
 </div>
-<h2 id="get_pixels">get_pixels</h2>
-<div id="get_pixels_CONTENT">
-<pre> $surface-&gt;get_pixels( $offset )  
+<h2 id="get_pixel">get_pixel</h2>
+<div id="get_pixel_CONTENT">
+<pre> my $pixel = $surface-&gt;get_pixel( $offset )
 
 </pre>
-<p>Returns the current integer value at (surface-&gt;pixels)[offset] </p>
+<p>Returns the pixel value for the given <code>$offset</code>.
+The pixel value depends on current pixel format.</p>
+<p><strong>Note:</strong> For surfaces with a palette (1 byte per pixel) the palette index is returned instead of color values.</p>
 
 </div>
 <h2 id="set_pixels">set_pixels</h2>
 <pre> $surface-&gt;set_pixels( $offset, $value );
 
 </pre>
-<p>Sets the current integer to $value at (surface-&gt;pixels)[offset]</p>
-
-</div>
-<h3 id="Usage">Usage</h3>
-<div id="Usage_CONTENT">
-<pre>  sub putpixel
-  {
-       my($x, $y, $color) = @_;
-       my $lineoffset = $y * ($screen-&gt;pitch / $depth_in_bytes); 
-       $screen-&gt;set_pixels( $lineoffset+ $x, $color);
-  }
+<p>Sets the pixel <code>$value</code> to the given <code>$offset</code>.
+The pixel value must fit the pixel format of the surface.</p>
+<p><strong>Note</strong>: For surfaces with a palette (1 byte per pixel) the palette index must be passed instead of color values.</p>
+<p>Example:</p>
+<pre> sub putpixel {
+     my ($x, $y, $color) = @_;
+     $display-&gt;set_pixels( $x + $y * $display-&gt;w, $color);
+ }
 
 </pre>
-<p>Note: $depth_in_bytes for 32 is 4, 16 is 2, 8 is 1;</p>
-<p>See also examples/sols/ch02.pl</p>
+<p>See also <cite>examples/pixel_operations/sols/ch02.pl</cite>!</p>
 
 </div>
 <h2 id="get_pixels_ptr">get_pixels_ptr</h2>
 <div id="get_pixels_ptr_CONTENT">
-<pre> $surface-&gt;get_pixels_ptr();
+<pre> my $ptr = $surface-&gt;get_pixels_ptr;
 
 </pre>
-<p>Returns the C ptr to this surfaces's pixels</p>
-
-
-
-
-
-
-
+<p>Returns a reference to the surface's pixels.</p>
 
 </div>
 <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
 <div id="SEE_ALSO_CONTENT">
-<p><a href="SDL">SDL</a>, <a href="SDL-PixelFormat">SDL::PixelFormat</a>, <a href="SDL-Video">SDL::Video</a>, <a href="SDL-Rect">SDL::Rect</a></p>
+<p><a href="SDL.html">SDL</a>, <a href="SDL-PixelFormat.html">SDL::PixelFormat</a>, <a href="SDL-Video.html">SDL::Video</a>, <a href="SDL-Rect.html">SDL::Rect</a></p>
+
+</div>
+<h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
+<div id="AUTHORS_CONTENT">
+<p>See <b>AUTHORS</b> in <cite>SDL</cite>.</p>
 
 </div>
 </div>
\ No newline at end of file