1SDL::Surface(3)       User Contributed Perl Documentation      SDL::Surface(3)
2
3
4

NAME

6       SDL::Surface - Graphic surface structure
7

CATEGORY

9       Core, Video, Structure
10

SYNOPSIS

12        use SDL;
13        use SDL::Video;
14        use SDL::Surface;
15
16        # Create the main surface (display)
17        SDL::init(SDL_INIT_VIDEO);
18        my $display = SDL::Video::set_video_mode(640, 480, 16, SDL_SWSURFACE);
19
20        # Create other surfaces attached to the $display.
21        my $surface  = SDL::Surface->new(SDL_ASYNCBLIT | SDL_HWSURFACE, 640, 480, 16, 0, 0, 0, 0);
22        my $surface2 = SDL::Surface->new_from($surface, 100, 100, 8, 0, 0, 0, 0);
23

DESCRIPTION

25       An "SDL_Surface" defines a surfaceangular area of pixels.
26

CONSTANTS

28       The constants for SDL::Surface belong to SDL::Video, under the export
29       tag of ':surface'.
30
31       SDL_ASYNCBLIT
32           Use asynchronous blit if possible
33
34       SDL_SWSURFACE
35           Store in system memory
36
37       SDL_HWSURFACE
38           Store in video memory
39

METHODS

41   new
42        my $surface = SDL::Surface->new(
43            $flags, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask
44        );
45
46       The constructor creates a new surface with the specified parameter
47       values.
48
49       The four mask values are the bits that the channel will ignore.  For
50       example, an Rmask of 0xFF will ignore that channel completely, making
51       everything on the surface more green/blue.
52
53   new_from
54        my $surface = SDL::Surface->new_from(
55            $surface, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask
56        );
57
58       The constructor creates a new surface with the specified parameter
59       values.  The flags are taken from the specified $surface.
60
61   w
62        my $w = $surface->w;
63
64       Returns the width of the surface.  SDL::Surface width is defined at
65       construction so this is read-only.
66
67   h
68        my $h = $surface->h;
69
70       Returns the height of the surface.  SDL::Surface height is defined at
71       construction so this is read-only.
72
73   format
74        my $format = $surface->format;
75
76       The format of the pixels stored in the surface.  See SDL::PixelFormat
77
78   pitch
79        my $pitch = $surface->pitch;
80
81       The scanline length in bytes.
82

Direct Write to Surface Pixel

84       Disclaimer: The following methods can be very slow, making them
85       suitable for creating surfaces, but not for animations
86
87   get_pixel
88        my $pixel = $surface->get_pixel( $offset )
89
90       Returns the numeric pixel value for the given $offset.  The pixel value
91       depends on current pixel format.
92
93       Note: For surfaces with a palette (1 byte per pixel) the palette index
94       is returned instead of color values.
95
96   set_pixels
97        $surface->set_pixels( $offset, $value );
98
99       Sets the pixel $value to the given $offset.  The pixel value must fit
100       the pixel format of the surface.
101
102       Note: For surfaces with a palette (1 byte per pixel) the palette index
103       must be passed instead of color values.
104
105       Example:
106
107        sub putpixel {
108            my ($x, $y, $color) = @_;
109            $display->set_pixels( $x + $y * $display->w, $color);
110        }
111
112       See also examples/pixel_operations/sols/ch02.pl!
113
114   get_pixels_ptr
115        my $ptr = $surface->get_pixels_ptr;
116
117       Returns a reference to the surface's pixels.
118

SEE ALSO

120       SDL, SDL::PixelFormat, SDL::Video, SDL::Rect
121

AUTHORS

123       See "AUTHORS" in SDL.
124
125
126
127perl v5.32.0                      2020-07-28                   SDL::Surface(3)
Impressum