SDL_Surface(3) SDL API Reference SDL_Surface(3)NAME
SDL_Surface - Graphical Surface Structure
STRUCTURE DEFINITION
typedef struct SDL_Surface {
Uint32 flags; /* Read-only */
SDL_PixelFormat *format; /* Read-only */
int w, h; /* Read-only */
Uint16 pitch; /* Read-only */
void *pixels; /* Read-write */
/* clipping information */
SDL_Rect clip_rect; /* Read-only */
/* Reference count -- used when freeing surface */
int refcount; /* Read-mostly */
/* This structure also contains private fields not shown here */
} SDL_Surface;
STRUCTURE DATA
flags Surface flags
format Pixel format
w, h Width and height of the surface
pitch Length of a surface scanline in bytes
pixels Pointer to the actual pixel data
clip_rect surface clip rectangle
DESCRIPTION
SDL_Surface's represent areas of "graphical" memory, memory that can be drawn to. The video framebuffer is returned as a SDL_Surface by
SDL_SetVideoMode and SDL_GetVideoSurface. Most of the fields should be pretty obvious. w and h are the width and height of the surface in
pixels. pixels is a pointer to the actual pixel data, the surface should be locked before accessing this field. The clip_rect field is the
clipping rectangle as set by SDL_SetClipRect.
The following are supported in the flags field.
SDL_SWSURFACE Surface is stored in system memory
SDL_HWSURFACE Surface is stored in video memory
SDL_ASYNCBLIT Surface uses asynchronous blits if possible
SDL_ANYFORMAT Allows any pixel-format (Display surface)
SDL_HWPALETTE Surface has exclusive palette
SDL_DOUBLEBUF Surface is double buffered (Display surface)
SDL_FULLSCREEN Surface is full screen (Display Surface)
SDL_OPENGL Surface has an OpenGL context (Display Surface)
SDL_OPENGLBLIT Surface supports OpenGL blitting (Display Surface)
SDL_RESIZABLE Surface is resizable (Display Surface)
SDL_HWACCEL Surface blit uses hardware acceleration
SDL_SRCCOLORKEY Surface use colorkey blitting
SDL_RLEACCEL Colorkey blitting is accelerated with RLE
SDL_SRCALPHA Surface blit uses alpha blending
SDL_PREALLOC Surface uses preallocated memory
SEE ALSO
SDL_PixelFormat
SDL Tue 11 Sep 2001, 23:01 SDL_Surface(3)
Check Out this Related Man Page
pods::SDL::Surface(3pm) User Contributed Perl Documentation pods::SDL::Surface(3pm)NAME
SDL::Surface - Graphic surface structure
CATEGORY
Core, Video, Structure
SYNOPSIS
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);
DESCRIPTION
An "SDL_Surface" defines a surfaceangular area of pixels.
CONSTANTS
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
METHODS
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
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.
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 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.
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!
get_pixels_ptr
my $ptr = $surface->get_pixels_ptr;
Returns a reference to the surface's pixels.
SEE ALSO
SDL, SDL::PixelFormat, SDL::Video, SDL::Rect
AUTHORS
See "AUTHORS" in SDL.
perl v5.14.2 2012-05-28 pods::SDL::Surface(3pm)