X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-Surface.html-inc;h=8cd739727d9486c0814ff1c2d0323b1a3bb90151;hb=c7e8d3c612049580c9a96b3006c4c89a00410643;hp=96720b6bbff5f6228b5b5986316372d6822b732d;hpb=c5cfaf97c76259d6b3d589b543acff12774fbcbf;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDL-Surface.html-inc b/pages/SDL-Surface.html-inc index 96720b6..8cd7397 100644 --- a/pages/SDL-Surface.html-inc +++ b/pages/SDL-Surface.html-inc @@ -6,24 +6,31 @@
SDL::Surface - Graphic surface structure.
+SDL::Surface - Graphic surface structure
The main surface (display) is provided by SDL::Video::set_video_mode. - use SDL; #provides flags & constants - use SDL::Video; #provides access to set_video_mode - use SDL::Surface; #provides access to SDL_Surface struct internals
-SDL::init(SDL_INIT_VIDEO); - my $display = SDL::Video::set_video_mode(); +use SDL; + use SDL::Video; + use SDL::Surface; --All surfaces constructed from now on are attached to the $display. There are two constructors available to do this.
-my $surface = SDL::Surface->new ( ... ); - my $surface2 = SDL::Surface->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->new(SDL_ASYNCBLIT | SDL_HWSURFACE, 640, 480, 16, 0, 0, 0, 0); + my $surface2 = SDL::Surface->new_from($surface, 100, 100, 8, 0, 0, 0, 0);@@ -53,59 +60,136 @@An
SDL_Surface
defines a surfaceangular area of pixels.
The constants for SDL::Surface belong to SDL::Video, under the export tag of ':surface'
.
Use asynchronous blit if possible
+Store in system memory
+Store in video memory
+The constructor creates a new surface with the specified parameter values.
-my $surface = SDL::Surface->new( ... ); +new
++-my $surface = SDL::Surface->new( + $flags, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask + );+The constructor creates a new surface with the specified parameter values.
+The four mask values are the bits that the channel will ignore. +For example, an Rmask of
0xFF
will ignore that channel completely, making everything on the surface more green/blue.new_from ( surface, width, height, depth, Rmask, Gmask, Bmask, Amask )
--The constructor creates a new surface with the specified parameter values.
-my $surface = SDL::Surface->new_from( $old_surface, ... ); - +new_from
+++my $surface = SDL::Surface->new_from( + $surface, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask + ); ++The constructor creates a new surface with the specified parameter values. +The flags are taken from the specified
+$surface
.w
++-my $w = $surface->w;+Returns the width of the surface. +SDL::Surface width is defined at construction so this is read-only.
Construtor Parameters
-+h
+++my $h = $surface->h; ++Returns the height of the surface. +SDL::Surface height is defined at construction so this is read-only.
+format
+++my $format = $surface->format; ++The format of the pixels stored in the surface. +See SDL::PixelFormat
+pitch
+++my $pitch = $surface->pitch; ++The scanline length in bytes.
+Direct Write to Surface Pixel
+++Disclaimer: The following methods can be very slow, making them suitable for creating surfaces, but not for animations
+ +get_pixel
++-my $pixel = $surface->get_pixel( $offset ) ++Returns the pixel value for the given
+$offset
. +The pixel value depends on current pixel format.Note: For surfaces with a palette (1 byte per pixel) the palette index is returned instead of color values.
w
--SDL::Surface width are defined at construction. Thus the following is read only.
-my $w = $surface->w; +set_pixels
++-$surface->set_pixels( $offset, $value ); + ++Sets the pixel
+$value
to the given$offset
. +The pixel value must fit the pixel format of the surface.Note: For surfaces with a palette (1 byte per pixel) the palette index must be passed instead of color values.
+Example:
+sub putpixel { + my ($x, $y, $color) = @_; + $display->set_pixels( $x + $y * $display->w, $color); + }+See also examples/pixel_operations/sols/ch02.pl!
h
--\ No newline at end of fileSDL::Surface height are defined at construction. Thus the following is read only.
-my $h = $surface->h; +get_pixels_ptr
++my $ptr = $surface->get_pixels_ptr;+Returns a reference to the surface's pixels.
SEE ALSO
- + + ++AUTHORS
++See AUTHORS in SDL.