This function returns a read-only structure containing information about the video hardware. If it is called before SDL::Video::set_video_mode, the vfmt member of the returned structure will contain the pixel format of the best video mode.

Example:

use SDL;
use SDL::Video;
use SDL::VideoInfo;
use SDL::PixelFormat;
SDL::init(SDL_INIT_VIDEO);
my $video_info = SDL::Video::get_video_info();
printf( "we can have %dbits per pixel\n", $video_info->vfmt->BitsPerPixel );

This function is used to check whether the requested mode is supported by the current video device. The arguments passed to this function are the same as those you would pass to SDL::Video::set_video_mode. It returns 0 if the mode is not supported at all, otherwise the suggested bpp.

Sets up a video mode with the specified width, height, bits-per-pixel and flags. set_video_mode returns a SDL::Surface on success otherwise it returns undef on error, the error message is retrieved using SDL::get_error.

Normally, if a video surface of the requested bits-per-pixel (bpp) is not available, SDL will emulate one with a shadow surface. Passing SDL_ANYFORMAT prevents this and causes SDL to use the video surface, regardless of its pixel depth.

Enable hardware double buffering; only valid with SDL_HWSURFACE. Calling SDL::Video::flip will flip the buffers and update the screen. All drawing will take place on the surface that is not displayed at the moment. If double buffering could not be enabled then SDL::Video::flip will just perform a SDL::Video::update_rect on the entire screen.

SDL will attempt to use a fullscreen mode. If a hardware resolution change is not possible (for whatever reason), the next higher resolution will be used and the display window centered on a black background.

Create an OpenGL rendering context, like above, but allow normal blitting operations. The screen (2D) surface may have an alpha channel, and SDL::update_rects must be used for updating changes to the screen surface. NOTE: This option is kept for compatibility only, and will be removed in next versions. Is not recommended for new code.

If possible, SDL_NOFRAME causes SDL to create a window with no title bar or frame decoration. Fullscreen modes automatically have this flag set.

Note 1: Use SDL_SWSURFACE if you plan on doing per-pixel manipulations, or blit surfaces with alpha channels, and require a high framerate. When you use hardware surfaces (by passing the flag SDL_HWSURFACE as parameter), SDL copies the surfaces from video memory to system memory when you lock them, and back when you unlock them. This can cause a major performance hit. Be aware that you may request a hardware surface, but receive a software surface because the video driver doesn't support hardware surface. Many platforms can only provide a hardware surface when using SDL_FULLSCREEN. The SDL_HWSURFACE flag is best used when the surfaces you'll be blitting can also be stored in video memory.

Note 2: If you want to control the position on the screen when creating a windowed surface, you may do so by setting the environment variables SDL_VIDEO_CENTERED=center or SDL_VIDEO_WINDOW_POS=x,y. You can also set them via SDL::putenv.

Note 3: This function should be called in the main thread of your application.

User note 1: Some have found that enabling OpenGL attributes like SDL_GL_STENCIL_SIZE (the stencil buffer size) before the video mode has been set causes the application to simply ignore those attributes, while enabling attributes after the video mode has been set works fine.

User note 2: Also note that, in Windows, setting the video mode resets the current OpenGL context. You must execute again the OpenGL initialization code (set the clear color or the shade model, or reload textures, for example) after calling SDL::set_video_mode. In Linux, however, it works fine, and the initialization code only needs to be executed after the first call to SDL::Video::set_video_mode (although there is no harm in executing the initialization code after each call to SDL::Video::set_video_mode, for example for a multiplatform application).

This function takes a surface and copies it to a new surface of the pixel format and colors of the video framebuffer, suitable for fast blitting onto the display surface. It calls SDL::Video::convert_surface.

If you want to take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and alpha value before calling this function.

If you want an alpha channel, see SDL::Video::display_format_alpha. Return Value

Note: Remember to use a different variable for the returned surface, otherwise you have a memory leak, since the original surface isn't freed.

This function takes a surface and copies it to a new surface of the pixel format and colors of the video framebuffer plus an alpha channel, suitable for fast blitting onto the display surface. It calls SDL::Video::convert_surface.

If you want to take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and alpha value before calling this function.

This function can be used to convert a colorkey to an alpha channel, if the SDL_SRCCOLORKEY flag is set on the surface. The generated surface will then be transparent (alpha=0) where the pixels match the colorkey, and opaque (alpha=255) elsewhere.

Sets the color key (transparent pixel) in a blittable surface and enables or disables RLE blit acceleration. $key can be an integer or an SDL::Color object. If you pass an SDL::Color object SDL::Video::map_RGB will be called on it before setting the color key.

RLE acceleration can substantially speed up blitting of images with large horizontal runs of transparent pixels (i.e., pixels that match the key value). The key must be of the same pixel format as the surface, SDL::Video::map_RGB is often useful for obtaining an acceptable value. If flag is SDL_SRCCOLORKEY then key is the transparent pixel value in the source image of a blit.

If flag is OR'd with SDL_RLEACCEL then the surface will be drawn using RLE acceleration when drawn with SDL::Video::blit_surface. The surface will actually be encoded for RLE acceleration the first time SDL::Video::blit_surface or SDL::Video::display_format|/display_format is called on the surface. If flag is 0, this function clears any current color key.

set_alpha is used for setting the per-surface alpha value and/or enabling and disabling alpha blending.

The surface parameter specifies which SDL::surface whose alpha attributes you wish to adjust. flags is used to specify whether alpha blending should be used ( SDL_SRCALPHA ) and whether the surface should use RLE acceleration for blitting ( SDL_RLEACCEL ). flags can be an OR'd combination of these two options, one of these options or 0. If SDL_SRCALPHA is not passed as a flag then all alpha information is ignored when blitting the surface. The alpha parameter is the per-surface alpha value; a surface need not have an alpha channel to use per-surface alpha and blitting can still be accelerated with SDL_RLEACCEL.

Note: The per-surface alpha value of 128 is considered a special case and is optimised, so it's much faster than other per-surface values.

The source is alpha-blended with the destination using the per-surface alpha value. If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied. The alpha channel of the copied pixels is set to opaque.

The RGB data is copied from the source. If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.

Note: When blitting, the presence or absence of SDL_SRCALPHA is relevant only on the source surface, not the destination. Note: Note that RGBA->RGBA blits (with SDL_SRCALPHA set) keep the alpha of the destination surface. This means that you cannot compose two arbitrary RGBA surfaces this way and get the result you would expect from "overlaying" them; the destination alpha will work as a mask.

Note: Also note that per-pixel and per-surface alpha cannot be combined; the per-pixel alpha is always used if available.

This function performs a fast fill of the given SDL::Rect with the given SDL::PixelFormat. If dest_rect is NULL, the whole surface will be filled with color.

The color should be a pixel of the format used by the surface, and can be generated by the SDL::Video::map_RGB or SDL::Video::map_RGBA|/map_RGBA functions. If the color value contains an alpha value then the destination is simply "filled" with that alpha information, no blending takes place.

If there is a clip rectangle set on the destination (set via SDL::Video::set_clip_rect), then this function will clip based on the intersection of the clip rectangle and the dstrect rectangle, and the dstrect rectangle will be modified to represent the area actually filled.

If you call this on the video surface (ie: the value of SDL::Video::get_video_surface) you may have to update the video surface to see the result. This can happen if you are using a shadowed surface that is not double buffered in Windows XP using build 1.2.9.

SDL::Video::lock_surface sets up the given SDL::Surface for directly accessing the pixels. Between calls to SDL::lock_surface and SDL::unlock_surface, you can write to ( surface-set_pixels>) and read from ( surface-get_pixels> ), using the pixel format stored in surface-format>. Once you are done accessing the surface, you should use SDL::Video::unlock_surface to release the lock.

Not all surfaces require locking. If SDL::Video::MUSTLOCK evaluates to 0, then reading and writing pixels to the surface can be performed at any time, and the pixel format of the surface will not change. No operating system or library calls should be made between the lock/unlock pairs, as critical system locks may be held during this time. SDL::Video::lock_surface returns 0 on success or -1 on error.

Note: Since SDL 1.1.8, the surface locks are recursive. This means that you can lock a surface multiple times, but each lock must have a matching unlock.

Surfaces that were previously locked using SDL::Video::lock_surface must be unlocked with SDL::Video::unlock_surface. Surfaces should be unlocked as soon as possible. SDL::Video::unlock_surface doesn't return anything.

Sets the clipping rectangle for the given SDL::Surface. When this surface is the destination of a blit, only the area within the clip rectangle will be drawn into. The rectangle pointed to by rect will be clipped to the edges of the surface so that the clip rectangle for a surface can never fall outside the edges of the surface. If rect is NULL the clipping rectangle will be set to the full size of the surface. SDL::Video::set_clip_rect doesn't returns anything.

Gets the clipping rectangle for the given SDL::Surface. When this surface is the destination of a blit, only the area within the clip rectangle is drawn into. The rectangle pointed to by rect will be filled with the clipping rectangle of the surface. SDL::Video::get_clip_rect doesn't returns anything;

This performs a fast blit from the given source SDL::Surface to the given destination SDL::Surface. The width and height in $src_rect determine the size of the copied rectangle. Only the position is used in the $dest_rect (the width and height are ignored). Blits with negative dest_rect coordinates will be clipped properly. If $src_rect is undef, the entire surface is copied. If $dest_rect is undef, then the destination position (upper left corner) is (0, 0). The final blit rectangle is saved in $dest_rect after all clipping is performed ($src_rect is not modified). The blit function should not be called on a locked surface. I.e. when you use your own drawing functions you may need to lock a surface, but this is not the case with SDL::Video::blit_surface. Like most surface manipulation functions in SDL, it should not be used together with OpenGL.

The results of blitting operations vary greatly depending on whether SDL_SRCALPHA is set or not. See SDL::Video::set_alpha for an explanation of how this affects your results. Colorkeying and alpha attributes also interact with surface blitting. SDL::Video::blit_surface doesn't returns anything.

On hardware that supports double-buffering, this function sets up a flip and returns. The hardware will wait for vertical retrace, and then swap video buffers before the next video surface blit or lock will return. On hardware that doesn't support double-buffering or if SDL_SWSURFACE was set, this is equivalent to calling SDL::Video::update_rect( $screen, 0, 0, 0, 0 ).

A software screen surface is also updated automatically when parts of a SDL window are redrawn, caused by overlapping windows or by restoring from an iconified state. As a result there is no proper double buffer behavior in windowed mode for a software screen, in contrast to a full screen software mode.

The SDL_DOUBLEBUF flag must have been passed to SDL::Video::set_video_mode, when setting the video mode for this function to perform hardware flipping.

When surface is the surface associated with the current display, the display colormap will be updated with the requested colors. If SDL_HWPALETTE was set in SDL::Video::set_video_mode flags, SDL::Video::set_colors will always return 1, and the palette is guaranteed to be set the way you desire, even if the window colormap has to be warped or run under emulation. The color components of a SDL::Color structure are 8-bits in size, giving you a total of 2563 = 16777216 colors. Palettized (8-bit) screen surfaces with the SDL_HWPALETTE flag have two palettes, a logical palette that is used for mapping blits to/from the surface and a physical palette (that determines how the hardware will map the colors to the display). SDL::Video::set_colors modifies both palettes (if present), and is equivalent to calling SDL::Video::set_palette with the flags set to ( SDL_LOGPAL | SDL_PHYSPAL ).

If surface is not a palettized surface, this function does nothing, returning 0. If all of the colors were set as passed to SDL::Video::set_colors, it will return 1. If not all the color entries were set exactly as given, it will return 0, and you should look at the surface palette to determine the actual color palette.

Palettized (8-bit) screen surfaces with the SDL_HWPALETTE flag have two palettes, a logical palette that is used for mapping blits to/from the surface and a physical palette (that determines how the hardware will map the colors to the display). Non screen surfaces have a logical palette only. SDL::Video::blit always uses the logical palette when blitting surfaces (if it has to convert between surface pixel formats). Because of this, it is often useful to modify only one or the other palette to achieve various special color effects (e.g., screen fading, color flashes, screen dimming).

This function can modify either the logical or physical palette by specifying SDL_LOGPAL or SDL_PHYSPAL the in the flags parameter.

When surface is the surface associated with the current display, the display colormap will be updated with the requested colors. If SDL_HWPALETTE was set in SDL::Video::set_video_mode flags, SDL::Video::set_palette will always return 1, and the palette is guaranteed to be set the way you desire, even if the window colormap has to be warped or run under emulation. The color components of a SDL::Color structure are 8-bits in size, giving you a total of 2563 = 16777216 colors.

If surface is not a palettized surface, this function does nothing, returning 0. If all of the colors were set as passed to set_palette, it will return 1. If not all the color entries were set exactly as given, it will return 0, and you should look at the surface palette to determine the actual color palette.

Sets the "gamma function" for the display of each color component. Gamma controls the brightness/contrast of colors displayed on the screen. A gamma value of 1.0 is identity (i.e., no adjustment is made).

This function adjusts the gamma based on the "gamma function" parameter, you can directly specify lookup tables for gamma adjustment with SDL::set_gamma_ramp.

Sets the gamma lookup tables for the display for each color component. Each table is an array ref of 256 Uint16 values, representing a mapping between the input and output for that channel. The input is the index into the array, and the output is the 16-bit gamma value at that index, scaled to the output color precision. You may pass NULL to any of the channels to leave them unchanged.

This function adjusts the gamma based on lookup tables, you can also have the gamma calculated based on a "gamma function" parameter with SDL::Video::set_gamma.

Not all display hardware is able to change gamma. SDL::Video::set_gamma_ramp returns -1 on error (or if gamma adjustment is not supported).

Maps the RGB color value to the specified SDL::PixelFormat and returns the pixel value as a 32-bit int. If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned. If the specified pixel format has an alpha component it will be returned as all 1 bits (fully opaque).

SDL::Video::map_RGB returns a pixel value best approximating the given RGB color value for a given pixel format. If the SDL::PixelFormat's bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).

Maps the RGBA color value to the specified SDL::PixelFormat and returns the pixel value as a 32-bit int. If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned. If the specified pixel format has no alpha component the alpha value will be ignored (as it will be in formats with a palette).

A pixel value best approximating the given RGBA color value for a given pixel format. If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).

Returns the address of the GL function proc, or NULL if the function is not found. If the GL library is loaded at runtime, with SDL::Video::GL_load_library, then all GL functions must be retrieved this way. Usually this is used to retrieve function pointers to OpenGL extensions. Note that this function needs an OpenGL context to function properly, so it should be called after SDL::Video::set_video_mode has been called (with the SDL_OPENGL flag).

It returns SDL/OpenGL attribute attr. This is useful after a call to SDL::Video::set_video_mode to check whether your attributes have been set as you expected. SDL::Video::GL_get_attribute returns undef if the attribute is not found.

This function sets the given OpenGL attribute attr to value. The requested attributes will take effect after a call to SDL::Video::set_video_mode. You should use SDL::Video::GL_get_attribute|/GL_get_attribute to check the values after a SDL::Video::set_video_mode call, since the values obtained can differ from the requested ones.

Available attributes:

SDL_GL_RED_SIZE

SDL_GL_GREEN_SIZE

SDL_GL_BLUE_SIZE

SDL_GL_ALPHA_SIZE

SDL_GL_BUFFER_SIZE

SDL_GL_DOUBLEBUFFER

SDL_GL_DEPTH_SIZE

SDL_GL_STENCIL_SIZE

SDL_GL_ACCUM_RED_SIZE

SDL_GL_ACCUM_GREEN_SIZE

SDL_GL_ACCUM_BLUE_SIZE

SDL_GL_ACCUM_ALPHA_SIZE

SDL_GL_STEREO

SDL_GL_MULTISAMPLEBUFFERS

SDL_GL_MULTISAMPLESAMPLES

SDL_GL_ACCELERATED_VISUAL

SDL_GL_SWAP_CONTROL

GL_set_attribute returns 0 on success or -1 on error.

Note: The SDL_DOUBLEBUF flag is not required to enable double buffering when setting an OpenGL video mode. Double buffering is enabled or disabled using the SDL_GL_DOUBLEBUFFER attribute.

Blit the overlay to the display surface specified when the overlay was created. The SDL::Rect structure, dstrect, specifies a rectangle on the display where the overlay is drawn. The x and y fields of dstrect specify the upper left location in display coordinates. The overlay is scaled (independently in x and y dimensions) to the size specified by dstrect, and is optimized for 2x scaling

title is a UTF-8 encoded null-terminated string which will serve as the window title (the text at the top of the window). The function does not change the string. You may free the string after the function returns.

icon is a UTF-8 encoded null-terminated string which will serve as the iconified window title (the text which is displayed in the menu bar or desktop when the window is minimized). As with title this string may be freed after the function returns.

If the application is running in a window managed environment SDL attempts to iconify/minimise it. If wm_iconify_window is successful, the application will receive a SDL_APPACTIVE loss event (see Application visibility events at SDL::Event).

Returns non-zero on success or 0 if iconification is not supported or was refused by the window manager.