X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-Surface.html-inc;h=6fe35f39f66be61f2c7a5e7e9e67791bdd405b95;hb=c8ad4fe9f211e727310a1ce6d23ffb1d7822d71f;hp=83709ba4e325a5273cf98fe29552da9f800ad3e7;hpb=f373167ec31ba16ae0770ba461f9de43f41a7ac1;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDL-Surface.html-inc b/pages/SDL-Surface.html-inc index 83709ba..6fe35f3 100644 --- a/pages/SDL-Surface.html-inc +++ b/pages/SDL-Surface.html-inc @@ -8,27 +8,17 @@
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);@@ -71,47 +61,7 @@
The constants are exported by default. You can avoid this by doing:
-use SDL::Video (); - --
and access them directly:
-SDL::Video::SDL_SWSURFACE; - --
Available constants: see flags
- -The constructor creates a new surface with the specified parameter values.
-my $surface = SDL::Surface->new( ... ); - -- -
The constructor creates a new surface with the specified parameter values.
-my $surface = SDL::Surface->new_from( $old_surface, ... ); - - - - -- -
Available flags for new() are exported by SDL::Video
+The constants for SDL::Surface belong to SDL::Video, under the export tag of ':surface'
.
Stored in the system memory.
+Store in system memory
Stored in video memory
+Store in video memory
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.
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
.
SDL::Surface width are defined at construction. Thus the following is read only.
-my $w = $surface->w; +my $w = $surface->w;+Returns the width of the surface. +SDL::Surface width is defined at construction so this is read-only.
SDL::Surface height are defined at construction. Thus the following is read only.
-my $h = $surface->h; +my $h = $surface->h;+Returns the height of the surface. +SDL::Surface height is defined at construction so this is read-only.
The format of the pixels stored in the surface. See SDL::PixelFormat
my $format = $surface->format;+
The format of the pixels stored in the surface. +See SDL::PixelFormat
my $pitch = $surface->pitch;-
SDL::Surface's scanline length in bytes
- - -To get the surface's clip_rect we the following
-my $clip_rect = SDL::Rect->new(0,0,0,0); - SDL::Video::get_clip_rect($surface, $clip_rect); - --
To set the surface's clip_rect use the following
-my $clip_rect = SDL::Rect->new(2,23,23,542); - SDL::Video::set_clip_rect($surface, $clip_rect); - -+
The scanline length in bytes.
Disclaimer: This can be very slow, it is suitable for creating surfaces one time and not for animations
+Disclaimer: The following methods can be very slow, making them suitable for creating surfaces, but not for animations
my $pixel = $surface->get_pixel( $offset ) +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.
+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.
$surface->set_pixels( $offset, $value );-
Sets the current pixel $value
to the given $offset
. The pixel value must fit the pixel format of the surface.
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.
- - -sub putpixel - { - my($x, $y, $color) = @_; - $screen->set_pixels( $x + $y * $screen->w, $color); +Example:
+sub putpixel { + my ($x, $y, $color) = @_; + $display->set_pixels( $x + $y * $display->w, $color); }-See also examples/sols/ch02.pl
+See also examples/pixel_operations/sols/ch02.pl!
$surface->get_pixels_ptr(); +my $ptr = $surface->get_pixels_ptr;-Returns the C ptr to this surfaces's pixels
- - - - - - - +Returns a reference to the surface's pixels.