GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
pods::SDL::Surface(3) User Contributed Perl Documentation pods::SDL::Surface(3)

SDL::Surface - Graphic surface structure

Core, Video, Structure

 use SDL;
 use SDL::Video;
 use SDL::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);

An "SDL_Surface" defines a surfaceangular area of pixels.

The constants for SDL::Surface belong to SDL::Video, under the export tag of ':surface'.
SDL_ASYNCBLIT
Use asynchronous blit if possible
SDL_SWSURFACE
Store in system memory
SDL_HWSURFACE
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.

 my $w = $surface->w;

Returns the width of the surface. SDL::Surface width is defined at construction so this is read-only.

 my $h = $surface->h;

Returns the height of the surface. SDL::Surface height is defined at construction so this is read-only.

 my $format = $surface->format;

The format of the pixels stored in the surface. See SDL::PixelFormat

 my $pitch = $surface->pitch;

The scanline length in bytes.

Disclaimer: The following methods can be very slow, making them suitable for creating surfaces, but not for animations

 my $pixel = $surface->get_pixel( $offset )

Returns the numeric 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 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!

 my $ptr = $surface->get_pixels_ptr;

Returns a reference to the surface's pixels.

SDL, SDL::PixelFormat, SDL::Video, SDL::Rect

See "AUTHORS" in SDL.
2022-06-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.