NAME
SDL2 - FFI Wrapper for SDL (Simple DirectMedia Layer) Development Library
SYNOPSIS
use SDL2 qw[:all];
die 'Error initializing SDL: ' . SDL_GetError() unless SDL_Init(SDL_INIT_VIDEO) == 0;
my $win = SDL_CreateWindow( 'Example window!',
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE );
die 'Could not create window: ' . SDL_GetError() unless $win;
my $event = SDL2::Event->new;
SDL_Init(SDL_INIT_VIDEO);
my $renderer = SDL_CreateRenderer( $win, -1, 0 );
SDL_SetRenderDrawColor( $renderer, 242, 242, 242, 255 );
do {
SDL_WaitEventTimeout( $event, 10 );
SDL_RenderClear($renderer);
SDL_RenderPresent($renderer);
} until $event->type == SDL_QUIT;
SDL_DestroyRenderer($renderer);
SDL_DestroyWindow($win);
exit SDL_Quit();
DESCRIPTION
SDL2 is an FFI::Platypus-backed wrapper around the Simple DirectMedia Layer - a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware.
Getting Started
The SDL2 module exports a high-level, Perl-like abstraction to use the SDL library.
To get started, you must initialize the subsystems you need:
use SDL2;
SDL_Init(SDL_INIT_VIDEO);
Initialization and Shutdown
The functions in this category are used to set up SDL for use and generally
have global effects in your program. These functions may be imported with the
:default tag.
SDL_Init( ... )
Initialize the SDL library.
SDL_Init( ... ) simply forwards to calling SDL_InitSubSystem( ... ). Therefore, the two may be used
interchangeably. Though for readability of your code SDL_InitSubSystem( ... ) might be preferred.
The file I/O (for example: SDL_RWFromFile) and threading (SDL_CreateThread) subsystems are initialized by default. Message boxes (SDL_ShowSimpleMessageBox) also attempt to work without initializing the video subsystem, in hopes of being useful in showing an error dialog when SDL_Init fails. You must specifically initialize other subsystems if you use them in your application.
Logging (such as SDL_Log) works without initialization, too.
Expected parameters include:
flagswhich may be any be imported with the:inittag and may be OR'd together.
Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem( ... ) for each SDL_InitSubSystem( ... ) to correctly shutdown a subsystem manually
(or call SDL_Quit( ) to force shutdown). If a
subsystem is already loaded then this call will increase the ref-count and
return.
Returns 0 on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_InitSubSystem( ... )
Compatibility function to initialize the SDL library.
In SDL2, this function and SDL_Init( ... ) are
interchangeable.
Expected parameters include:
flagswhich may be any be imported with the:inittag and may be OR'd together.
Returns 0 on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_Quit( )
Clean up all initialized subsystems.
You should call this function even if you have already shutdown each
initialized subsystem with SDL_QuitSubSystem( ). It is safe to call this function even in the case of errors in
initialization.
If you start a subsystem using a call to that subsystem's init function (for
example SDL_VideoInit( )) instead of SDL_Init( ... ) or SDL_InitSubSystem( ... ), then you must use that subsystem's quit
function (SDL_VideoQuit( )) to shut it down
before calling SDL_Quit( ). But generally, you should not be using those
functions directly anyhow; use SDL_Init( ... )
instead.
You can use this function in an END { ... } block to ensure that it is run
when your application is shutdown.
SDL_QuitSubSystem( ... )
Shut down specific SDL subsystems.
If you start a subsystem using a call to that subsystem's init function (for
example SDL_VideoInit( ) ) instead of SDL_Init( ... ) or SDL_InitSubSystem( ... ), SDL_QuitSubSystem( ... ) and SDL_WasInit( ... ) will not work. You will need to use that
subsystem's quit function ( SDL_VideoQuit( )
directly instead. But generally, you should not be using those functions
directly anyhow; use SDL_Init( ... ) instead.
You still need to call SDL_Quit( ) even if you close
all open subsystems with SDL_QuitSubSystem( ... ).
Expected parameters include:
flagswhich may be any be imported with the:inittag and may be OR'd together.
SDL_WasInit( ... )
Get a mask of the specified subsystems which are currently initialized.
Expected parameters include:
flagswhich may be any be imported with the:inittag and may be OR'd together.
If flags is 0, it returns a mask of all initialized subsystems, otherwise
it returns the initialization status of the specified subsystems.
The return value does not include SDL_INIT_NOPARACHUTE.
Configuration Variables
This category contains functions to set and get configuration hints, as well as listing each of them alphabetically.
The convention for naming hints is SDL_HINT_X, where SDL_X is the
environment variable that can be used to override the default.
In general these hints are just that - they may or may not be supported or applicable on any given platform, but they provide a way for an application or user to give the library a hint as to how they would like the library to work.
SDL_SetHintWithPriority( ... )
Set a hint with a specific priority.
SDL_SetHintWithPriority( SDL_EVENT_LOGGING, 2, SDL_HINT_OVERRIDE );
The priority controls the behavior when setting a hint that already has a value. Hints will replace existing hints of their priority and lower. Environment variables are considered to have override priority.
Expected parameters include:
-
namethe hint to set
-
valuethe value of the hint variable
-
prioritythe priority level for the hint
Returns a true if the hint was set, untrue otherwise.
SDL_SetHint( ... )
Set a hint with normal priority.
SDL_SetHint( SDL_HINT_XINPUT_ENABLED, 1 );
Hints will not be set if there is an existing override hint or environment variable that takes precedence. You can use SDL_SetHintWithPriority( ) to set the hint with override priority instead.
Expected parameters:
-
namethe hint to set
-
valuethe value of the hint variable
Returns a true value if the hint was set, untrue otherwise.
SDL_GetHint( ... )
Get the value of a hint.
SDL_GetHint( SDL_HINT_XINPUT_ENABLED );
Expected parameters:
-
namethe hint to query
Returns the string value of a hint or an undefined value if the hint isn't set.
SDL_GetHintBoolean( ... )
Get the boolean value of a hint variable.
SDL_GetHintBoolean( SDL_HINT_XINPUT_ENABLED, 0);
Expected parameters:
-
namethe name of the hint to get the boolean value from
-
default_valuethe value to return if the hint does not exist
Returns the boolean value of a hint or the provided default value if the hint does not exist.
SDL_AddHintCallback( ... )
Add a function to watch a particular hint.
my $cb = SDL_AddHintCallback(
SDL_HINT_XINPUT_ENABLED,
sub {
my ($userdata, $name, $oldvalue, $newvalue) = @_;
...;
},
{ time => time( ), clicks => 3 }
);
Expected parameters:
-
namethe hint to watch
-
callbacka code reference that will be called when the hint value changes
-
userdataa pointer to pass to the callback function
Returns a pointer to a FFI::Platypus::Closure which you may pass to SDL_DelHintCallback( ... ).
SDL_DelHintCallback( ... )
Remove a callback watching a particular hint.
SDL_AddHintCallback(
SDL_HINT_XINPUT_ENABLED,
$cb,
{ time => time( ), clicks => 3 }
);
Expected parameters:
-
namethe hint to watch
-
callbackFFI::Platypus::Closure object returned by
SDL_AddHintCallback( ... ) -
userdataa pointer to pass to the callback function
SDL_ClearHints( )
Clear all hints.
SDL_ClearHints( );
This function is automatically called during SDL_Quit( ).
Error Handling
Functions in this category provide simple error message routines for SDL. SDL_GetError( ) can be called for almost all SDL
functions to determine what problems are occurring. Check the wiki page of each
specific SDL function to see whether SDL_GetError( ) is meaningful for them or not.
The SDL error messages are in English.
SDL_SetError( ... )
Set the SDL error message for the current thread.
Calling this function will replace any previous error message that was set.
This function always returns -1, since SDL frequently uses -1 to signify
an failing result, leading to this idiom:
if ($error_code) {
return SDL_SetError( 'This operation has failed: %d', $error_code );
}
Expected parameters:
-
fmta
printf( )-style message format string -
@paramsadditional parameters matching % tokens in the
fmtstring, if any
SDL_GetError( )
Retrieve a message about the last error that occurred on the current thread.
warn SDL_GetError( );
It is possible for multiple errors to occur before calling SDL_GetError( ).
Only the last error is returned.
The message is only applicable when an SDL function has signaled an error. You
must check the return values of SDL function calls to determine when to
appropriately call SDL_GetError( ). You should not use the results of
SDL_GetError( ) to decide if an error has occurred! Sometimes SDL will set
an error string even when reporting success.
SDL will not clear the error string for successful API calls. You must check return values for failure cases before you can assume the error string applies.
Error strings are set per-thread, so an error set in a different thread will not interfere with the current thread's operation.
The returned string is internally allocated and must not be freed by the application.
Returns a message with information about the specific error that occurred, or
an empty string if there hasn't been an error message set since the last call
to SDL_ClearError( ). The message is only
applicable when an SDL function has signaled an error. You must check the
return values of SDL function calls to determine when to appropriately call
SDL_GetError( ).
SDL_GetErrorMsg( ... )
Get the last error message that was set for the current thread.
my $x;
warn SDL_GetErrorMsg($x, 300);
This allows the caller to copy the error string into a provided buffer, but
otherwise operates exactly the same as SDL_GetError( ).
-
errstrA buffer to fill with the last error message that was set for the current thread
-
maxlenThe size of the buffer pointed to by the errstr parameter
Returns the pointer passed in as the errstr parameter.
SDL_ClearError( )
Clear any previous error message for this thread.
Log Handling
Simple log messages with categories and priorities.
By default, logs are quiet but if you're debugging SDL you might want:
SDL_LogSetAllPriority( SDL_LOG_PRIORITY_WARN );
Here's where the messages go on different platforms:
Windows debug output stream
Android log output
Others standard error output (STDERR)
Messages longer than the maximum size (4096 bytes) will be truncated.
SDL_LogSetAllPriority( ... )
Set the priority of all log categories.
SDL_LogSetAllPriority( SDL_LOG_PRIORITY_WARN );
Expected parameters:
-
priorityThe SDL_LogPriority to assign. These may be imported with the
:logprioritytag.
SDL_LogSetPriority( ... )
Set the priority of all log categories.
SDL_LogSetPriority( SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN );
Expected parameters:
-
categoryThe category to assign a priority to. These may be imported with the
:logcategorytag. -
priorityThe SDL_LogPriority to assign. These may be imported with the
:logprioritytag.
SDL_LogGetPriority( ... )
Get the priority of a particular log category.
SDL_LogGetPriority( SDL_LOG_CATEGORY_ERROR );
Expected parameters:
-
categoryThe SDL_LogCategory to query. These may be imported with the
:logcategorytag.
SDL_LogGetPriority( ... )
Get the priority of a particular log category.
SDL_LogGetPriority( SDL_LOG_CATEGORY_ERROR );
Expected parameters:
-
categoryThe SDL_LogCategory to query. These may be imported with the
:logcategorytag.
SDL_LogResetPriorities( )
Reset all priorities to default.
SDL_LogResetPriorities( );
This is called by SDL_Quit( ).
SDL_Log( ... )
Log a message with SDL_LOG_CATEGORY_APPLICATION and
SDL_LOG_PRIORITY_INFO.
SDL_Log( 'HTTP Status: %s', $http->status );
Expected parameters:
-
fmtA
sprintf( )style message format string. -
...Any additional parameters matching
%tokens in thefmtstring, if any.
SDL_LogVerbose( ... )
Log a message with SDL_LOG_PRIORITY_VERBOSE.
SDL_LogVerbose( 'Current time: %s [%ds exec]', +localtime( ), time - $^T );
Expected parameters:
-
categoryThe category of the message.
-
fmtA
sprintf( )style message format string. -
...Additional parameters matching
%tokens in thefmtstring, if any.
SDL_LogDebug( ... )
Log a message with SDL_LOG_PRIORITY_DEBUG.
SDL_LogDebug( 'Current time: %s [%ds exec]', +localtime( ), time - $^T );
Expected parameters:
-
categoryThe category of the message.
-
fmtA
sprintf( )style message format string. -
...Additional parameters matching
%tokens in thefmtstring, if any.
SDL_LogInfo( ... )
Log a message with SDL_LOG_PRIORITY_INFO.
SDL_LogInfo( 'Current time: %s [%ds exec]', +localtime( ), time - $^T );
Expected parameters:
-
categoryThe category of the message.
-
fmtA
sprintf( )style message format string. -
...Additional parameters matching
%tokens in thefmtstring, if any.
SDL_LogWarn( ... )
Log a message with SDL_LOG_PRIORITY_WARN.
SDL_LogWarn( 'Current time: %s [%ds exec]', +localtime( ), time - $^T );
Expected parameters:
-
categoryThe category of the message.
-
fmtA
sprintf( )style message format string. -
...Additional parameters matching
%tokens in thefmtstring, if any.
SDL_LogError( ... )
Log a message with SDL_LOG_PRIORITY_ERROR.
SDL_LogError( 'Current time: %s [%ds exec]', +localtime( ), time - $^T );
Expected parameters:
-
categoryThe category of the message.
-
fmtA
sprintf( )style message format string. -
...Additional parameters matching
%tokens in thefmtstring, if any.
SDL_LogCritical( ... )
Log a message with SDL_LOG_PRIORITY_CRITICAL.
SDL_LogCritical( 'Current time: %s [%ds exec]', +localtime( ), time - $^T );
Expected parameters:
-
categoryThe category of the message.
-
fmtA
sprintf( )style message format string. -
...Additional parameters matching
%tokens in thefmtstring, if any.
SDL_LogMessage( ... )
Log a message with the specified category and priority.
SDL_LogMessage( SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_CRITICAL,
'Current time: %s [%ds exec]', +localtime( ), time - $^T );
Expected parameters:
-
categoryThe category of the message.
-
priorityThe priority of the message.
-
fmtA
sprintf( )style message format string. -
...Additional parameters matching
%tokens in thefmtstring, if any.
SDL_LogSetOutputFunction( ... )
Replace the default log output function with one of your own.
my $cb = SDL_LogSetOutputFunction( sub { ... }, {} );
Expected parameters:
-
callbackA coderef to call instead of the default callback.
This coderef should expect the following parameters:
-
userdataWhat was passed as
userdatatoSDL_LogSetOutputFunction( ). -
categoryThe category of the message.
-
priorityThe priority of the message.
-
messageThe message being output.
-
-
userdataData passed to the
callback.
Querying SDL Version
These functions are used to collect or display information about the version of SDL that is currently being used by the program or that it was compiled against.
The version consists of three segments (X.Y.Z)
- X - Major Version, which increments with massive changes, additions, and enhancements
- Y - Minor Version, which increments with backwards-compatible changes to the major revision
- Z - Patchlevel, which increments with fixes to the minor revision
Example: The first version of SDL 2 was 2.0.0
The version may also be reported as a 4-digit numeric value where the thousands place represents the major version, the hundreds place represents the minor version, and the tens and ones places represent the patchlevel (update version).
Example: The first version number of SDL 2 was 2000
SDL_GetVersion( ... )
Get the version of SDL that is linked against your program.
my $ver = SDL2::Version->new;
SDL_GetVersion( $ver );
This function may be called safely at any time, even before SDL_Init( ).
Expected parameters include:
version- An SDL2::Version object which will be filled with the proper values
Display and Window Management
This category contains functions for handling display and window actions.
These functions may be imported with the :video tag.
SDL_GetNumVideoDrivers( )
my $num = SDL_GetNumVideoDrivers( );
Get the number of video drivers compiled into SDL.
Returns a number >= 1 on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_GetVideoDriver( ... )
Get the name of a built in video driver.
CORE::say SDL_GetVideoDriver($_) for 0 .. SDL_GetNumVideoDrivers( ) - 1;
The video drivers are presented in the order in which they are normally checked during initialization.
Expected parameters include:
index- the index of a video driver
Returns the name of the video driver with the given index.
SDL_VideoInit( ... )
Initialize the video subsystem, optionally specifying a video driver.
SDL_VideoInit( 'x11' );
This function initializes the video subsystem, setting up a connection to the window manager, etc, and determines the available display modes and pixel formats, but does not initialize a window or graphics mode.
If you use this function and you haven't used the SDL_INIT_VIDEO flag with either SDL_Init( ) or SDL_InitSubSystem( ), you should call SDL_VideoQuit( ) before calling SDL_Quit( ).
It is safe to call this function multiple times. SDL_VideoInit( ) will call SDL_VideoQuit( ) itself if the video subsystem has already been initialized.
You can use SDL_GetNumVideoDrivers( ) and SDL_GetVideoDriver( ) to find a specific `driver_name`.
Expected parameters include:
driver_name- the name of a video driver to initialize, or undef for the default driver
Returns 0 on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_VideoQuit( )
Shut down the video subsystem, if initialized with SDL_VideoInit( ).
SDL_VideoQuit( );
This function closes all windows, and restores the original video mode.
SDL_GetCurrentVideoDriver( )
Get the name of the currently initialized video driver.
my $driver = SDL_GetCurrentVideoDriver( );
Returns the name of the current video driver or NULL if no driver has been initialized.
SDL_GetNumVideoDisplays( )
Get the number of available video displays.
my $screens = SDL_GetNumVideoDisplays( );
Returns a number >= 1 or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_GetDisplayName( ... )
Get the name of a display in UTF-8 encoding.
my $screen = SDL_GetDisplayName( 0 );
Expected parameters include:
displayIndex- the index of display from which the name should be queried
Returns the name of a display or undefined for an invalid display index or
failure; call SDL_GetError( ) for more
information.
SDL_GetDisplayBounds( ... )
Get the desktop area represented by a display.
my $rect = SDL_GetDisplayBounds( 0 );
The primary display (displayIndex == 0) is always located at 0,0.
Expected parameters include:
displayIndex- the index of the display to query
Returns the SDL2::Rect structure filled in with the display bounds on success
or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_GetDisplayUsableBounds( ... )
Get the usable desktop area represented by a display.
my $rect = SDL_GetDisplayUsableBounds( 0 );
The primary display (displayIndex == 0) is always located at 0,0.
This is the same area as SDL_GetDisplayBounds( ... ) reports, but with portions reserved by
the system removed. For example, on Apple's macOS, this subtracts the area
occupied by the menu bar and dock.
Setting a window to be fullscreen generally bypasses these unusable areas, so these are good guidelines for the maximum space available to a non-fullscreen window.
Expected parameters include:
displayIndex- the index of the display to query
Returns the SDL2::Rect structure filled in with the display bounds on success
or a negative error code on failure; call SDL_GetError( ) for more information. This function also returns
-1 if the parameter displayIndex is out of range.
SDL_GetDisplayDPI( ... )
Get the dots/pixels-per-inch for a display.
my ( $ddpi, $hdpi, $vdpi ) = SDL_GetDisplayDPI( 0 );
Diagonal, horizontal and vertical DPI can all be optionally returned if the appropriate parameter is non-NULL.
A failure of this function usually means that either no DPI information is
available or the displayIndex is out of range.
Expected parameters include:
displayIndex- the index of the display from which DPI information should be queried
Returns [ddpi, hdpi, vdip] on success or a negative error code on failure;
call SDL_GetError( ) for more information.
ddpi is the diagonal DPI of the display, hdpi is the horizontal DPI of
the display, vdpi is the vertical DPI of the display.
SDL_GetDisplayOrientation( ... )
Get the orientation of a display.
my $orientation = SDL_GetDisplayOrientation( 0 );
Expected parameters include:
displayIndex- the index of the display to query
Returns a value which may be imported with :displayOrientation or
SDL_ORIENTATION_UNKNOWN if it isn't available.
SDL_GetNumDisplayModes( ... )
Get the number of available display modes.
my $modes = SDL_GetNumDisplayModes( 0 );
The displayIndex needs to be in the range from 0 to
SDL_GetNumVideoDisplays( ) - 1.
Expected parameters include:
displayIndex- the index of the display to query
Returns a number >= 1 on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_GetDisplayMode( ... )
Get information about a specific display mode.
my $mode = SDL_GetDisplayMode( 0, 0 );
The display modes are sorted in this priority:
- width - largest to smallest
- height - largest to smallest
- bits per pixel - more colors to fewer colors
- packed pixel layout - largest to smallest
- refresh rate - highest to lowest
Expected parameters include:
displayIndex- the index of the display to querymodeIndex- the index of the display mode to query
Returns an SDL2::DisplayMode structure filled in with the mode at
modeIndex on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_GetDesktopDisplayMode( ... )
Get information about the desktop's display mode.
my $mode = SDL_GetDesktopDisplayMode( 0 );
There's a difference between this function and SDL_GetCurrentDisplayMode( ... ) when SDL runs fullscreen and has
changed the resolution. In that case this function will return the previous
native display mode, and not the current display mode.
Expected parameters include:
displayIndex- the index of the display to query
Returns an SDL2::DisplayMode structure filled in with the current display
mode on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_GetCurrentDisplayMode( ... )
my $mode = SDL_GetCurrentDisplayMode( 0 );
There's a difference between this function and SDL_GetDesktopDisplayMode( ... ) when SDL runs fullscreen and has
changed the resolution. In that case this function will return the current
display mode, and not the previous native display mode.
Expected parameters include:
displayIndex- the index of the display to query
Returns an SDL2::DisplayMode structure filled in with the current display
mode on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_GetClosestDisplayMode( ... )
Get the closes match to the requested display mode.
$mode = SDL_GetClosestDisplayMode( 0, $mode );
The available display modes are scanned and he closest mode matching the requested mode is returned. The mode format and refresh rate default to the desktop mode if they are set to 0. The modes are scanned with size being first priority, format being second priority, and finally checking the refresh rate. If all the available modes are too small, then an undefined value is returned.
Expected parameters include:
displayIndex- index of the display to querymode- an SDL2::DisplayMode structure containing the desired display modeclosest- an SDL2::DisplayMode structure filled in with the closest match of the available display modes
Returns the passed in value closest or an undefined value if no matching
video mode was available; call SDL_GetError( )
for more information.
SDL_GetWindowDisplayIndex( ... )
Get the index of the display associated with a window.
my $index = SDL_GetWindowDisplayIndex( $window );
Expected parameters include:
window- the window to query
Returns the index of the display containing the center of the window on success
or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_SetWindowDisplayMode( ... )
Set the display mode to use when a window is visible at fullscreen.
my $ok = !SDL_SetWindowDisplayMode( $window, $mode );
This only affects the display mode used when the window is fullscreen. To
change the window size when the window is not fullscreen, use SDL_SetWindowSize( ... ).
SDL_GetWindowDisplayMode( ... )
Query the display mode to use when a window is visible at fullscreen.
my $mode = SDL_GetWindowDisplayMode( $window );
Expected parameters include:
window- the window to query
Returns a SDL2::DisplayMode structure on success or a negative error code on
failure; call SDL_GetError( ) for more
information.
SDL_GetWindowPixelFormat( ... )
Get the pixel format associated with the window.
my $format = SDL_GetWindowPixelFormat( $window );
Expected parameters include:
window- the window to query
Returns the pixel format of the window on success or SDL_PIXELFORMAT_UNKNOWN
on failure; call SDL_GetError( ) for more
information.
SDL_CreateWindow( ... )
Create a window with the specified position, dimensions, and flags.
my $window = SDL_CreateWindow( 'Example',
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
1280, 720,
SDL_WINDOW_SHOWN
);
flags may be any of the following OR'd together:
SDL_WINDOW_FULLSCREEN- fullscreen windowSDL_WINDOW_FULLSCREEN_DESKTOP- fullscreen window at desktop resolutionSDL_WINDOW_OPENGL- window usable with an OpenGL contextSDL_WINDOW_VULKAN- window usable with a Vulkan instanceSDL_WINDOW_METAL- window usable with a Metal instanceSDL_WINDOW_HIDDEN- window is not visibleSDL_WINDOW_BORDERLESS- no window decorationSDL_WINDOW_RESIZABLE- window can be resizedSDL_WINDOW_MINIMIZED- window is minimizedSDL_WINDOW_MAXIMIZED- window is maximizedSDL_WINDOW_INPUT_GRABBED- window has grabbed input focusSDL_WINDOW_ALLOW_HIGHDPI- window should be created in high-DPI mode if supported (>= SDL 2.0.1)
SDL_WINDOW_SHOWN is ignored by SDL_CreateWindow( ... ). The SDL_Window is
implicitly shown if SDL_WINDOW_HIDDEN is not set. SDL_WINDOW_SHOWN may be
queried later using SDL_GetWindowFlags( ... ).
On Apple's macOS, you must set the NSHighResolutionCapable Info.plist property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
If the window is created with the SDL_WINDOW_ALLOW_HIGHDPI flag, its size in
pixels may differ from its size in screen coordinates on platforms with
high-DPI support (e.g. iOS and macOS). Use SDL_GetWindowSize( ... ) to query the client area's size in screen
coordinates, and SDL_GL_GetDrawableSize( ) or SDL_GetRendererOutputSize( )
to query the drawable size in pixels.
If the window is set fullscreen, the width and height parameters w and h
will not be used. However, invalid size parameters (e.g. too large) may still
fail. Window size is actually limited to 16384 x 16384 for all platforms at
window creation.
If the window is created with any of the SDL_WINDOW_OPENGL or
SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function
(SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the corresponding
UnloadLibrary function is called by SDL_DestroyWindow( ... ).
If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver,
SDL_CreateWindow( ... ) will fail because SDL_Vulkan_LoadLibrary( ) will fail.
If SDL_WINDOW_METAL is specified on an OS that does not support Metal,
SDL_CreateWindow( ... ) will fail.
On non-Apple devices, SDL requires you to either not link to the Vulkan loader or link to a dynamic library version. This limitation may be removed in a future version of SDL.
Expected parameters include:
title- the title of the window, in UTF-8 encodingx- the x position of the window,SDL_WINDOWPOS_CENTERED, orSDL_WINDOWPOS_UNDEFINEDy- the y position of the window,SDL_WINDOWPOS_CENTERED, orSDL_WINDOWPOS_UNDEFINEDw- the width of the window, in screen coordinatesh- the height of the window, in screen coordinatesflags- 0, or one or moreSDL_WindowFlagsOR'd together
Returns the window that was created or an undefined value on failure; call SDL_GetError( ) for more information.
SDL_CreateWindowFrom( ... )
Create an SDL window from an existing native window.
my $window = SDL_CreateWindowFrom( $data );
In some cases (e.g. OpenGL) and on some platforms (e.g. Microsoft Windows) the
hint SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT needs to be configured before
using SDL_CreateWindowFrom( ... ).
Expected parameters include:
data- driver-dependant window creation data, typically your native window
Returns the window that was created or an undefined value on failure; call SDL_GetError( ) for more information.
SDL_GetWindowID( ... )
Get the numeric ID of a window.
my $id = SDL_GetWindowID( $window );
The numeric ID is what SDL2::WindowEvent references, and is necessary to map these events to specific SDL2::Window objects.
Expected parameters include:
window- the window to query
Returns the ID of the window on success or 0 on failure; call SDL_GetError( ) for more information.
SDL_GetWindowFromID( ... )
Get a window from a stored ID.
my $window = SDL_GetWindowFromID( 2 );
The numeric ID is what SDL2::WindowEvent references, and is necessary to map these events to specific SDL2::Window objects.
Expected parameters include:
id- the ID of the window
Returns the window associated with id or an undefined value if it doesn't
exist; call SDL_GetError( ) for more information.
SDL_GetWindowFlags( ... )
Get the window flags.
my $id = SDL_GetWindowFlags( $window );
The numeric ID is what SDL2::WindowEvent references, and is necessary to map these events to specific SDL2::Window objects.
Expected parameters include:
window- the window to query
Returns a mask of the SDL_WindowFlags associated with window.
SDL_SetWindowTitle( ... )
Set the title of a window.
SDL_SetWindowTitle( $window, 'Untitle file *' );
This string is expected to be in UTF-8 encoding.
Expected parameters include:
window- the window to changetitle- the desired window title in UTF-8 format
SDL_GetWindowTitle( ... )
Get the title of a window.
my $title = SDL_GetWindowTitle( $window );
Expected parameters include:
window- the window to query
Returns the title of the window in UTF-8 format or "" (an empty string) if
there is no title.
SDL_SetWindowIcon( ... )
Set the icon for a window.
SDL_SetWindowIcon( $window, $icon );
Expected parameters include:
window- the window to changeicon- an SDL2::Surface structure containing the icon for the window
SDL_SetWindowData( ... )
Associate an arbitrary named pointer with a window.
my $prev = SDL_SetWindowData( $window, 'test', $data );
Expected parameters include:
window- the window to changename- the name of the pointeruserdata- the associated pointer
Returns the previous value associated with name.
SDL_GetWindowData( ... )
Retrieve the data pointer associated with a window.
my $data = SDL_SetWindowData( $window, 'test' );
Expected parameters include:
window- the window to queryname- the name of the pointer
Returns the value associated with name.
SDL_SetWindowPosition( ... )
Set the position of a window.
SDL_SetWindowPosition( $window, 100, 100 );
The window coordinate origin is the upper left of the display.
Expected parameters include:
window- the window to repositionx- the x coordinate of the window in screen coordinates, orSDL_WINDOWPOS_CENTEREDorSDL_WINDOWPOS_UNDEFINEDy- the y coordinate of the window in screen coordinates, orSDL_WINDOWPOS_CENTEREDorSDL_WINDOWPOS_UNDEFINED
SDL_GetWindowPosition( ... )
Get the position of a window.
my ($x, $y) = SDL_GetWindowPosition( $window );
Expected parameters include:
window- the window to query
Returns the x and y positions of the window, in screen coordinates,
either of which may be undefined.
SDL_SetWindowSize( ... )
Set the size of a window's client area.
SDL_SetWindowSize( $window, 100, 100 );
The window size in screen coordinates may differ from the size in pixels, if
the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with
high-dpi support (e.g. iOS or macOS). Use SDL_GL_GetDrawableSize( ... ) or SDL_GetRendererOutputSize( ... ) to get the real client area size in
pixels.
Fullscreen windows automatically match the size of the display mode, and you
should use SDL_SetWindowDisplayMode( ... ) to change their size.
Expected parameters include:
window- the window to changew- the width of the window in pixels, in screen coordinates, must be > 0h- the height of the window in pixels, in screen coordinates, must be > 0
SDL_GetWindowSize( ... )
Get the position of a window.
my ($w, $h) = SDL_GetWindowSize( $window );
The window size in screen coordinates may differ from the size in pixels, if
the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with
high-dpi support (e.g. iOS or macOS). Use SDL_GL_GetDrawableSize( ... ), SDL_Vulkan_GetDrawableSize( ... ), or SDL_GetRendererOutputSize( ... ) to
get the real client area size in pixels.
Expected parameters include:
window- the window to query the width and height from
Returns the width and height of the window, in screen coordinates, either
of which may be undefined.
SDL_GetWindowBordersSize( ... )
Get the size of a window's borders (decorations) around the client area.
my ($top, $left, $bottom, $right) = SDL_GetWindowBorderSize( $window );
Expected parameters include:
window- the window to query the size values of the border (decorations) from
Returns the top, left, bottom, and right size values, any of which
may be undefined.
Note: If this function fails (returns -1), the size values will be initialized
to 0, 0, 0, 0, as if the window in question was borderless.
Note: This function may fail on systems where the window has not yet been
decorated by the display server (for example, immediately after calling SDL_CreateWindow( ... ) ). It is
recommended that you wait at least until the window has been presented and
composited, so that the window system has a chance to decorate the window and
provide the border dimensions to SDL.
This function also returns -1 if getting the information is not supported.
SDL_SetWindowMinimumSize( ... )
Set the minimum size of a window's client area.
SDL_SetWindowMinimumSize( $window, 100, 100 );
Expected parameters include:
window- the window to changew- the minimum width of the window in pixelsh- the minimum height of the window in pixels
SDL_GetWindowMinimumSize( ... )
Get the minimum size of a window's client area.
my ($w, $h) = SDL_GetWindowMinimumSize( $window );
Expected parameters include:
window- the window to query the minimum width and minimum height from
Returns the minimum width and minimum height of the window, either of
which may be undefined.
SDL_SetWindowMaximumSize( ... )
Set the maximum size of a window's client area.
SDL_SetWindowMaximumSize( $window, 100, 100 );
Expected parameters include:
window- the window to changew- the maximum width of the window in pixelsh- the maximum height of the window in pixels
SDL_GetWindowMaximumSize( ... )
Get the maximum size of a window's client area.
my ($w, $h) = SDL_GetWindowMaximumSize( $window );
Expected parameters include:
window- the window to query the maximum width and maximum height from
Returns the maximum width and maximum height of the window, either of
which may be undefined.
SDL_SetWindowBordered( ... )
Set the border state of a window.
SDL_SetWindowBordered( $window, 1 );
This will add or remove the window's SDL_WINDOW_BORDERLESS flag and add or
remove the border from the actual window. This is a no-op if the window's
border already matches the requested state.
You can't change the border state of a fullscreen window.
Expected parameters include:
window- the window of which to change the border statebordered- false value to remove border, true value to add border
SDL_SetWindowResizable( ... )
Set the user-resizable state of a window.
SDL_SetWindowResizable( $window, 1 );
This will add or remove the window's SDL_WINDOW_RESIZABLE flag and
allow/disallow user resizing of the window. This is a no-op if the window's
resizable state already matches the requested state.
You can't change the resizable state of a fullscreen window.
Expected parameters include:
window- the window of which to change the border statebordered- true value to allow resizing, false value to disallow
SDL_ShowWindow( ... )
Show a window.
SDL_ShowWindow( $window );
Expected parameters include:
window- the window to show
SDL_HideWindow( ... )
Hide a window.
SDL_HideWindow( $window );
Expected parameters include:
window- the window to hide
SDL_RaiseWindow( ... )
Raise a window above other windows and set the input focus.
SDL_RaiseWindow( $window );
Expected parameters include:
window- the window to raise
SDL_MaximizeWindow( ... )
Make a window as large as possible.
SDL_MaximizeWindow( $window );
Expected parameters include:
window- the window to maximize
SDL_MinimizeWindow( ... )
Minimize a window to an iconic representation.
SDL_MinimizeWindow( $window );
Expected parameters include:
window- the window to minimize
SDL_RestoreWindow( ... )
Restore the size and position of a minimized or maximized window.
SDL_RestoreWindow( $window );
Expected parameters include:
window- the window to restore
SDL_SetWindowFullscreen( ... )
Set a window's fullscreen state.
SDL_SetWindowFullscreen( $window, SDL_WINDOW_FULLSCREEN );
Expected parameters include:
window- the window to changeflags-SDL_WINDOW_FULLSCREEN,SDL_WINDOW_FULLSCREEN_DESKTOPor 0
Returns 0 on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_GetWindowSurface( ... )
Get the SDL surface associated with the window.
my $surface = SDL_GetWindowSurface( $window );
A new surface will be created with the optimal format for the window, if necessary. This surface will be freed when the window is destroyed. Do not free this surface.
This surface will be invalidated if the window is resized. After resizing a window this function must be called again to return a valid surface.
You may not combine this with 3D or the rendering API on this window.
This function is affected by SDL_HINT_FRAMEBUFFER_ACCELERATION.
Expected parameters include:
window- the window to query
Returns the surface associated with the window, or an undefined on failure;
call SDL_GetError( ) for more information.
SDL_UpdateWindowSurface( ... )
Copy the window surface to the screen.
my $ok = !SDL_UpdateWindowSurface( $window );
This is the function you use to reflect any changes to the surface on the screen.
Expected parameters include:
window- the window to query
Returns 0 on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_UpdateWindowSurfaceRects( ... )
Copy areas of the window surface to the screen.
SDL_UpdateWindowSurfaceRects( $window, @recs );
This is the function you use to reflect changes to portions of the surface on the screen.
Expected parameters include:
window- the window to updaterects- an array of SDL2::Rect structures representing areas of the surface to copy
Returns 0 on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_SetWindowGrab( ... )
Set a window's input grab mode.
SDL_SetWindowGrab( $window, 1 );
When input is grabbed the mouse is confined to the window.
If the caller enables a grab while another window is currently grabbed, the other window loses its grab in favor of the caller's window.
Expected parameters include:
window- the window for which the input grab mode should be setgrabbed- a true value to grab input or a false value to release input
SDL_SetWindowKeyboardGrab( ... )
Set a window's keyboard grab mode.
SDL_SetWindowKeyboardGrab( $window, 1 );
If the caller enables a grab while another window is currently grabbed, the other window loses its grab in favor of the caller's window.
Expected parameters include:
window- The window for which the keyboard grab mode should be set.grabbed- This is true to grab keyboard, and false to release.
SDL_SetWindowMouseGrab( ... )
Set a window's mouse grab mode.
SDL_SetWindowMouseGrab( $window, 1 );
Expected parameters include:
window- The window for which the mouse grab mode should be set.grabbed- This is true to grab mouse, and false to release.
If the caller enables a grab while another window is currently grabbed, the other window loses its grab in favor of the caller's window.
SDL_GetWindowGrab( ... )
Get a window's input grab mode.
my $grabbing = SDL_GetWindowGrab( $window );
Expected parameters include:
window- the window to query
Returns true if input is grabbed, false otherwise.
SDL_GetWindowKeyboardGrab( ... )
Get a window's keyboard grab mode.
my $keyboard = SDL_GetWindowKeyboardGrab( $window );
Expected parameters include:
window- the window to query
Returns true if keyboard is grabbed, and false otherwise.
SDL_GetWindowMouseGrab( ... )
Get a window's mouse grab mode.
my $mouse = SDL_GetWindowMouseGrab( $window );
Expected parameters include:
window- the window to query
This returns true if mouse is grabbed, and false otherwise.
SDL_GetGrabbedWindow( )
Get the window that currently has an input grab enabled.
my $window = SDL_GetGrabbedWindow( );
Returns the window if input is grabbed or undefined otherwise.
SDL_SetWindowBrightness( ... )
Set the brightness (gamma multiplier) for a given window's display.
my $ok = !SDL_SetWindowBrightness( $window, 2 );
Despite the name and signature, this method sets the brightness of the entire
display, not an individual window. A window is considered to be owned by the
display that contains the window's center pixel. (The index of this display can
be retrieved using SDL_GetWindowDisplayIndex( ... ).) The brightness set will not follow
the window if it is moved to another display.
Many platforms will refuse to set the display brightness in modern times. You are better off using a shader to adjust gamma during rendering, or something similar.
Expected parameters includes:
window- the window used to select the display whose brightness will be changedbrightness- the brightness (gamma multiplier) value to set where 0.0 is completely dark and 1.0 is normal brightness
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GetWindowBrightness( ... )
Get the brightness (gamma multiplier) for a given window's display.
my $gamma = SDL_GetWindowBrightness( $window );
Despite the name and signature, this method retrieves the brightness of the
entire display, not an individual window. A window is considered to be owned by
the display that contains the window's center pixel. (The index of this display
can be retrieved using SDL_GetWindowDisplayIndex( ... ).)
Expected parameters include:
window- the window used to select the display whose brightness will be queried
Returns the brightness for the display where 0.0 is completely dark and 1.0
is normal brightness.
SDL_SetWindowOpacity( ... )
Set the opacity for a window.
SDL_SetWindowOpacity( $window, .5 );
The parameter opacity will be clamped internally between 0.0
(transparent) and 1.0 (opaque).
This function also returns -1 if setting the opacity isn't supported.
Expected parameters include:
window- the window which will be made transparent or opaqueopacity- the opacity value (0.0 - transparent, 1.0 - opaque)
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GetWindowOpacity( ... )
Get the opacity of a window.
my $opacity = SDL_GetWindowOpacity( $window );
If transparency isn't supported on this platform, opacity will be reported as 1.0 without error.
The parameter opacity is ignored if it is undefined.
This function also returns -1 if an invalid window was provided.
Expected parameters include:
window- the window to get the current opacity value from
Returns the current opacity on success or a negative error code on failure;
call SDL_GetError( )( ) for more information.
SDL_SetWindowModalFor( ... )
Set the window as a modal for another window.
my $ok = !SDL_SetWindowModalFor( $winodw, $parent );
Expected parameters include:
modal_window- the window that should be set modalparent_window- the parent window for the modal window
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_SetWindowInputFocus( ... )
Explicitly set input focus to the window.
SDL_SetWindowInputFocus( $window );
You almost certainly want SDL_RaiseWindow( ... ) instead of this function. Use this with caution, as you might give focus
to a window that is completely obscured by other windows.
Expected parameters include:
window- the window that should get the input focus
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_SetWindowGammaRamp( ... )
Set the gamma ramp for the display that owns a given window.
my $ok = !SDL_SetWindowGammaRamp( $window, \@red, \@green, \@blue );
Set the gamma translation table for the red, green, and blue channels of the
video hardware. Each table is an array of 256 16-bit quantities, 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. Despite the name and signature, this method sets
the gamma ramp of the entire display, not an individual window. A window is
considered to be owned by the display that contains the window's center pixel.
(The index of this display can be retrieved using SDL_GetWindowDisplayIndex( ... ).)
The gamma ramp set will not follow the window if it is moved to another
display.
Expected parameters include:
window- the window used to select the display whose gamma ramp will be changedred- a 256 element array of 16-bit quantities representing the translation table for the red channel, or NULLgreen- a 256 element array of 16-bit quantities representing the translation table for the green channel, or NULLblue- a 256 element array of 16-bit quantities representing the translation table for the blue channel, or NULL
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GetWindowGammaRamp( ... )
Get the gamma ramp for a given window's display.
my ($red, $green, $blue) = SDL_GetWindowGammaRamp( $window );
Despite the name and signature, this method retrieves the gamma ramp of the
entire display, not an individual window. A window is considered to be owned by
the display that contains the window's center pixel. (The index of this display
can be retrieved using SDL_GetWindowDisplayIndex( ... ).)
Expected parameters include:
window- the window used to select the display whose gamma ramp will be queried
Returns three 256 element arrays of 16-bit quantities filled in with the
translation table for the red, gree, and blue channels on success or a negative
error code on failure; call SDL_GetError( )( )
for more information.
SDL_SetWindowHitTest( ... )
Provide a callback that decides if a window region has special properties.
SDL_SetWindowHitTest( $window, sub ($win, $point, $data) {
warn sprintf 'Click at x:%d y:%d', $point->x, $point->y;
...;
});
Normally, windows are dragged and resized by decorations provided by the system window manager (a title bar, borders, etc), but for some apps, it makes sense to drag them from somewhere else inside the window itself; for example, one might have a borderless window that wants to be draggable from any part, or simulate its own title bar, etc.
This function lets the app provide a callback that designates pieces of a given window as special. This callback is run during event processing if we need to tell the OS to treat a region of the window specially; the use of this callback is known as "hit testing."
Mouse input may not be delivered to your application if it is within a special area; the OS will often apply that input to moving the window or resizing the window and not deliver it to the application.
Specifying undef for a callback disables hit-testing. Hit-testing is disabled by default.
Platforms that don't support this functionality will return -1
unconditionally, even if you're attempting to disable hit-testing.
Your callback may fire at any time, and its firing does not indicate any specific behavior (for example, on Windows, this certainly might fire when the OS is deciding whether to drag your window, but it fires for lots of other reasons, too, some unrelated to anything you probably care about and when the mouse isn't actually at the location it is testing). Since this can fire at any time, you should try to keep your callback efficient, devoid of allocations, etc.
Expected parameters include:
window- the window to set hit-testing oncallback- the function to call when doing a hit-testcallback_data- an app-defined void pointer passed tocallback
Returns 0 on success or -1 on error (including unsupported); call SDL_GetError( )( ) for more information.
SDL_FlashWindow( ... )
Request a window to give a signal, e.g. a visual signal, to demand attention from the user.
SDL_FlashWindow( $window, 10 );
Expected parameters include:
window- the window to request the flashing forflash_count- number of times the window gets flashed on systems that support flashing the window multiple times, like Windows, else it is ignored
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_DestroyWindow( ... )
Destroy a window.
SDL_DestoryWindow( $window );
If window is undefined, this function will return immediately after setting
the SDL error message to "Invalid window". See SDL_GetError( )( ).
Expected parameters include:
window- the window to destroy
SDL_IsScreenSaverEnabled( ... )
Check whether the screensaver is currently enabled.
my $enabled = SDL_IsScreenSaverEnabled( );
The screensaver is disabled by default since SDL 2.0.2. Before SDL 2.0.2 the screensaver was enabled by default.
The default can also be changed using SDL_HINT_VIDEO_ALLOW_SCREENSAVER.
Returns true if the screensaver is enabled, false if it is disabled.
SDL_EnableScreenSaver( ... )
Allow the screen to be blanked by a screen saver.
SDL_EnableScreenSaver( );
SDL_DisableScreenSaver( ... )
Prevent the screen from being blanked by a screen saver.
SDL_DisableScreenSaver( );
If you disable the screensaver, it is automatically re-enabled when SDL quits.
OpenGL Support Functions
These may be imported with the :opengl tag.
SDL_GL_LoadLibrary( ... )
Dynamically load an OpenGL library.
my $ok = SDL_GL_LoadLibrary( );
This should be done after initializing the video driver, but before creating any OpenGL windows. If no OpenGL library is loaded, the default library will be loaded upon creation of the first OpenGL window.
If you do this, you need to retrieve all of the GL functions used in your
program from the dynamic library using SDL_GL_GetProcAddress( ).
Expected parameters include:
path- the platform dependent OpenGL library name, or undef to open the default OpenGL library
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GL_GetProcAddress( ... )
Get an OpenGL function by name.
my $ptr = SDL_GL_GetProcAddress( 'glGenBuffers' );
...; # TODO
# TODO: In the future, this should return an XSUB loaded with FFI.
If the GL library is loaded at runtime with SDL_GL_LoadLibrary( ... ), then all GL functions must be retrieved
this way. Usually this is used to retrieve function pointers to OpenGL
extensions.
There are some quirks to looking up OpenGL functions that require some extra care from the application. If you code carefully, you can handle these quirks without any platform-specific code, though:
- On Windows, function pointers are specific to the current GL context; this means you need to have created a GL context and made it current before calling SDL_GL_GetProcAddress( ). If you recreate your context or create a second context, you should assume that any existing function pointers aren't valid to use with it. This is (currently) a Windows-specific limitation, and in practice lots of drivers don't suffer this limitation, but it is still the way the wgl API is documented to work and you should expect crashes if you don't respect it. Store a copy of the function pointers that comes and goes with context lifespan.
- On X11, function pointers returned by this function are valid for any
context, and can even be looked up before a context is created at all. This
means that, for at least some common OpenGL implementations, if you look up
a function that doesn't exist, you'll get a non-NULL result that is _NOT_
safe to call. You must always make sure the function is actually available
for a given GL context before calling it, by checking for the existence of
the appropriate extension with
SDL_GL_ExtensionSupported( ... ), or verifying that the version of OpenGL you're using offers the function as core functionality. - Some OpenGL drivers, on all platforms, will return undef if a function isn't supported, but you can't count on this behavior. Check for extensions you use, and if you get an undef anyway, act as if that extension wasn't available. This is probably a bug in the driver, but you can code defensively for this scenario anyhow.
- Just because you're on Linux/Unix, don't assume you'll be using X11. Next-gen display servers are waiting to replace it, and may or may not make the same promises about function pointers.
- OpenGL function pointers must be declared
APIENTRYas in the example code. This will ensure the proper calling convention is followed on platforms where this matters (Win32) thereby avoiding stack corruption.
Expected parameters include:
proc- the name of an OpenGL function
Returns a pointer to the named OpenGL function. The returned pointer should be cast to the appropriate function signature.
SDL_GL_UnloadLibrary( )
Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary( ... ).
SDL_GL_ExtensionSupported( ... )
Check if an OpenGL extension is supported for the current context.
my $ok = SDL_GL_ExtensionSupported( 'GL_ARB_texture_rectangle' );
This function operates on the current GL context; you must have created a context and it must be current before calling this function. Do not assume that all contexts you create will have the same set of extensions available, or that recreating an existing context will offer the same extensions again.
While it's probably not a massive overhead, this function is not an O(1) operation. Check the extensions you care about after creating the GL context and save that information somewhere instead of calling the function every time you need to know.
Expected parameters include:
extension- the name of the extension to check
Returns true if the extension is supported, false otherwise.
SDL_GL_ResetAttributes( )
Reset all previously set OpenGL context attributes to their default values.
SDL_GL_ResetAttributes( );
SDL_GL_SetAttribute( ... )
Set an OpenGL window attribute before window creation.
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
This function sets the OpenGL attribute attr to value. The requested
attributes should be set before creating an OpenGL window. You should use SDL_GL_GetAttribute( ... ) to check the
values after creating the OpenGL context, since the values obtained can differ
from the requested ones.
Expected parameters include:
attr- an SDL_GLattr enum value specifying the OpenGL attribute to setvalue- the desired value for the attribute
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GL_GetAttribute( ... )
Get the actual value for an attribute from the current context.
my $value = SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER);
Expected parameters include:
attr- an SDL_GLattr enum value specifying the OpenGL attribute to get
Returns the value on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GL_CreateContext( ... )
Create an OpenGL context for an OpenGL window, and make it current.
# Window mode MUST include SDL_WINDOW_OPENGL for use with OpenGL.
my $window = SDL_CreateWindow(
'SDL2/OpenGL Demo', 0, 0, 640, 480,
SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
# Create an OpenGL context associated with the window
my $glcontext = SDL_GL_CreateContext( $window );
# now you can make GL calls.
glClearColor( 0, 0, 0 ,1 );
glClear( GL_COLOR_BUFFER_BIT );
SDL_GL_SwapWindow( $window );
# Once finished with OpenGL functions, the SDL_GLContext can be deleted.
SDL_GL_DeleteContext( $glcontext );
Windows users new to OpenGL should note that, for historical reasons, GL
functions added after OpenGL version 1.1 are not available by default. Those
functions must be loaded at run-time, either with an OpenGL extension-handling
library or with SDL_GL_GetProcAddress( ... ) and its related functions.
SDL2::GLContext is opaque to the application.
Expected parameters include:
window- the window to associate with the context
Returns the OpenGL context associated with window or undef on error; call
SDL_GetError( )( ) for more details.
SDL_GL_MakeCurrent( ... )
Set up an OpenGL context for rendering into an OpenGL window.
SDL_GL_MakeCurrent( $window, $gl );
The context must have been created with a compatible window.
Expected parameters include:
window- the window to associate with the contextcontext- the OpenGL context to associate with the window
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GL_GetCurrentWindow( )
Get the currently active OpenGL window.
my $window = SDL_GL_GetCurrentWindow( );
Returns the currently active OpenGL window on success or undef on failure; call
SDL_GetError( )( ) for more information.
SDL_GL_GetCurrentContext( )
Get the currently active OpenGL context.
my $gl = SDL_GL_GetCurrentContext( );
Returns the currently active OpenGL context or NULL on failure; call SDL_GetError( )( ) for more information.
SDL_GL_GetDrawableSize( ... )
Get the size of a window's underlying drawable in pixels.
my ($w, $h) = SDL_GL_GetDrawableSize( $window );
This returns info useful for calling glViewport( ... ).
This may differ from SDL_GetWindowSize( ... ) if we're rendering to a high-DPI drawable, i.e. the window was created
with SDL_WINDOW_ALLOW_HIGHDPI on a platform with high-DPI support (Apple
calls this "Retina"), and not disabled by the
SDL_HINT_VIDEO_HIGHDPI_DISABLED hint.
Expected parameters include:
window- the window from which the drawable size should be queried
Returns the width and height in pixels, either of which may be undefined.
SDL_GL_SetSwapInterval( ... )
Set the swap interval for the current OpenGL context.
my $ok = !SDL_GL_SetSwapInterval( 1 );
Some systems allow specifying -1 for the interval, to enable adaptive vsync.
Adaptive vsync works the same as vsync, but if you've already missed the
vertical retrace for a given frame, it swaps buffers immediately, which might
be less jarring for the user during occasional framerate drops. If application
requests adaptive vsync and the system does not support it, this function will
fail and return -1. In such a case, you should probably retry the call with
1 for the interval.
Adaptive vsync is implemented for some glX drivers with
GLX_EXT_swap_control_tear:
https://www.opengl.org/registry/specs/EXT/glx_swap_control_tear.txt and for
some Windows drivers with WGL_EXT_swap_control_tear:
https://www.opengl.org/registry/specs/EXT/wgl_swap_control_tear.txt
Read more on the Khronos wiki: https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync
Expected parameters include:
interval- 0 for immediate updates, 1 for updates synchronized with the vertical retrace, -1 for adaptive vsync
Returns 0 on success or -1 if setting the swap interval is not supported;
call SDL_GetError( )( ) for more information.
SDL_GL_GetSwapInterval( )
Get the swap interval for the current OpenGL context.
my $interval = SDL_GL_GetSwapInterval( );
If the system can't determine the swap interval, or there isn't a valid current context, this function will return 0 as a safe default.
Returns 0 if there is no vertical retrace synchronization, 1 if the
buffer swap is synchronized with the vertical retrace, and -1 if late swaps
happen immediately instead of waiting for the next retrace; call SDL_GetError( )( ) for more information.
SDL_GL_SwapWindow( ... )
Update a window with OpenGL rendering.
SDL_GL_SwapWindow( $window );
This is used with double-buffered OpenGL contexts, which are the default.
On macOS, make sure you bind 0 to the draw framebuffer before swapping the
window, otherwise nothing will happen. If you aren't using glBindFramebuffer( ), this is the default and you won't have to do anything extra.
Expected parameters include:
window- the window to change
SDL_GL_DeleteContext( ... )
Delete an OpenGL context.
SDL_GL_DeleteContext( $context );
Expected parameters include:
context- the OpenGL context to be deleted
2D Accelerated Rendering
This category contains functions for 2D accelerated rendering. You may import
these functions with the :render tag.
This API supports the following features:
- single pixel points
- single pixel lines
- filled rectangles
- texture images
All of these may be drawn in opaque, blended, or additive modes.
The texture images can have an additional color tint or alpha modulation applied to them, and may also be stretched with linear interpolation, rotated or flipped/mirrored.
For advanced functionality like particle effects or actual 3D you should use SDL's OpenGL/Direct3D support or one of the many available 3D engines.
This API is not designed to be used from multiple threads, see SDL issue #986 for details.
SDL_GetNumRenderDrivers( )
Get the number of 2D rendering drivers available for the current display.
my $drivers = SDL_GetNumRenderDrivers( );
A render driver is a set of code that handles rendering and texture management on a particular display. Normally there is only one, but some drivers may have several available with different capabilities.
There may be none if SDL was compiled without render support.
Returns a number >= 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GetRenderDriverInfo( ... )
Get info about a specific 2D rendering driver for the current display.
my $info = !SDL_GetRendererDriverInfo( );
Expected parameters include:
index- the index of the driver to query information about
Returns an SDL2::RendererInfo structure on success or a negative error code
on failure; call SDL_GetError( )( ) for more
information.
SDL_CreateWindowAndRenderer( ... )
Create a window and default renderer.
my ($window, $renderer) = SDL_CreateWindowAndRenderer(640, 480, 0);
Expected parameters include:
width- the width of the windowheight- the height of the windowwindow_flags- the flags used to create the window (seeSDL_CreateWindow( ... ))
Returns a SDL2::Window and SDL2::Renderer objects on success, or -1 on
error; call SDL_GetError( )( ) for more
information.
SDL_CreateRenderer( ... )
Create a 2D rendering context for a window.
my $renderer = SDL_CreateRenderer( $window, -1, 0);
Expected parameters include:
window- the window where rendering is displayedindex- the index of the rendering driver to initialize, or-1to initialize the first one supporting the requested flagsflags-0, or one or moreSDL_RendererFlagsOR'd together
Returns a valid rendering context or undefined if there was an error; call SDL_GetError( )( ) for more information.
SDL_CreateSoftwareRenderer( ... )
Create a 2D software rendering context for a surface.
my $renderer = SDL_CreateSoftwareRenderer( $surface );
Two other API which can be used to create SDL_Renderer:
SDL_CreateRenderer( ... ) and SDL_CreateWindowAndRenderer( ... ). These can also create a software renderer, but they are intended to be
used with an SDL2::Window as the final destination and not an
SDL2::Surface.
Expected parameters include:
surface- the SDL2::Surface structure representing the surface where rendering is done
Returns a valid rendering context or undef if there was an error; call SDL_GetError( )( ) for more information.
SDL_GetRenderer( ... )
Get the renderer associated with a window.
my $renderer = SDL_GetRenderer( $window );
Expected parameters include:
window- the window to query
Returns the rendering context on success or undef on failure; call SDL_GetError( )( ) for more information.
SDL_GetRendererInfo( ... )
Get information about a rendering context.
my $info = !SDL_GetRendererInfo( $renderer );
Expected parameters include:
renderer- the rendering context
Returns an SDL2::RendererInfo structure on success or a negative error code
on failure; call SDL_GetError( )( ) for more
information.
SDL_GetRendererOutputSize( ... )
Get the output size in pixels of a rendering context.
my ($w, $h) = SDL_GetRendererOutputSize( $renderer );
Due to high-dpi displays, you might end up with a rendering context that has
more pixels than the window that contains it, so use this instead of SDL_GetWindowSize( ... ) to decide how much
drawing area you have.
Expected parameters include:
renderer- the rendering context
Returns the width and height on success or a negative error code on failure;
call SDL_GetError( )( ) for more information.
SDL_CreateTexture( ... )
Create a texture for a rendering context.
my $texture = SDL_CreateTexture( $renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, 1024, 768);
You can set the texture scaling method by setting
SDL_HINT_RENDER_SCALE_QUALITY before creating the texture.
Expected parameters include:
renderer- the rendering contextformat- one of the enumerated values in:pixelFormatEnumaccess- one of the enumerated values in:textureAccessw- the width of the texture in pixelsh- the height of the texture in pixels
Returns a pointer to the created texture or undefined if no rendering context
was active, the format was unsupported, or the width or height were out of
range; call SDL_GetError( )( ) for more
information.
SDL_CreateTextureFromSurface( ... )
Create a texture from an existing surface.
use Config;
my ($rmask, $gmask, $bmask, $amask) =
$Config{byteorder} == 4321 ? (0xff000000,0x00ff0000,0x0000ff00,0x000000ff) :
(0x000000ff,0x0000ff00,0x00ff0000,0xff000000);
my $surface = SDL_CreateRGBSurface( 0, 640, 480, 32, $rmask, $gmask, $bmask, $amask );
my $texture = SDL_CreateTextureFromSurface( $renderer, $surface );
The surface is not modified or freed by this function.
The SDL_TextureAccess hint for the created texture is
SDL_TEXTUREACCESS_STATIC.
The pixel format of the created texture may be different from the pixel format
of the surface. Use SDL_QueryTexture( ... ) to query the pixel format of the texture.
Expected parameters include:
renderer- the rendering contextsurface- the SDL2::Surface structure containing pixel data used to fill the texture
Returns the created texture or undef on failure; call SDL_GetError( )( ) for more information.
SDL_QueryTexture( ... )
Query the attributes of a texture.
my ( $format, $access, $w, $h ) = SDL_QueryTexture( $texture );
Expected parameters include:
texture- the texture to query
Returns the following on success...
format- a pointer filled in with the raw format of the texture; the actual format may differ, but pixel transfers will use this format (one of the:pixelFormatEnumvalues)access- a pointer filled in with the actual access to the texture (one of the:textureAccessvalues)w- a pointer filled in with the width of the texture in pixelsh- a pointer filled in with the height of the texture in pixels
...or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_SetTextureColorMod( ... )
Set an additional color value multiplied into render copy operations.
my $ok = !SDL_SetTextureColorMod( $texture, 64, 64, 64 );
When this texture is rendered, during the copy operation each source color channel is modulated by the appropriate color value according to the following formula:
srcC = srcC * (color / 255)
Color modulation is not always supported by the renderer; it will return -1
if color modulation is not supported.
Expected parameters include:
texture- the texture to updater- the red color value multiplied into copy operationsg- the green color value multiplied into copy operationsb- the blue color value multiplied into copy operations
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GetTextureColorMod( ... )
Get the additional color value multiplied into render copy operations.
my ( $r, $g, $b ) = SDL_GetTextureColorMod( $texture );
Expected parameters include:
texture- the texture to query
Returns the current red, green, and blue color values on success or a negative
error code on failure; call SDL_GetError( )( )
for more information.
SDL_SetTextureAlphaMod( ... )
Set an additional alpha value multiplied into render copy operations.
SDL_SetTextureAlphaMod( $texture, 100 );
When this texture is rendered, during the copy operation the source alpha
value is modulated by this alpha value according to the following formula:
srcA = srcA * (alpha / 255)
Alpha modulation is not always supported by the renderer; it will return -1
if alpha modulation is not supported.
Expected parameters include:
texture- the texture to updatealpha- the source alpha value multiplied into copy operations
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GetTextureAlphaMod( ... )
Get the additional alpha value multiplied into render copy operations.
my $alpha = SDL_GetTextureAlphaMod( $texture );
Expected parameters include:
texture- the texture to query
Returns the current alpha value on success or a negative error code on failure;
call SDL_GetError( )( ) for more information.
SDL_SetTextureBlendMode( ... )
Set the blend mode for a texture, used by SDL_RenderCopy( ... ).
If the blend mode is not supported, the closest supported mode is chosen and
this function returns -1.
Expected parameters include:
texture- the texture to updateblendMode- the:blendModeto use for texture blending
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GetTextureBlendMode( ... )
Get the blend mode used for texture copy operations.
SDL_GetTextureBlendMode( $texture, SDL_BLENDMODE_ADD );
Expected parameters include:
texture- the texture to query
Returns the current :blendMode on success or a negative error code on
failure; call SDL_GetError( )( ) for more
information.
SDL_SetTextureScaleMode( ... )
Set the scale mode used for texture scale operations.
SDL_SetTextureScaleMode( $texture, $scaleMode );
If the scale mode is not supported, the closest supported mode is chosen.
Expected parameters include:
texture- The texture to update.scaleMode- the SDL_ScaleMode to use for texture scaling.
Returns 0 on success, or -1 if the texture is not valid.
SDL_GetTextureScaleMode( ... )
Get the scale mode used for texture scale operations.
my $ok = SDL_GetTextureScaleMode( $texture );
Expected parameters include:
texture- the texture to query.
Returns the current scale mode on success, or -1 if the texture is not
valid.
SDL_UpdateTexture( ... )
Update the given texture rectangle with new pixel data.
my $rect = SDL2::Rect->new( { x => 0, y => ..., w => $surface->w, h => $surface->h } );
SDL_UpdateTexture( $texture, $rect, $surface->pixels, $surface->pitch );
The pixel data must be in the pixel format of the texture. Use SDL_QueryTexture( ... ) to query the pixel
format of the texture.
This is a fairly slow function, intended for use with static textures that do not change often.
If the texture is intended to be updated often, it is preferred to create the texture as streaming and use the locking functions referenced below. While this function will work with streaming textures, for optimization reasons you may not get the pixels back if you lock the texture afterward.
Expected parameters include:
texture- the texture to updaterect- an SDL2::Rect structure representing the area to update, or undef to update the entire texturepixels- the raw pixel data in the format of the texturepitch- the number of bytes in a row of pixel data, including padding between lines
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_UpdateYUVTexture( ... )
Update a rectangle within a planar YV12 or IYUV texture with new pixel data.
SDL_UpdateYUVTexture( $texture, $rect, $yPlane, $yPitch, $uPlane, $uPitch, $vPlane, $vPitch );
You can use SDL_UpdateTexture( ... ) as
long as your pixel data is a contiguous block of Y and U/V planes in the proper
order, but this function is available if your pixel data is not contiguous.
Expected parameters include:
texture- the texture to updaterect- a pointer to the rectangle of pixels to update, or undef to update the entire textureYplane- the raw pixel data for the Y planeYpitch- the number of bytes between rows of pixel data for the Y planeUplane- the raw pixel data for the U planeUpitch- the number of bytes between rows of pixel data for the U planeVplane- the raw pixel data for the V planeVpitch- the number of bytes between rows of pixel data for the V plane
Returns 0 on success or -1 if the texture is not valid; call SDL_GetError( )( ) for more information.
SDL_UpdateNVTexture( ... )
Update a rectangle within a planar NV12 or NV21 texture with new pixels.
SDL_UpdateNVTexture( $texture, $rect, $yPlane, $yPitch, $uPlane, $uPitch );
You can use SDL_UpdateTexture( ... ) as
long as your pixel data is a contiguous block of NV12/21 planes in the proper
order, but this function is available if your pixel data is not contiguous.
Expected parameters include:
texture- the texture to updaterect- a pointer to the rectangle of pixels to update, or undef to update the entire texture.Yplane- the raw pixel data for the Y plane.Ypitch- the number of bytes between rows of pixel data for the Y plane.UVplane- the raw pixel data for the UV plane.UVpitch- the number of bytes between rows of pixel data for the UV plane.
Returns 0 on success, or -1 if the texture is not valid.
SDL_LockTexture( ... )
Lock a portion of the texture for write-only pixel access.
SDL_LockTexture( $texture, $rect, $pixels, $pitch );
As an optimization, the pixels made available for editing don't necessarily contain the old texture data. This is a write-only operation, and if you need to keep a copy of the texture data you should do that at the application level.
You must use SDL_UpdateTexture( ... ) to
unlock the pixels and apply any changes.
Expected parameters include:
texture- the texture to lock for access, which was created withSDL_TEXTUREACCESS_STREAMINGrect- an SDL2::Rect structure representing the area to lock for access; undef to lock the entire texturepixels- this is filled in with a pointer to the locked pixels, appropriately offset by the locked areapitch- this is filled in with the pitch of the locked pixels; the pitch is the length of one row in bytes
Returns 0 on success or a negative error code if the texture is not valid or
was not created with `SDL_TEXTUREACCESS_STREAMING`; call SDL_GetError( )( ) for more information.
SDL_LockTextureToSurface( ... )
Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface.
my $surface = SDL_LockTextureSurface( $texture, $rect );
Besides providing an SDL2::Surface instead of raw pixel data, this function operates like SDL2::LockTexture.
As an optimization, the pixels made available for editing don't necessarily contain the old texture data. This is a write-only operation, and if you need to keep a copy of the texture data you should do that at the application level.
You must use SDL_UnlockTexture( ... ) to
unlock the pixels and apply any changes.
The returned surface is freed internally after calling SDL_UnlockTexture( ... ) or SDL_DestroyTexture( ... ). The caller should not free it.
Expected parameters include:
texture- the texture to lock for access, which was created withSDL_TEXTUREACCESS_STREAMINGrect- a pointer to the rectangle to lock for access. If the rect is undef, the entire texture will be locked
Returns the SDL2::Surface structure on success, or -1 if the texture is
not valid or was not created with SDL_TEXTUREACCESS_STREAMING.
SDL_UnlockTexture( ... )
Unlock a texture, uploading the changes to video memory, if needed.
SDL_UnlockTexture( $texture );
Warning: Please note that SDL_LockTexture( ... ) is intended to be write-only; it will not guarantee the previous
contents of the texture will be provided. You must fully initialize any area of
a texture that you lock before unlocking it, as the pixels might otherwise be
uninitialized memory.
Which is to say: locking and immediately unlocking a texture can result in corrupted textures, depending on the renderer in use.
Expected parameters include:
texture- a texture locked bySDL_LockTexture( ... )
SDL_RenderTargetSupported( ... )
Determine whether a renderer supports the use of render targets.
my $bool = SDL_RenderTargetSupported( $renderer );
Expected parameters include:
renderer- the renderer that will be checked
Returns true if supported or false if not.
SDL_SetRenderTarget( ... )
Set a texture as the current rendering target.
SDL_SetRenderTarget( $renderer, $texture );
Before using this function, you should check the SDL_RENDERER_TARGETTEXTURE
bit in the flags of SDL2::RendererInfo to see if render targets are
supported.
The default render target is the window for which the renderer was created. To
stop rendering to a texture and render to the window again, call this function
with a undefined texture.
Expected parameters include:
renderer- the rendering contexttexture- the targeted texture, which must be created with theSDL_TEXTUREACCESS_TARGETflag, or undef to render to the window instead of a texture.
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GetRenderTarget( ... )
Get the current render target.
my $texture = SDL_GetRenderTarget( $renderer );
The default render target is the window for which the renderer was created, and is reported an undefined value here.
Expected parameters include:
renderer- the rendering context
Returns the current render target or undef for the default render target.
SDL_RenderSetLogicalSize( ... )
Set a device independent resolution for rendering.
SDL_RenderSetLogicalSize( $renderer, 100, 100 );
This function uses the viewport and scaling functionality to allow a fixed logical resolution for rendering, regardless of the actual output resolution. If the actual output resolution doesn't have the same aspect ratio the output rendering will be centered within the output display.
If the output display is a window, mouse and touch events in the window will be filtered and scaled so they seem to arrive within the logical resolution.
If this function results in scaling or subpixel drawing by the rendering backend, it will be handled using the appropriate quality hints.
Expected parameters include:
renderer- the renderer for which resolution should be setw- the width of the logical resolutionh- the height of the logical resolution
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderGetLogicalSize( ... )
Get device independent resolution for rendering.
my ($w, $h) = SDL_RenderGetLogicalSize( $renderer );
This may return 0 for w and h if the SDL2::Renderer has never had
its logical size set by SDL_RenderSetLogicalSize( ... ) and never had a render target set.
Expected parameters include:
renderer- a rendering context
Returns the width and height.
SDL_RenderSetIntegerScale( ... )
Set whether to force integer scales for resolution-independent rendering.
SDL_RenderSetIntegerScale( $renderer, 1 );
This function restricts the logical viewport to integer values - that is, when a resolution is between two multiples of a logical size, the viewport size is rounded down to the lower multiple.
Expected parameters include:
renderer- the renderer for which integer scaling should be setenable- enable or disable the integer scaling for rendering
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderGetIntegerScale( ... )
Get whether integer scales are forced for resolution-independent rendering.
SDL_RenderGetIntegerScale( $renderer );
Expected parameters include:
renderer- the renderer from which integer scaling should be queried
Returns true if integer scales are forced or false if not and on failure; call
SDL_GetError( )( ) for more information.
SDL_RenderSetViewport( ... )
Set the drawing area for rendering on the current target.
SDL_RenderSetViewport( $renderer, $rect );
When the window is resized, the viewport is reset to fill the entire new window size.
Expected parameters include:
renderer- the rendering contextrect- the SDL2::Rect structure representing the drawing area, or undef to set the viewport to the entire target
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderGetViewport( ... )
Get the drawing area for the current target.
my $rect = SDL_RenderGetViewport( $renderer );
Expected parameters include:
renderer- the rendering context
Returns an SDL2::Rect structure filled in with the current drawing area.
SDL_RenderSetClipRect( ... )
Set the clip rectangle for rendering on the specified target.
SDL_RenderSetClipRect( $renderer, $rect );
Expected parameters include:
renderer- the rendering context for which clip rectangle should be setrect- an SDL2::Rect structure representing the clip area, relative to the viewport, or undef to disable clipping
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderGetClipRect( ... )
Get the clip rectangle for the current target.
my $rect = SDL_RenderGetClipRect( $renderer );
Expected parameters include:
renderer- the rendering context from which clip rectangle should be queried
Returns an SDL2::Rect structure filled in with the current clipping area or an empty rectangle if clipping is disabled.
SDL_RenderIsClipEnabled( ... )
Get whether clipping is enabled on the given renderer.
my $tf = SDL_RenderIsClipEnabled( $renderer );
Expected parameters include:
renderer- the renderer from which clip state should be queried
Returns true if clipping is enabled or false if not; call SDL_GetError( )( ) for more information.
SDL_RenderSetScale( ... )
Set the drawing scale for rendering on the current target.
SDL_RenderSetScale( $renderer, .5, 1 );
The drawing coordinates are scaled by the x/y scaling factors before they are used by the renderer. This allows resolution independent drawing with a single coordinate system.
If this results in scaling or subpixel drawing by the rendering backend, it will be handled using the appropriate quality hints. For best results use integer scaling factors.
Expected parameters include:
renderer- a rendering contextscaleX- the horizontal scaling factorscaleY- the vertical scaling factor
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderGetScale( ... )
Get the drawing scale for the current target.
my ($scaleX, $scaleY) = SDL_RenderGetScale( $renderer );
Expected parameters include:
renderer- the renderer from which drawing scale should be queried
Returns the horizonal and vertical scaling factors.
SDL_SetRenderDrawColor( ... )
Set the color used for drawing operations (Rect, Line and Clear).
SDL_SetRenderDrawColor( $renderer, 0, 0, 128, SDL_ALPHA_OPAQUE );
Set the color for drawing or filling rectangles, lines, and points, and for SDL_RenderClear( ... ).
Expected parameters include:
renderer- the rendering contextr- the red value used to draw on the rendering targetg- the green value used to draw on the rendering targetb- the blue value used to draw on the rendering targeta- the alpha value used to draw on the rendering target; usuallySDL_ALPHA_OPAQUE(255). UseSDL_SetRenderDrawBlendModeto specify how the alpha channel is used
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GetRenderDrawColor( ... )
Get the color used for drawing operations (Rect, Line and Clear).
my ($r, $g, $b, $a) = SDL_GetRenderDrawColor( $renderer );
Expected parameters include:
renderer- the rendering context
Returns red, green, blue, and alpha values on success or a negative error code
on failure; call SDL_GetError( )( ) for more
information.
SDL_SetRenderDrawBlendMode( ... )
Set the blend mode used for drawing operations (Fill and Line).
SDL_SetRenderDrawBlendMode( $renderer, SDL_BLENDMODE_BLEND );
If the blend mode is not supported, the closest supported mode is chosen.
Expected parameters include:
renderer- the rendering contextblendMode- the:blendModeto use for blending
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GetRenderDrawBlendMode( ... )
Get the blend mode used for drawing operations.
my $blendMode = SDL_GetRenderDrawBlendMode( $rendering );
Expected parameters include:
renderer- the rendering context
Returns the current :blendMode on success or a negative error code on
failure; call SDL_GetError( )( ) for more
information.
SDL_RenderClear( ... )
Clear the current rendering target with the drawing color.
SDL_RenderClear( $renderer );
This function clears the entire rendering target, ignoring the viewport and the clip rectangle.
renderer- the rendering context
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderDrawPoint( ... )
Draw a point on the current rendering target.
SDL_RenderDrawPoint( $renderer, 100, 100 );
SDL_RenderDrawPoint( ... ) draws a single point. If you want to draw
multiple, use SDL_RenderDrawPoints( ... ) instead.
Expected parameters include:
renderer- the rendering contextx- the x coordinate of the pointy- the y coordinate of the point
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderDrawPoints( ... )
Draw multiple points on the current rendering target.
my @points = map { SDL2::Point->new( {x => int rand, y => int rand } ) } 1..1024;
SDL_RenderDrawPoints( $renderer, @points );
renderer- the rendering contextpoints- an array of SDL2::Point structures that represent the points to draw
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderDrawLine( ... )
Draw a line on the current rendering target.
SDL_RenderDrawLine( $renderer, 300, 240, 340, 240 );
SDL_RenderDrawLine( ... ) draws the line to include both end points. If you
want to draw multiple, connecting lines use SDL_RenderDrawLines( ... ) instead.
Expected parameters include:
renderer- the rendering contextx1- the x coordinate of the start pointy1- the y coordinate of the start pointx2- the x coordinate of the end pointy2- the y coordinate of the end point
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderDrawLines( ... )
Draw a series of connected lines on the current rendering target.
SDL_RenderDrawLines( $renderer, @points);
Expected parameters include:
renderer- the rendering contextpoints- an array of SDL2::Point structures representing points along the lines
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderDrawRect( ... )
Draw a rectangle on the current rendering target.
SDL_RenderDrawRect( $renderer, SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ) );
Expected parameters include:
renderer- the rendering contextrect- an SDL2::Rect structure representing the rectangle to draw
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderDrawRects( ... )
Draw some number of rectangles on the current rendering target.
SDL_RenderDrawRects( $renderer,
SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ),
SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } )
);
Expected parameters include:
renderer- the rendering contextrects- an array of SDL2::Rect structures representing the rectangles to be drawn
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderFillRect( ... )
Fill a rectangle on the current rendering target with the drawing color.
SDL_RenderFillRect( $renderer, SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ) );
The current drawing color is set by SDL_SetRenderDrawColor( ... ), and the color's alpha value is ignored
unless blending is enabled with the appropriate call to SDL_SetRenderDrawBlendMode( ... ).
Expected parameters include:
renderer- the rendering contextrect- the SDL2::Rect structure representing the rectangle to fill
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderFillRects( ... )
Fill some number of rectangles on the current rendering target with the drawing color.
SDL_RenderFillRects( $renderer,
SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ),
SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } )
);
Expected parameters include:
renderer- the rendering contextrects- an array of SDL2::Rect structures representing the rectangles to be filled
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderCopy( ... )
Copy a portion of the texture to the current rendering target.
SDL_RenderCopy( $renderer, $blueShapes, $srcR, $destR );
The texture is blended with the destination based on its blend mode set with
SDL_SetTextureBlendMode( ... ).
The texture color is affected based on its color modulation set by SDL_SetTextureColorMod( ... ).
The texture alpha is affected based on its alpha modulation set by SDL_SetTextureAlphaMod( ... ).
Expected parameters include:
renderer- the rendering contexttexture- the source texturesrcrect- the source SDL2::Rect structuredstrect- the destination SDL2::Rect structure; the texture will be stretched to fill the given rectangle
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderCopyEx( ... )
Copy a portion of the texture to the current rendering, with optional rotation and flipping.
Copy a portion of the texture to the current rendering target, optionally rotating it by angle around the given center and also flipping it top-bottom and/or left-right.
The texture is blended with the destination based on its blend mode set with
SDL_SetTextureBlendMode( ... ).
The texture color is affected based on its color modulation set by SDL_SetTextureColorMod( ... ).
The texture alpha is affected based on its alpha modulation set by SDL_SetTextureAlphaMod( ... ).
Expected parameters include:
renderer- the rendering contexttexture- the source texturesrcrect- the source SDL2::Rect structuredstrect- the destination SDL_Rect structureangle- an angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise directioncenter- a pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done arounddstrect.w / 2,dstrect.h / 2)flip- a :rendererFlip value stating which flipping actions should be performed on the texture
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderDrawPointF( ... )
Draw a point on the current rendering target at subpixel precision.
SDL_RenderDrawPointF( $renderer, 25.5, 100.25 );
Expected parameters include:
renderer- The renderer which should draw a point.x- The x coordinate of the point.y- The y coordinate of the point.
Returns 0 on success, or -1 on error
SDL_RenderDrawPointsF( ... )
Draw multiple points on the current rendering target at subpixel precision.
my @points = map { SDL2::Point->new( {x => int rand, y => int rand } ) } 1..1024;
SDL_RenderDrawPointsF( $renderer, @points );
Expected parameters include:
renderer- The renderer which should draw multiple pointspoints- The points to draw
Returns 0 on success, or -1 on error; call SDL_GetError( )( ) for more information.
SDL_RenderDrawLineF( ... )
Draw a line on the current rendering target at subpixel precision.
SDL_RenderDrawLineF( $renderer, 100, 100, 250, 100);
Expected parameters include:
renderer- The renderer which should draw a line.x1- The x coordinate of the start point.y1- The y coordinate of the start point.x2- The x coordinate of the end point.y2- The y coordinate of the end point.
Returns 0 on success, or -1 on error.
SDL_RenderDrawLinesF( ... )
Draw a series of connected lines on the current rendering target at subpixel precision.
SDL_RenderDrawLines( $renderer, @points);
Expected parameters include:
renderer- The renderer which should draw multiple lines.points- The points along the lines
Return 0 on success, or -1 on error.
SDL_RenderDrawRectF( ... )
Draw a rectangle on the current rendering target at subpixel precision.
SDL_RenderDrawRectF( $renderer, $point);
Expected parameters include:
renderer- The renderer which should draw a rectangle.rect- A pointer to the destination rectangle
Returns 0 on success, or -1 on error
SDL_RenderDrawRectsF( ... )
Draw some number of rectangles on the current rendering target at subpixel precision.
SDL_RenderDrawRectsF( $renderer,
SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ),
SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } )
);
Expected parameters include:
renderer- The renderer which should draw multiple rectangles.rects- A pointer to an array of destination rectangles.
Returns 0 on success, or -1 on error.
SDL_RenderFillRectF( ... )
Fill a rectangle on the current rendering target with the drawing color at subpixel precision.
SDL_RenderFillRectF( $renderer,
SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } )
);
Expected parameters include:
renderer- The renderer which should fill a rectangle.rect- A pointer to the destination rectangle
Returns 0 on success, or -1 on error.
SDL_RenderFillRectsF( ... )
Fill some number of rectangles on the current rendering target with the drawing color at subpixel precision.
SDL_RenderFillRectsF( $renderer,
SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ),
SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } )
);
Expected parameters include:
renderer- The renderer which should fill multiple rectangles.rects- A pointer to an array of destination rectangles.
Returns 0 on success, or -1 on error.
SDL_RenderCopyF( ... )
Copy a portion of the texture to the current rendering target at subpixel precision.
Expected parameters include:
renderer- The renderer which should copy parts of a texturetexture- The source texturesrcrect- A pointer to the source rectangledstrect- A pointer to the destination rectangle
Returns 0 on success, or -1 on error.
SDL_RenderCopyExF( ... )
Copy a portion of the source texture to the current rendering target, with rotation and flipping, at subpixel precision.
renderer- The renderer which should copy parts of a texturetexture- The source texturesrcrect- A pointer to the source rectangledstrect- A pointer to the destination rectangleangle- An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise directioncenter- A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done arounddstrect.w/2,dstrect.h/2)flip- A:rendererFlipvalue stating which flipping actions should be performed on the texture
Returns 0 on success, or -1 on error
SDL_RenderReadPixels( ... )
Read pixels from the current rendering target to an array of pixels.
SDL_RenderReadPixels(
$renderer,
SDL2::Rect->new( { x => 0, y => 0, w => 640, h => 480 } ),
SDL_PIXELFORMAT_RGB888,
$surface->pixels, $surface->pitch
);
WARNING: This is a very slow operation, and should not be used frequently.
pitch specifies the number of bytes between rows in the destination
pixels data. This allows you to write to a subrectangle or have padded rows
in the destination. Generally, pitch should equal the number of pixels per
row in the `pixels` data times the number of bytes per pixel, but it might
contain additional padding (for example, 24bit RGB Windows Bitmap data pads all
rows to multiples of 4 bytes).
Expected parameters include:
renderer- the rendering contextrect- an SDL2::Rect structure representing the area to readformat- an:pixelFormatEnumvalue of the desired format of the pixel data, or0to use the format of the rendering targetpixels- pointer to the pixel data to copy intopitch- the pitch of thepixelsparameter
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_RenderPresent( ... )
Update the screen with any rendering performed since the previous call.
SDL_RenderPresent( $renderer );
SDL's rendering functions operate on a backbuffer; that is, calling a rendering
function such as SDL_RenderDrawLine( ... ) does not directly put a line on the screen, but rather updates the
backbuffer. As such, you compose your entire scene and *present* the composed
backbuffer to the screen as a complete picture.
Therefore, when using SDL's rendering API, one does all drawing intended for the frame, and then calls this function once per frame to present the final drawing to the user.
The backbuffer should be considered invalidated after each present; do not
assume that previous contents will exist between frames. You are strongly
encouraged to call SDL_RenderClear( ... )
to initialize the backbuffer before starting each new frame's drawing, even if
you plan to overwrite every pixel.
Expected parameters include:
renderer- the rendering context
SDL_DestroyTexture( ... )
Destroy the specified texture.
SDL_DestroyTexture( $texture );
Passing undef or an otherwise invalid texture will set the SDL error message to "Invalid texture".
Expected parameters include:
texture- the texture to destroy
SDL_DestroyRenderer( ... )
Destroy the rendering context for a window and free associated textures.
SDL_DestroyRenderer( $renderer );
Expected parameters include:
renderer- the rendering context
SDL_RenderFlush( ... )
Force the rendering context to flush any pending commands to the underlying rendering API.
SDL_RenderFlush( $renderer );
You do not need to (and in fact, shouldn't) call this function unless you are planning to call into OpenGL/Direct3D/Metal/whatever directly in addition to using an SDL_Renderer.
This is for a very-specific case: if you are using SDL's render API, you asked
for a specific renderer backend (OpenGL, Direct3D, etc), you set
SDL_HINT_RENDER_BATCHING to "1", and you plan to make OpenGL/D3D/whatever
calls in addition to SDL render API calls. If all of this applies, you should
call SDL_RenderFlush( ... ) between calls
to SDL's render API and the low-level API you're using in cooperation.
In all other cases, you can ignore this function. This is only here to get maximum performance out of a specific situation. In all other cases, SDL will do the right thing, perhaps at a performance loss.
This function is first available in SDL 2.0.10, and is not needed in 2.0.9 and earlier, as earlier versions did not queue rendering commands at all, instead flushing them to the OS immediately.
Expected parameters include:
renderer- the rendering context
Returns 0 on success or a negative error code on failure; call SDL_GetError( )( ) for more information.
SDL_GL_BindTexture( ... )
Bind an OpenGL/ES/ES2 texture to the current context.
my ($texw, $texh) = SDL_GL_BindTexture( $texture );
This is for use with OpenGL instructions when rendering OpenGL primitives directly.
If not NULL, the returned width and height values suitable for the provided
texture. In most cases, both will be 1.0, however, on systems that support
the GL_ARB_texture_rectangle extension, these values will actually be the pixel
width and height used to create the texture, so this factor needs to be taken
into account when providing texture coordinates to OpenGL.
You need a renderer to create an SDL2::Texture, therefore you can only use
this function with an implicit OpenGL context from SDL_CreateRenderer( ... ), not with your own OpenGL context. If
you need control over your OpenGL context, you need to write your own
texture-loading methods.
Also note that SDL may upload RGB textures as BGR (or vice-versa), and re-order the color channels in the shaders phase, so the uploaded texture may have swapped color channels.
Expected parameters include:
texture- the texture to bind to the current OpenGL/ES/ES2 context
Returns the texture's with and height on success, or -1 if the operation is not
supported; call SDL_GetError( )( ) for more
information.
SDL_GL_UnbindTexture( ... )
Unbind an OpenGL/ES/ES2 texture from the current context.
SDL_GL_UnbindTexture( $texture );
See SDL_GL_BindTexture( ... ) for
examples on how to use these functions.
Expected parameters include:
texture- the texture to unbind from the current OpenGL/ES/ES2 context
Returns 0 on success, or -1 if the operation is not supported.
SDL_RenderGetMetalLayer( ... )
Get the CAMetalLayer associated with the given Metal renderer.
my $opaque = SDL_RenderGetMetalLayer( $renderer );
This function returns void *, so SDL doesn't have to include Metal's
headers, but it can be safely cast to a CAMetalLayer *.
Expected parameters include:
renderer- the renderer to query
Returns CAMetalLayer* on success, or undef if the renderer isn't a Metal
renderer.
SDL_RenderGetMetalCommandEncoder( ... )
Get the Metal command encoder for the current frame
$opaque = SDL_RenderGetMetalCommandEncoder( $renderer );
This function returns void *, so SDL doesn't have to include Metal's
headers, but it can be safely cast to an
id<MTLRenderCommandEncoder>.
Expected parameters include:
renderer- the renderer to query
Returns id<MTLRenderCommandEncoder> on success, or undef if the
renderer isn't a Metal renderer.
SDL_ComposeCustomBlendMode( ... )
Compose a custom blend mode for renderers.
The functions SDL_SetRenderDrawBlendMode and SDL_SetTextureBlendMode accept the SDL_BlendMode returned by this function if the renderer supports it.
A blend mode controls how the pixels from a drawing operation (source) get combined with the pixels from the render target (destination). First, the components of the source and destination pixels get multiplied with their blend factors. Then, the blend operation takes the two products and calculates the result that will get stored in the render target.
Expressed in pseudocode, it would look like this:
my $dstRGB = colorOperation( $srcRGB * $srcColorFactor, $dstRGB * $dstColorFactor );
my $dstA = alphaOperation( $srcA * $srcAlphaFactor, $dstA * $dstAlphaFactor );
Where the functions colorOperation(src, dst) and alphaOperation(src, dst)
can return one of the following:
src + dstsrc - dstdst - srcmin(src, dst)max(src, dst)
The red, green, and blue components are always multiplied with the first, second, and third components of the SDL_BlendFactor, respectively. The fourth component is not used.
The alpha component is always multiplied with the fourth component of the :blendFactor. The other components are not used in the
alpha calculation.
Support for these blend modes varies for each renderer. To check if a specific
:blendMode is supported, create a renderer and pass it
to either SDL_SetRenderDrawBlendMode or SDL_SetTextureBlendMode. They
will return with an error if the blend mode is not supported.
This list describes the support of custom blend modes for each renderer in SDL
2.0.6. All renderers support the four blend modes listed in the :blendMode enumeration.
- direct3d - Supports
SDL_BLENDOPERATION_ADDwith all factors. - direct3d11 - Supports all operations with all factors. However, some factors produce unexpected results with
SDL_BLENDOPERATION_MINIMUMandSDL_BLENDOPERATION_MAXIMUM. - opengl - Supports the
SDL_BLENDOPERATION_ADDoperation with all factors. OpenGL versions 1.1, 1.2, and 1.3 do not work correctly with SDL 2.0.6. - opengles - Supports the
SDL_BLENDOPERATION_ADDoperation with all factors. Color and alpha factors need to be the same. OpenGL ES 1 implementation specific: May also supportSDL_BLENDOPERATION_SUBTRACTandSDL_BLENDOPERATION_REV_SUBTRACT. May support color and alpha operations being different from each other. May support color and alpha factors being different from each other. - opengles2 - Supports the
SDL_BLENDOPERATION_ADD,SDL_BLENDOPERATION_SUBTRACT,SDL_BLENDOPERATION_REV_SUBTRACToperations with all factors. - psp - No custom blend mode support.
- software - No custom blend mode support.
Some renderers do not provide an alpha component for the default render target.
The SDL_BLENDFACTOR_DST_ALPHA and SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA
factors do not have an effect in this case.
Expected parameters include:
srcColorFactor-the:blendFactorapplied to the red, green, and blue components of the source pixelsdstColorFactor- the:blendFactorapplied to the red, green, and blue components of the destination pixelscolorOperation- the:blendOperationused to combine the red, green, and blue components of the source and destination pixelssrcAlphaFactor- the:blendFactorapplied to the alpha component of the source pixelsdstAlphaFactor- the:blendFactorapplied to the alpha component of the destination pixelsalphaOperation- the:blendOperationused to combine the alpha component of the source and destination pixels
Returns a :blendMode that represents the chosen factors and operations.
Time Management Routines
This section contains functions for handling the SDL time management routines.
They may be imported with the :timer tag.
SDL_GetTicks( )
Get the number of milliseconds since SDL library initialization.
my $time = SDL_GetTicks( );
This value wraps if the program runs for more than ~49 days.
Returns an unsigned 32-bit value representing the number of milliseconds since the SDL library initialized.
SDL_GetPerformanceCounter( )
Get the current value of the high resolution counter.
my $high_timer = SDL_GetPerformanceCounter( );
This function is typically used for profiling.
The counter values are only meaningful relative to each other. Differences
between values can be converted to times by using SDL_GetPerformanceFrequency( ).
Returns the current counter value.
SDL_GetPerformanceFrequency( ... )
Get the count per second of the high resolution counter.
my $hz = SDL_GetPerformanceFrequency( );
Returns a platform-specific count per second.
SDL_Delay( ... )
Wait a specified number of milliseconds before returning.
SDL_Delay( 1000 );
This function waits a specified number of milliseconds before returning. It waits at least the specified time, but possibly longer due to OS scheduling.
Expected parameters include:
ms- the number of milliseconds to delay
SDL_AddTimer( ... )
Call a callback function at a future time.
my $id = SDL_AddTimer( 1000, sub ( $interval, $data ) { warn 'ping!'; $interval; } );
If you use this function, you must pass SDL_INIT_TIMER to SDL_Init( ... ).
The callback function is passed the current timer interval and returns the next
timer interval. If the returned value is the same as the one passed in, the
periodic alarm continues, otherwise a new alarm is scheduled. If the callback
returns 0, the periodic alarm is cancelled.
The callback is run on a separate thread.
Timers take into account the amount of time it took to execute the callback. For example, if the callback took 250 ms to execute and returned 1000 (ms), the timer would only wait another 750 ms before its next iteration.
Timing may be inexact due to OS scheduling. Be sure to note the current time
with SDL_GetTicks( ) or SDL_GetPerformanceCounter( ) in case
your callback needs to adjust for variances.
Expected parameters include:
interval- the timer delay, in milliseconds, passed tocallbackcallback- theCODEreference to call when the specifiedintervalelapsesparam- a pointer that is passed tocallback
Returns a timer ID or 0 if an error occurs; call SDL_GetError( )( ) for more information.
SDL_RemoveTimer( ... )
SDL_RemoveTimer( $id );
Remove a timer created with SDL_AddTimer( ... ).
Expected parameters include:
id- the ID of the timer to remove
Returns true if the timer is removed or false if the timer wasn't found.
Raw Audio Mixing
These methods provide access to the raw audio mixing buffer for the SDL
library. They may be imported with the :audio tag.
SDL_GetNumAudioDrivers( )
Returns a list of built in audio drivers, in the order that they were normally initialized by default.
SDL_GetAudioDriver( ... )
Returns an audio driver by name.
my $driver = SDL_GetAudioDriver( 1 );
Expected parameters include:
index- The zero-based index of the desired audio driver
SDL_AudioInit( ... )
Audio system initialization.
SDL_AudioInit( 'pulseaudio' );
This method is used internally, and should not be used unless you have a
specific need to specify the audio driver you want to use. You should normally
use SDL_Init( ... ).
Returns 0 on success.
SDL_AudioQuit( )
Cleaning up initialized audio system.
SDL_AudioQuit( );
This method is used internally, and should not be used unless you have a
specific need to close the selected audio driver. You should normally use SDL_Quit( ).
SDL_GetCurrentAudioDriver( )
Get the name of the current audio driver.
my $driver = SDL_GetCurrentAudioDriver( );
The returned string points to internal static memory and thus never becomes invalid, even if you quit the audio subsystem and initialize a new driver (although such a case would return a different static string from another call to this function, of course). As such, you should not modify or free the returned string.
Returns the name of the current audio driver or undef if no driver has been initialized.
SDL_OpenAudio( ... )
This function is a legacy means of opening the audio device.
my $obtained = SDL_OpenAudio(
SDL2::AudioSpec->new( { freq => 48000, channels => 2, format => AUDIO_F32 } ) );
This function remains for compatibility with SDL 1.2, but also because it's
slightly easier to use than the new functions in SDL 2.0. The new, more
powerful, and preferred way to do this is SDL_OpenAudioDevice( ... ) .
This function is roughly equivalent to:
SDL_OpenAudioDevice( (), 0, $desired, SDL_AUDIO_ALLOW_ANY_CHANGE );
With two notable exceptions:
-
- If
obtainedis undefined, we usedesired(and allow no changes), which means desired will be modified to have the correct values for silence, etc, and SDL will convert any differences between your app's specific request and the hardware behind the scenes.
- If
-
-
The return value is always success or failure, and not a device ID, which means you can only have one device open at a time with this function.
- \param desired an SDL_AudioSpec structure representing the desired output
-
format. Please refer to the SDL_OpenAudioDevice documentation -
for details on how to prepare this structure. - \param obtained an SDL_AudioSpec structure filled in with the actual
-
parameters, or NULL. - \returns This function opens the audio device with the desired parameters,
-
and returns 0 if successful, placing the actual hardware -
parameters in the structure pointed to by `obtained`. -
If `obtained` is NULL, the audio data passed to the callback -
function will be guaranteed to be in the requested format, and -
will be automatically converted to the actual hardware audio -
format if necessary. If `obtained` is NULL, `desired` will -
have fields modified. -
This function returns a negative error code on failure to open the -
audio device or failure to set up the audio thread; call -
SDL_GetError() for more information.
-
Imports
This list of imports will be organized by their related tags. Of course, you may import them all by name as well.
:init
These are the flags which may be passed to SDL_Init( ... ). You should specify the subsystems which you will be using in your
application.
-
SDL_INIT_TIMERTimer subsystem.
-
SDL_INIT_AUDIOAudio subsystem.
-
SDL_INIT_VIDEOVideo subsystem. Automatically initializes the events subsystem.
-
SDL_INIT_JOYSTICKJoystick subsystem. Automatically initializes the events subsystem.
-
SDL_INIT_HAPTICHaptic (force feedback) subsystem.
-
SDL_INIT_GAMECONTROLLERController subsystem. Automatically initializes the joystick subsystem.
-
SDL_INIT_EVENTSEvents subsystem.
-
SDL_INIT_EVERYTHINGAll of the above subsystems.
-
SDL_INIT_SENSOR -
SDL_INIT_NOPARACHUTECompatibility; this flag is ignored.
:hints
SDL_HINT_DEFAULT- low priority, used for default valuesSDL_HINT_NORMAL- medium prioritySDL_HINT_OVERRIDE- high priority
SDL_Hint
These enum values can be passed to Configuration Variable related functions.
-
SDL_HINT_ACCELEROMETER_AS_JOYSTICKA hint that specifies whether the Android / iOS built-in accelerometer should be listed as a joystick device, rather than listing actual joysticks only.
Values:
0 list only real joysticks and accept input from them 1 list real joysticks along with the accelorometer as if it were a 3 axis joystick (the default)Example:
# This disables the use of gyroscopes as axis device SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); -
SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSIONA hint that specifies the Android APK expansion main file version.
Values:
X the Android APK expansion main file version (should be a string number like "1", "2" etc.)This hint must be set together with the hint
SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION.If both hints were set then
SDL_RWFromFile( )will look into expansion files after a given relative path was not found in the internal storage and assets.By default this hint is not set and the APK expansion files are not searched.
-
SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSIONA hint that specifies the Android APK expansion patch file version.
Values:
X the Android APK expansion patch file version (should be a string number like "1", "2" etc.)This hint must be set together with the hint
SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION.If both hints were set then
SDL_RWFromFile( )will look into expansion files after a given relative path was not found in the internal storage and assets.By default this hint is not set and the APK expansion files are not searched.
-
SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCHA hint that specifies a variable to control whether mouse and touch events are to be treated together or separately.
Values:
0 mouse events will be handled as touch events and touch will raise fake mouse events (default) 1 mouse events will be handled separately from pure touch eventsBy default mouse events will be handled as touch events and touch will raise fake mouse events.
The value of this hint is used at runtime, so it can be changed at any time.
-
SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTSA hint that specifies whether controllers used with the Apple TV generate UI events.
Values:
0 controller input does not gnerate UI events (default) 1 controller input generates UI eventsWhen UI events are generated by controller input, the app will be backgrounded when the Apple TV remote's menu button is pressed, and when the pause or B buttons on gamepads are pressed.
More information about properly making use of controllers for the Apple TV can be found here: https://developer.apple.com/tvos/human-interface-guidelines/remote-and-controllers/
-
SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATIONA hint that specifies whether the Apple TV remote's joystick axes will automatically match the rotation of the remote.
Values:
0 remote orientation does not affect joystick axes (default) 1 joystick axes are based on the orientation of the remote -
SDL_HINT_BMP_SAVE_LEGACY_FORMATA hint that specifies whether SDL should not use version 4 of the bitmap header when saving BMPs.
Values:
0 version 4 of the bitmap header will be used when saving BMPs (default) 1 version 4 of the bitmap header will not be used when saving BMPsThe bitmap header version 4 is required for proper alpha channel support and SDL will use it when required. Should this not be desired, this hint can force the use of the 40 byte header version which is supported everywhere.
If the hint is not set then surfaces with a colorkey or an alpha channel are saved to a 32-bit BMP file with an alpha mask. SDL will use the bitmap header version 4 and set the alpha mask accordingly. This is the default behavior since SDL 2.0.5.
If the hint is set then surfaces with a colorkey or an alpha channel are saved to a 32-bit BMP file without an alpha mask. The alpha channel data will be in the file, but applications are going to ignore it. This was the default behavior before SDL 2.0.5.
-
SDL_HINT_EMSCRIPTEN_ASYNCIFYA hint that specifies if SDL should give back control to the browser automatically when running with asyncify.
Values:
0 disable emscripten_sleep calls (if you give back browser control manually or use asyncify for other purposes) 1 enable emscripten_sleep calls (default)This hint only applies to the Emscripten platform.
-
SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENTA hint that specifies a value to override the binding element for keyboard inputs for Emscripten builds.
Values:
#window the JavaScript window object (default) #document the JavaScript document object #screen the JavaScript window.screen object #canvas the default WebGL canvas elementAny other string without a leading # sign applies to the element on the page with that ID.
This hint only applies to the Emscripten platform.
-
SDL_HINT_FRAMEBUFFER_ACCELERATIONA hint that specifies how 3D acceleration is used with SDL_GetWindowSurface( ... ).
Values:
0 disable 3D acceleration 1 enable 3D acceleration, using the default renderer X enable 3D acceleration, using X where X is one of the valid rendering drivers. (e.g. "direct3d", "opengl", etc.)By default SDL tries to make a best guess whether to use acceleration or not on each platform.
SDL can try to accelerate the screen surface returned by SDL_GetWindowSurface( ... ) by using streaming textures with a 3D rendering engine. This variable controls whether and how this is done.
-
SDL_HINT_GAMECONTROLLERCONFIGA variable that lets you provide a file with extra gamecontroller db entries.
This hint must be set before calling
SDL_Init(SDL_INIT_GAMECONTROLLER).You can update mappings after the system is initialized with
SDL_GameControllerMappingForGUID( )andSDL_GameControllerAddMapping( ). -
SDL_HINT_GRAB_KEYBOARDA variable setting the double click time, in milliseconds.
-
SDL_HINT_IDLE_TIMER_DISABLEDA hint that specifies a variable controlling whether the idle timer is disabled on iOS.
Values:
0 enable idle timer (default) 1 disable idle timerWhen an iOS application does not receive touches for some time, the screen is dimmed automatically. For games where the accelerometer is the only input this is problematic. This functionality can be disabled by setting this hint.
As of SDL 2.0.4,
SDL_EnableScreenSaver( )andSDL_DisableScreenSaver( )accomplish the same thing on iOS. They should be preferred over this hint. -
SDL_HINT_IME_INTERNAL_EDITINGA variable to control whether we trap the Android back button to handle it manually. This is necessary for the right mouse button to work on some Android devices, or to be able to trap the back button for use in your code reliably. If set to true, the back button will show up as an
SDL_KEYDOWN/SDL_KEYUPpair with a keycode ofSDL_SCANCODE_AC_BACK.The variable can be set to the following values:
0 Back button will be handled as usual for system. (default) 1 Back button will be trapped, allowing you to handle the key press manually. (This will also let right mouse click work on systems where the right mouse button functions as back.)The value of this hint is used at runtime, so it can be changed at any time.
-
SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTSA variable controlling whether the HIDAPI joystick drivers should be used.
This variable can be set to the following values:
0 HIDAPI drivers are not used 1 HIDAPI drivers are used (default)This variable is the default for all drivers, but can be overridden by the hints for specific drivers below.
-
SDL_HINT_MAC_BACKGROUND_APPA hint that specifies if the SDL app should not be forced to become a foreground process on Mac OS X.
Values:
0 force the SDL app to become a foreground process (default) 1 do not force the SDL app to become a foreground processThis hint only applies to Mac OSX.
-
SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICKA hint that specifies whether ctrl+click should generate a right-click event on Mac.
Values:
0 disable emulating right click (default) 1 enable emulating right click -
SDL_HINT_MOUSE_FOCUS_CLICKTHROUGHA hint that specifies if mouse click events are sent when clicking to focus an SDL window.
Values:
0 no mouse click events are sent when clicking to focus (default) 1 mouse click events are sent when clicking to focus -
SDL_HINT_MOUSE_RELATIVE_MODE_WARPA hint that specifies whether relative mouse mode is implemented using mouse warping.
Values:
0 relative mouse mode uses the raw input (default) 1 relative mouse mode uses mouse warping -
SDL_HINT_NO_SIGNAL_HANDLERSA hint that specifies not to catch the
SIGINTorSIGTERMsignals.Values:
0 SDL will install a SIGINT and SIGTERM handler, and when it catches a signal, convert it into an SDL_QUIT event 1 SDL will not install a signal handler at all -
SDL_HINT_ORIENTATIONSA variable controlling which orientations are allowed on iOS/Android.
In some circumstances it is necessary to be able to explicitly control which UI orientations are allowed.
This variable is a space delimited list of the following values:
LandscapeLeftLandscapeRightPortraitPortraitUpsideDown
-
SDL_HINT_RENDER_DIRECT3D11_DEBUGA variable controlling whether to enable Direct3D 11+'s Debug Layer.
This variable does not have any effect on the Direct3D 9 based renderer.
This variable can be set to the following values:
0 Disable Debug Layer use (default) 1 Enable Debug Layer use -
SDL_HINT_RENDER_DIRECT3D_THREADSAFEA variable controlling whether the Direct3D device is initialized for thread-safe operations.
This variable can be set to the following values:
0 Thread-safety is not enabled (faster; default) 1 Thread-safety is enabled -
SDL_HINT_RENDER_DRIVERA variable specifying which render driver to use.
If the application doesn't pick a specific renderer to use, this variable specifies the name of the preferred renderer. If the preferred renderer can't be initialized, the normal default renderer is used.
This variable is case insensitive and can be set to the following values:
direct3dopenglopengles2openglesmetalsoftware
The default varies by platform, but it's the first one in the list that is available on the current platform.
-
SDL_HINT_RENDER_OPENGL_SHADERSA variable controlling whether the OpenGL render driver uses shaders if they are available.
This variable can be set to the following values:
0 Disable shaders 1 Enable shaders (default) -
SDL_HINT_RENDER_SCALE_QUALITYA variable controlling the scaling quality
This variable can be set to the following values: 0 or nearest Nearest pixel sampling (default) 1 or linear Linear filtering (supported by OpenGL and Direct3D) 2 or best Currently this is the same as linear
-
SDL_HINT_RENDER_VSYNCA variable controlling whether updates to the SDL screen surface should be synchronized with the vertical refresh, to avoid tearing.
This variable can be set to the following values:
0 Disable vsync 1 Enable vsyncBy default SDL does not sync screen surface updates with vertical refresh.
-
SDL_HINT_RPI_VIDEO_LAYERTell SDL which Dispmanx layer to use on a Raspberry PI
Also known as Z-order. The variable can take a negative or positive value.
The default is
10000. -
SDL_HINT_THREAD_STACK_SIZEA string specifying SDL's threads stack size in bytes or
0for the backend's default sizeUse this hint in case you need to set SDL's threads stack size to other than the default. This is specially useful if you build SDL against a non glibc libc library (such as musl) which provides a relatively small default thread stack size (a few kilobytes versus the default 8MB glibc uses). Support for this hint is currently available only in the pthread, Windows, and PSP backend.
Instead of this hint, in 2.0.9 and later, you can use
SDL_CreateThreadWithStackSize( ). This hint only works with the classicSDL_CreateThread( ). -
SDL_HINT_TIMER_RESOLUTIONA variable that controls the timer resolution, in milliseconds.
he higher resolution the timer, the more frequently the CPU services timer interrupts, and the more precise delays are, but this takes up power and CPU time. This hint is only used on Windows.
See this blog post for more information: http://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/
If this variable is set to
0, the system timer resolution is not set.The default value is
1. This hint may be set at any time. -
SDL_HINT_VIDEO_ALLOW_SCREENSAVERA variable controlling whether the screensaver is enabled.
This variable can be set to the following values:
0 Disable screensaver 1 Enable screensaverBy default SDL will disable the screensaver.
-
SDL_HINT_VIDEO_HIGHDPI_DISABLEDIf set to
1, then do not allow high-DPI windows. ("Retina" on Mac and iOS) -
SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACESA variable that dictates policy for fullscreen Spaces on Mac OS X.
This hint only applies to Mac OS X.
The variable can be set to the following values:
0 Disable Spaces support (FULLSCREEN_DESKTOP won't use them and SDL_WINDOW_RESIZABLE windows won't offer the "fullscreen" button on their titlebars). 1 Enable Spaces support (FULLSCREEN_DESKTOP will use them and SDL_WINDOW_RESIZABLE windows will offer the "fullscreen" button on their titlebars).The default value is
1. Spaces are disabled regardless of this hint if the OS isn't at least Mac OS X Lion (10.7). This hint must be set before any windows are created. -
SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSSMinimize your
SDL_Windowif it loses key focus when in fullscreen mode. Defaults to false.Warning: Before SDL 2.0.14, this defaulted to true! In 2.0.14, we're seeing if "true" causes more problems than it solves in modern times.
-
SDL_HINT_VIDEO_WIN_D3DCOMPILERA variable specifying which shader compiler to preload when using the Chrome ANGLE binaries
SDL has EGL and OpenGL ES2 support on Windows via the ANGLE project. It can use two different sets of binaries, those compiled by the user from source or those provided by the Chrome browser. In the later case, these binaries require that SDL loads a DLL providing the shader compiler.
This variable can be set to the following values:
-
d3dcompiler_46.dlldefault, best for Vista or later.
-
d3dcompiler_43.dllfor XP support.
-
nonedo not load any library, useful if you compiled ANGLE from source and included the compiler in your binaries.
-
-
SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMATA variable that is the address of another
SDL_Window*(as a hex string formatted with%p).If this hint is set before
SDL_CreateWindowFrom( )and theSDL_Window*it is set to hasSDL_WINDOW_OPENGLset (and running on WGL only, currently), then two things will occur on the newly createdSDL_Window:-
- Its pixel format will be set to the same pixel format as this
SDL_Window. This is needed for example when sharing an OpenGL context across multiple windows.
- Its pixel format will be set to the same pixel format as this
-
- The flag SDL_WINDOW_OPENGL will be set on the new window so it can be used for OpenGL rendering.
This variable can be set to the address (as a string
%p) of theSDL_Window*that new windows created withSDL_CreateWindowFrom( ... )should share a pixel format with. -
-
SDL_HINT_VIDEO_X11_NET_WM_PINGA variable controlling whether the X11 _NET_WM_PING protocol should be supported.
This variable can be set to the following values:
0 Disable _NET_WM_PING 1 Enable _NET_WM_PINGBy default SDL will use _NET_WM_PING, but for applications that know they will not always be able to respond to ping requests in a timely manner they can turn it off to avoid the window manager thinking the app is hung. The hint is checked in CreateWindow.
-
SDL_HINT_VIDEO_X11_XINERAMAA variable controlling whether the X11 Xinerama extension should be used.
This variable can be set to the following values:
0 Disable Xinerama 1 Enable XineramaBy default SDL will use Xinerama if it is available.
-
SDL_HINT_VIDEO_X11_XRANDRA variable controlling whether the X11 XRandR extension should be used.
This variable can be set to the following values:
0 Disable XRandR 1 Enable XRandRBy default SDL will not use XRandR because of window manager issues.
-
SDL_HINT_VIDEO_X11_XVIDMODEA variable controlling whether the X11 VidMode extension should be used.
This variable can be set to the following values:
0 Disable XVidMode 1 Enable XVidModeBy default SDL will use XVidMode if it is available.
-
SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDENA variable controlling whether the window frame and title bar are interactive when the cursor is hidden.
This variable can be set to the following values:
0 The window frame is not interactive when the cursor is hidden (no move, resize, etc) 1 The window frame is interactive when the cursor is hiddenBy default SDL will allow interaction with the window frame when the cursor is hidden.
-
SDL_HINT_WINDOWS_DISABLE_THREAD_NAMINGTell SDL not to name threads on Windows with the 0x406D1388 Exception. The 0x406D1388 Exception is a trick used to inform Visual Studio of a thread's name, but it tends to cause problems with other debuggers, and the .NET runtime. Note that SDL 2.0.6 and later will still use the (safer) SetThreadDescription API, introduced in the Windows 10 Creators Update, if available.
The variable can be set to the following values:
0 SDL will raise the 0x406D1388 Exception to name threads. This is the default behavior of SDL <= 2.0.4. 1 SDL will not raise this exception, and threads will be unnamed. (default) This is necessary with .NET languages or debuggers that aren't Visual Studio. -
SDL_HINT_WINDOWS_INTRESOURCE_ICONA variable to specify custom icon resource id from RC file on Windows platform.
-
SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALLA variable to specify custom icon resource id from RC file on Windows platform.
-
SDL_HINT_WINDOWS_ENABLE_MESSAGELOOPA variable controlling whether the windows message loop is processed by SDL .
This variable can be set to the following values:
0 The window message loop is not run 1 The window message loop is processed in SDL_PumpEvents( )By default SDL will process the windows message loop.
-
SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4Tell SDL not to generate window-close events for Alt+F4 on Windows.
The variable can be set to the following values:
0 SDL will generate a window-close event when it sees Alt+F4. 1 SDL will only do normal key handling for Alt+F4. -
SDL_HINT_WINRT_HANDLE_BACK_BUTTONAllows back-button-press events on Windows Phone to be marked as handled.
Windows Phone devices typically feature a Back button. When pressed, the OS will emit back-button-press events, which apps are expected to handle in an appropriate manner. If apps do not explicitly mark these events as 'Handled', then the OS will invoke its default behavior for unhandled back-button-press events, which on Windows Phone 8 and 8.1 is to terminate the app (and attempt to switch to the previous app, or to the device's home screen).
Setting the
SDL_HINT_WINRT_HANDLE_BACK_BUTTONhint to "1" will cause SDL to mark back-button-press events as Handled, if and when one is sent to the app.Internally, Windows Phone sends back button events as parameters to special back-button-press callback functions. Apps that need to respond to back-button-press events are expected to register one or more callback functions for such, shortly after being launched (during the app's initialization phase). After the back button is pressed, the OS will invoke these callbacks. If the app's callback(s) do not explicitly mark the event as handled by the time they return, or if the app never registers one of these callback, the OS will consider the event un-handled, and it will apply its default back button behavior (terminate the app).
SDL registers its own back-button-press callback with the Windows Phone OS. This callback will emit a pair of SDL key-press events (
SDL_KEYDOWNandSDL_KEYUP), each with a scancode of SDL_SCANCODE_AC_BACK, after which it will check the contents of the hint,SDL_HINT_WINRT_HANDLE_BACK_BUTTON. If the hint's value is set to1, the back button event's Handled property will get set to atruevalue. If the hint's value is set to something else, or if it is unset, SDL will leave the event's Handled property alone. (By default, the OS sets this property to 'false', to note.)SDL apps can either set
SDL_HINT_WINRT_HANDLE_BACK_BUTTONwell before a back button is pressed, or can set it in direct-response to a back button being pressed.In order to get notified when a back button is pressed, SDL apps should register a callback function with
SDL_AddEventWatch( ), and have it listen forSDL_KEYDOWNevents that have a scancode ofSDL_SCANCODE_AC_BACK. (Alternatively,SDL_KEYUPevents can be listened-for. Listening for either event type is suitable.) Any value ofSDL_HINT_WINRT_HANDLE_BACK_BUTTONset by such a callback, will be applied to the OS' current back-button-press event.More details on back button behavior in Windows Phone apps can be found at the following page, on Microsoft's developer site: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj247550(v=vs.105).aspx
-
SDL_HINT_WINRT_PRIVACY_POLICY_LABELLabel text for a WinRT app's privacy policy link.
Network-enabled WinRT apps must include a privacy policy. On Windows 8, 8.1, and RT, Microsoft mandates that this policy be available via the Windows Settings charm. SDL provides code to add a link there, with its label text being set via the optional hint,
SDL_HINT_WINRT_PRIVACY_POLICY_LABEL.Please note that a privacy policy's contents are not set via this hint. A separate hint,
SDL_HINT_WINRT_PRIVACY_POLICY_URL, is used to link to the actual text of the policy.The contents of this hint should be encoded as a UTF8 string.
The default value is "Privacy Policy". This hint should only be set during app initialization, preferably before any calls to
SDL_Init( ... ).For additional information on linking to a privacy policy, see the documentation for
SDL_HINT_WINRT_PRIVACY_POLICY_URL. -
SDL_HINT_WINRT_PRIVACY_POLICY_URLA URL to a WinRT app's privacy policy.
All network-enabled WinRT apps must make a privacy policy available to its users. On Windows 8, 8.1, and RT, Microsoft mandates that this policy be be available in the Windows Settings charm, as accessed from within the app. SDL provides code to add a URL-based link there, which can point to the app's privacy policy.
To setup a URL to an app's privacy policy, set
SDL_HINT_WINRT_PRIVACY_POLICY_URLbefore calling anySDL_Init( ... )functions. The contents of the hint should be a valid URL. For example, http://www.example.com.The default value is an empty string (``), which will prevent SDL from adding a privacy policy link to the Settings charm. This hint should only be set during app init.
The label text of an app's "Privacy Policy" link may be customized via another hint,
SDL_HINT_WINRT_PRIVACY_POLICY_LABEL.Please note that on Windows Phone, Microsoft does not provide standard UI for displaying a privacy policy link, and as such, SDL_HINT_WINRT_PRIVACY_POLICY_URL will not get used on that platform. Network-enabled phone apps should display their privacy policy through some other, in-app means.
-
SDL_HINT_XINPUT_ENABLEDA variable that lets you disable the detection and use of Xinput gamepad devices
The variable can be set to the following values:
0 Disable XInput detection (only uses direct input) 1 Enable XInput detection (default) -
SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPINGA variable that causes SDL to use the old axis and button mapping for XInput devices.
This hint is for backwards compatibility only and will be removed in SDL 2.1
The default value is
0. This hint must be set beforeSDL_Init( ... ) -
SDL_HINT_QTWAYLAND_WINDOW_FLAGSFlags to set on QtWayland windows to integrate with the native window manager.
On QtWayland platforms, this hint controls the flags to set on the windows. For example, on Sailfish OS,
OverridesSystemGesturesdisables swipe gestures.This variable is a space-separated list of the following values (empty = no flags):
OverridesSystemGesturesStaysOnTopBypassWindowManager
-
SDL_HINT_QTWAYLAND_CONTENT_ORIENTATIONA variable describing the content orientation on QtWayland-based platforms.
On QtWayland platforms, windows are rotated client-side to allow for custom transitions. In order to correctly position overlays (e.g. volume bar) and gestures (e.g. events view, close/minimize gestures), the system needs to know in which orientation the application is currently drawing its contents.
This does not cause the window to be rotated or resized, the application needs to take care of drawing the content in the right orientation (the framebuffer is always in portrait mode).
This variable can be one of the following values:
primary(default)portraitlandscapeinverted-portraitinverted-landscape
-
SDL_HINT_RENDER_LOGICAL_SIZE_MODEA variable controlling the scaling policy for
SDL_RenderSetLogicalSize.This variable can be set to the following values:
-
0orletterboxUses letterbox/sidebars to fit the entire rendering on screen.
-
1oroverscanWill zoom the rendering so it fills the entire screen, allowing edges to be drawn offscreen.
By default letterbox is used.
-
-
SDL_HINT_VIDEO_EXTERNAL_CONTEXTA variable controlling whether the graphics context is externally managed.
This variable can be set to the following values:
0 SDL will manage graphics contexts that are attached to windows. 1 Disable graphics context management on windows.By default SDL will manage OpenGL contexts in certain situations. For example, on Android the context will be automatically saved and restored when pausing the application. Additionally, some platforms will assume usage of OpenGL if Vulkan isn't used. Setting this to
1will prevent this behavior, which is desirable when the application manages the graphics context, such as an externally managed OpenGL context or attaching a Vulkan surface to the window. -
<SDL_HINT_VIDEO_X11_WINDOW_VISUALID>
A variable forcing the visual ID chosen for new X11 windows.
-
SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITORA variable controlling whether the X11 _NET_WM_BYPASS_COMPOSITOR hint should be used.
This variable can be set to the following values:
0 Disable _NET_WM_BYPASS_COMPOSITOR 1 Enable _NET_WM_BYPASS_COMPOSITORBy default SDL will use _NET_WM_BYPASS_COMPOSITOR.
-
SDL_HINT_VIDEO_X11_FORCE_EGLA variable controlling whether X11 should use GLX or EGL by default
This variable can be set to the following values:
0 Use GLX 1 Use EGLBy default SDL will use GLX when both are present.
-
SDL_HINT_MOUSE_DOUBLE_CLICK_TIMEA variable setting the double click time, in milliseconds.
-
SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUSA variable setting the double click radius, in pixels.
-
SDL_HINT_MOUSE_NORMAL_SPEED_SCALEA variable setting the speed scale for mouse motion, in floating point, when the mouse is not in relative mode.
-
SDL_HINT_MOUSE_RELATIVE_SPEED_SCALEA variable setting the scale for mouse motion, in floating point, when the mouse is in relative mode.
-
SDL_HINT_MOUSE_RELATIVE_SCALINGA variable controlling whether relative mouse motion is affected by renderer scaling
This variable can be set to the following values:
0 Relative motion is unaffected by DPI or renderer's logical size 1 Relative motion is scaled according to DPI scaling and logical sizeBy default relative mouse deltas are affected by DPI and renderer scaling.
-
SDL_HINT_TOUCH_MOUSE_EVENTSA variable controlling whether touch events should generate synthetic mouse events
This variable can be set to the following values:
0 Touch events will not generate mouse events 1 Touch events will generate mouse eventsBy default SDL will generate mouse events for touch events.
-
SDL_HINT_MOUSE_TOUCH_EVENTSA variable controlling whether mouse events should generate synthetic touch events
This variable can be set to the following values:
0 Mouse events will not generate touch events (default for desktop platforms) 1 Mouse events will generate touch events (default for mobile platforms, such as Android and iOS) -
SDL_HINT_IOS_HIDE_HOME_INDICATORA variable controlling whether the home indicator bar on iPhone X should be hidden.
This variable can be set to the following values:
0 The indicator bar is not hidden (default for windowed applications) 1 The indicator bar is hidden and is shown when the screen is touched (useful for movie playback applications) 2 The indicator bar is dim and the first swipe makes it visible and the second swipe performs the "home" action (default for fullscreen applications) -
SDL_HINT_TV_REMOTE_AS_JOYSTICKA variable controlling whether the Android / tvOS remotes should be listed as joystick devices, instead of sending keyboard events.
This variable can be set to the following values:
0 Remotes send enter/escape/arrow key events 1 Remotes are available as 2 axis, 2 button joysticks (the default). -
SDL_HINT_GAMECONTROLLERTYPEA variable that overrides the automatic controller type detection
The variable should be comma separated entries, in the form: VID/PID=type
The VID and PID should be hexadecimal with exactly 4 digits, e.g.
0x00fdThe type should be one of:
-
Xbox360 -
XboxOne -
PS3 -
PS4 -
PS5 -
SwitchProThis hint affects what driver is used, and must be set before calling
SDL_Init(SDL_INIT_GAMECONTROLLER). -
SDL_HINT_GAMECONTROLLERCONFIG_FILEA variable that lets you provide a file with extra gamecontroller db entries.
The file should contain lines of gamecontroller config data, see SDL_gamecontroller.h
This hint must be set before calling
SDL_Init(SDL_INIT_GAMECONTROLLER)You can update mappings after the system is initialized with
SDL_GameControllerMappingForGUID( )andSDL_GameControllerAddMapping( ). -
SDL_HINT_GAMECONTROLLER_IGNORE_DEVICESA variable containing a list of devices to skip when scanning for game controllers.
The format of the string is a comma separated list of USB VID/PID pairs in hexadecimal form, e.g.
0xAAAA/0xBBBB,0xCCCC/0xDDDDThe variable can also take the form of @file, in which case the named file will be loaded and interpreted as the value of the variable.
-
SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPTIf set, all devices will be skipped when scanning for game controllers except for the ones listed in this variable.
The format of the string is a comma separated list of USB VID/PID pairs in hexadecimal form, e.g.
0xAAAA/0xBBBB,0xCCCC/0xDDDDThe variable can also take the form of @file, in which case the named file will be loaded and interpreted as the value of the variable.
-
SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELSIf set, game controller face buttons report their values according to their labels instead of their positional layout.
For example, on Nintendo Switch controllers, normally you'd get:
(Y) (X) (B) (A)but if this hint is set, you'll get:
(X) (Y) (A) (B)The variable can be set to the following values:
0 Report the face buttons by position, as though they were on an Xbox controller. 1 Report the face buttons by label instead of positionThe default value is
1. This hint may be set at any time. -
SDL_HINT_JOYSTICK_HIDAPIA variable controlling whether the HIDAPI joystick drivers should be used.
This variable can be set to the following values:
0 HIDAPI drivers are not used 1 HIDAPI drivers are used (the default)This variable is the default for all drivers, but can be overridden by the hints for specific drivers below.
-
SDL_HINT_JOYSTICK_HIDAPI_PS4A variable controlling whether the HIDAPI driver for PS4 controllers should be used.
This variable can be set to the following values:
0 HIDAPI driver is not used 1 HIDAPI driver is usedThe default is the value of
SDL_HINT_JOYSTICK_HIDAPI -
SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLEA variable controlling whether extended input reports should be used for PS4 controllers when using the HIDAPI driver.
This variable can be set to the following values:
0 extended reports are not enabled (default) 1 extended reportsExtended input reports allow rumble on Bluetooth PS4 controllers, but break DirectInput handling for applications that don't use SDL.
Once extended reports are enabled, they can not be disabled without power cycling the controller.
For compatibility with applications written for versions of SDL prior to the introduction of PS5 controller support, this value will also control the state of extended reports on PS5 controllers when the
SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLEhint is not explicitly set. -
SDL_HINT_JOYSTICK_HIDAPI_PS5A variable controlling whether the HIDAPI driver for PS5 controllers should be used.
This variable can be set to the following values:
0 HIDAPI driver is not used 1 HIDAPI driver is usedThe default is the value of
SDL_HINT_JOYSTICK_HIDAPI. -
SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLEA variable controlling whether extended input reports should be used for PS5 controllers when using the HIDAPI driver.
This variable can be set to the following values:
0 extended reports are not enabled (default) 1 extended reportsExtended input reports allow rumble on Bluetooth PS5 controllers, but break DirectInput handling for applications that don't use SDL.
Once extended reports are enabled, they can not be disabled without power cycling the controller.
For compatibility with applications written for versions of SDL prior to the introduction of PS5 controller support, this value defaults to the value of
SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE. -
SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LEDA variable controlling whether the player LEDs should be lit to indicate which player is associated with a PS5 controller.
This variable can be set to the following values:
0 player LEDs are not enabled 1 player LEDs are enabled (default) -
SDL_HINT_JOYSTICK_HIDAPI_STADIAA variable controlling whether the HIDAPI driver for Google Stadia controllers should be used.
This variable can be set to the following values:
0 HIDAPI driver is not used 1 HIDAPI driver is usedThe default is the value of
SDL_HINT_JOYSTICK_HIDAPI. -
SDL_HINT_JOYSTICK_HIDAPI_STEAMA variable controlling whether the HIDAPI driver for Steam Controllers should be used.
This variable can be set to the following values:
0 HIDAPI driver is not used 1 HIDAPI driver is usedThe default is the value of
SDL_HINT_JOYSTICK_HIDAPI. -
SDL_HINT_JOYSTICK_HIDAPI_SWITCHA variable controlling whether the HIDAPI driver for Nintendo Switch controllers should be used.
This variable can be set to the following values:
0 HIDAPI driver is not used 1 HIDAPI driver is usedThe default is the value of
SDL_HINT_JOYSTICK_HIDAPI. -
SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LEDA variable controlling whether the Home button LED should be turned on when a Nintendo Switch controller is opened
This variable can be set to the following values:
0 home button LED is left off 1 home button LED is turned on (default) -
SDL_HINT_JOYSTICK_HIDAPI_JOY_CONSA variable controlling whether Switch Joy-Cons should be treated the same as Switch Pro Controllers when using the HIDAPI driver.
This variable can be set to the following values:
0 basic Joy-Con support with no analog input (default) 1 Joy-Cons treated as half full Pro Controllers with analog inputs and sensorsThis does not combine Joy-Cons into a single controller. That's up to the user.
-
SDL_HINT_JOYSTICK_HIDAPI_XBOXA variable controlling whether the HIDAPI driver for XBox controllers should be used.
This variable can be set to the following values:
0 HIDAPI driver is not used 1 HIDAPI driver is usedThe default is
0on Windows, otherwise the value ofSDL_HINT_JOYSTICK_HIDAPI. -
SDL_HINT_JOYSTICK_HIDAPI_CORRELATE_XINPUTA variable controlling whether the HIDAPI driver for XBox controllers on Windows should pull correlated data from XInput.
This variable can be set to the following values:
0 HIDAPI Xbox driver will only use HIDAPI data 1 HIDAPI Xbox driver will also pull data from XInput, providing better trigger axes, guide button presses, and rumble supportThe default is
1. This hint applies to any joysticks opened after setting the hint. -
SDL_HINT_JOYSTICK_HIDAPI_GAMECUBEA variable controlling whether the HIDAPI driver for Nintendo GameCube controllers should be used.
This variable can be set to the following values:
0 HIDAPI driver is not used 1 HIDAPI driver is usedThe default is the value of
SDL_HINT_JOYSTICK_HIDAPI. -
SDL_HINT_ENABLE_STEAM_CONTROLLERSA variable that controls whether Steam Controllers should be exposed using the SDL joystick and game controller APIs
The variable can be set to the following values:
0 Do not scan for Steam Controllers 1 Scan for Steam Controllers (default)The default value is
1. This hint must be set before initializing the joystick subsystem. -
SDL_HINT_JOYSTICK_RAWINPUTA variable controlling whether the RAWINPUT joystick drivers should be used for better handling XInput-capable devices.
This variable can be set to the following values:
0 RAWINPUT drivers are not used 1 RAWINPUT drivers are used (default) -
SDL_HINT_JOYSTICK_THREADA variable controlling whether a separate thread should be used for handling joystick detection and raw input messages on Windows
This variable can be set to the following values:
0 A separate thread is not used (default) 1 A separate thread is used for handling raw input messages -
SDL_HINT_LINUX_JOYSTICK_DEADZONESA variable controlling whether joysticks on Linux adhere to their HID-defined deadzones or return unfiltered values.
This variable can be set to the following values:
0 Return unfiltered joystick axis values (default) 1 Return axis values with deadzones taken into account -
SDL_HINT_ALLOW_TOPMOSTIf set to
0then never set the top most bit on a SDL Window, even if the video mode expects it. This is a debugging aid for developers and not expected to be used by end users. The default is1.This variable can be set to the following values:
0 don't allow topmost 1 allow topmost (default) -
SDL_HINT_THREAD_PRIORITY_POLICYA string specifying additional information to use with
SDL_SetThreadPriority.By default
SDL_SetThreadPrioritywill make appropriate system changes in order to apply a thread priority. For example on systems using pthreads the scheduler policy is changed automatically to a policy that works well with a given priority. Code which has specific requirements can override SDL's default behavior with this hint.pthread hint values are
current,other,fifoandrr. Currently no other platform hint values are defined but may be in the future.Note:
On Linux, the kernel may send
SIGKILLto realtime tasks which exceed the distro configured execution budget for rtkit. This budget can be queried throughRLIMIT_RTTIMEafter callingSDL_SetThreadPriority( ). -
SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICALSpecifies whether
SDL_THREAD_PRIORITY_TIME_CRITICALshould be treated as realtime.On some platforms, like Linux, a realtime priority thread may be subject to restrictions that require special handling by the application. This hint exists to let SDL know that the app is prepared to handle said restrictions.
On Linux, SDL will apply the following configuration to any thread that becomes realtime:
-
The SCHED_RESET_ON_FORK bit will be set on the scheduling policy,
-
An RLIMIT_RTTIME budget will be configured to the rtkit specified limit.
Exceeding this limit will result in the kernel sending
SIGKILLto the app,Refer to the man pages for more information.
This variable can be set to the following values:
0 default platform specific behaviour 1 Force SDL_THREAD_PRIORITY_TIME_CRITICAL to a realtime scheduling policy -
-
SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMATA variable that is the address of another SDL_Window* (as a hex string formatted with
%p).If this hint is set before
SDL_CreateWindowFrom( )and theSDL_Window*it is set to hasSDL_WINDOW_OPENGLset (and running on WGL only, currently), then two things will occur on the newly createdSDL_Window:-
- Its pixel format will be set to the same pixel format as this
SDL_Window. This is needed for example when sharing an OpenGL context across multiple windows.
- Its pixel format will be set to the same pixel format as this
-
- The flag
SDL_WINDOW_OPENGLwill be set on the new window so it can be used for OpenGL rendering.
This variable can be set to the following values:
- The address (as a string
%p) of theSDL_Window*that new windows created withSDL_CreateWindowFrom( ... )should share a pixel format with.
- The flag
-
SDL_HINT_ANDROID_TRAP_BACK_BUTTONA variable to control whether we trap the Android back button to handle it manually. This is necessary for the right mouse button to work on some Android devices, or to be able to trap the back button for use in your code reliably. If set to true, the back button will show up as an SDL_KEYDOWN / SDL_KEYUP pair with a keycode of
SDL_SCANCODE_AC_BACK.The variable can be set to the following values:
-
0Back button will be handled as usual for system. (default)
-
1Back button will be trapped, allowing you to handle the key press manually. (This will also let right mouse click work on systems where the right mouse button functions as back.)
The value of this hint is used at runtime, so it can be changed at any time.
-
-
-
SDL_HINT_ANDROID_BLOCK_ON_PAUSEA variable to control whether the event loop will block itself when the app is paused.
The variable can be set to the following values:
-
0Non blocking.
-
1Blocking. (default)
The value should be set before SDL is initialized.
-
-
-
SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIOA variable to control whether SDL will pause audio in background (Requires
SDL_ANDROID_BLOCK_ON_PAUSEas "Non blocking")The variable can be set to the following values:
-
0Non paused.
-
1Paused. (default)
The value should be set before SDL is initialized.
-
-
SDL_HINT_RETURN_KEY_HIDES_IMEA variable to control whether the return key on the soft keyboard should hide the soft keyboard on Android and iOS.
The variable can be set to the following values:
-
0The return key will be handled as a key event. This is the behaviour of SDL <= 2.0.3. (default)
-
1The return key will hide the keyboard.
The value of this hint is used at runtime, so it can be changed at any time.
-
-
SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONSForce SDL to use Critical Sections for mutexes on Windows. On Windows 7 and newer, Slim Reader/Writer Locks are available. They offer better performance, allocate no kernel resources and use less memory. SDL will fall back to Critical Sections on older OS versions or if forced to by this hint.
This also affects Condition Variables. When SRW mutexes are used, SDL will use Windows Condition Variables as well. Else, a generic SDL_cond implementation will be used that works with all mutexes.
This variable can be set to the following values:
-
0Use SRW Locks when available. If not, fall back to Critical Sections. (default)
-
1Force the use of Critical Sections in all cases.
-
-
SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNELForce SDL to use Kernel Semaphores on Windows. Kernel Semaphores are inter-process and require a context switch on every interaction. On Windows 8 and newer, the WaitOnAddress API is available. Using that and atomics to implement semaphores increases performance. SDL will fall back to Kernel Objects on older OS versions or if forced to by this hint.
This variable can be set to the following values:
-
0Use Atomics and WaitOnAddress API when available. If not, fall back to Kernel Objects. (default)
-
1Force the use of Kernel Objects in all cases.
-
-
SDL_HINT_WINDOWS_USE_D3D9EXUse the D3D9Ex API introduced in Windows Vista, instead of normal D3D9. Direct3D 9Ex contains changes to state management that can eliminate device loss errors during scenarios like Alt+Tab or UAC prompts. D3D9Ex may require some changes to your application to cope with the new behavior, so this is disabled by default.
This hint must be set before initializing the video subsystem.
For more information on Direct3D 9Ex, see:
- https://docs.microsoft.com/en-us/windows/win32/direct3darticles/graphics-apis-in-windows-vista#direct3d-9ex
- https://docs.microsoft.com/en-us/windows/win32/direct3darticles/direct3d-9ex-improvements
This variable can be set to the following values:
-
0Use the original Direct3D 9 API (default)
-
1Use the Direct3D 9Ex API on Vista and later (and fall back if D3D9Ex is unavailable)
-
SDL_HINT_VIDEO_DOUBLE_BUFFERTell the video driver that we only want a double buffer.
By default, most lowlevel 2D APIs will use a triple buffer scheme that wastes no CPU time on waiting for vsync after issuing a flip, but introduces a frame of latency. On the other hand, using a double buffer scheme instead is recommended for cases where low latency is an important factor because we save a whole frame of latency. We do so by waiting for vsync immediately after issuing a flip, usually just after eglSwapBuffers call in the backend's *_SwapWindow function.
Since it's driver-specific, it's only supported where possible and implemented. Currently supported the following drivers:
- KMSDRM (kmsdrm)
- Raspberry Pi (raspberrypi)
-
SDL_HINT_KMSDRM_REQUIRE_DRM_MASTERDetermines whether SDL enforces that DRM master is required in order to initialize the KMSDRM video backend.
The DRM subsystem has a concept of a "DRM master" which is a DRM client that has the ability to set planes, set cursor, etc. When SDL is DRM master, it can draw to the screen using the SDL rendering APIs. Without DRM master, SDL is still able to process input and query attributes of attached displays, but it cannot change display state or draw to the screen directly.
In some cases, it can be useful to have the KMSDRM backend even if it cannot be used for rendering. An app may want to use SDL for input processing while using another rendering API (such as an MMAL overlay on Raspberry Pi) or using its own code to render to DRM overlays that SDL doesn't support.
This hint must be set before initializing the video subsystem.
This variable can be set to the following values:
-
0SDL will allow usage of the KMSDRM backend without DRM master
-
1SDL Will require DRM master to use the KMSDRM backend (default)
-
-
SDL_HINT_OPENGL_ES_DRIVERA variable controlling what driver to use for OpenGL ES contexts.
On some platforms, currently Windows and X11, OpenGL drivers may support creating contexts with an OpenGL ES profile. By default SDL uses these profiles, when available, otherwise it attempts to load an OpenGL ES library, e.g. that provided by the ANGLE project. This variable controls whether SDL follows this default behaviour or will always load an OpenGL ES library.
Circumstances where this is useful include
-
- Testing an app with a particular OpenGL ES implementation, e.g ANGLE, or emulator, e.g. those from ARM, Imagination or Qualcomm.
- Resolving OpenGL ES function addresses at link time by linking with the OpenGL ES library instead of querying them at run time with
SDL_GL_GetProcAddress( ).
Caution: for an application to work with the default behaviour across different OpenGL drivers it must query the OpenGL ES function addresses at run time using
SDL_GL_GetProcAddress( ).This variable is ignored on most platforms because OpenGL ES is native or not supported.
This variable can be set to the following values:
-
0Use ES profile of OpenGL, if available. (Default when not set.)
-
1Load OpenGL ES library using the default library names.
-
-
SDL_HINT_AUDIO_RESAMPLING_MODEA variable controlling speed/quality tradeoff of audio resampling.
If available, SDL can use libsamplerate ( http://www.mega-nerd.com/SRC/ ) to handle audio resampling. There are different resampling modes available that produce different levels of quality, using more CPU.
If this hint isn't specified to a valid setting, or libsamplerate isn't available, SDL will use the default, internal resampling algorithm.
Note that this is currently only applicable to resampling audio that is being written to a device for playback or audio being read from a device for capture. SDL_AudioCVT always uses the default resampler (although this might change for SDL 2.1).
This hint is currently only checked at audio subsystem initialization.
This variable can be set to the following values:
-
0ordefaultUse SDL's internal resampling (Default when not set - low quality, fast)
-
1orfastUse fast, slightly higher quality resampling, if available
-
2ormediumUse medium quality resampling, if available
-
3orbestUse high quality resampling, if available
-
-
SDL_HINT_AUDIO_CATEGORYA variable controlling the audio category on iOS and Mac OS X.
This variable can be set to the following values:
-
ambientUse the AVAudioSessionCategoryAmbient audio category, will be muted by the phone mute switch (default)
-
playbackUse the AVAudioSessionCategoryPlayback category
For more information, see Apple's documentation: https://developer.apple.com/library/content/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionCategoriesandModes/AudioSessionCategoriesandModes.html
-
-
SDL_HINT_RENDER_BATCHINGA variable controlling whether the 2D render API is compatible or efficient.
This variable can be set to the following values:
-
0Don't use batching to make rendering more efficient.
-
1Use batching, but might cause problems if app makes its own direct OpenGL calls.
Up to SDL 2.0.9, the render API would draw immediately when requested. Now it batches up draw requests and sends them all to the GPU only when forced to (during SDL_RenderPresent, when changing render targets, by updating a texture that the batch needs, etc). This is significantly more efficient, but it can cause problems for apps that expect to render on top of the render API's output. As such, SDL will disable batching if a specific render backend is requested (since this might indicate that the app is planning to use the underlying graphics API directly). This hint can be used to explicitly request batching in this instance. It is a contract that you will either never use the underlying graphics API directly, or if you do, you will call
SDL_RenderFlush( )before you do so any current batch goes to the GPU before your work begins. Not following this contract will result in undefined behavior. -
-
SDL_HINT_AUTO_UPDATE_JOYSTICKSA variable controlling whether SDL updates joystick state when getting input events
This variable can be set to the following values:
-
0You'll call
SDL_JoystickUpdate( )manually -
1SDL will automatically call
SDL_JoystickUpdate( )(default)
This hint can be toggled on and off at runtime.
-
-
SDL_HINT_AUTO_UPDATE_SENSORSA variable controlling whether SDL updates sensor state when getting input events
This variable can be set to the following values:
-
0You'll call
SDL_SensorUpdate ( )manually -
1SDL will automatically call
SDL_SensorUpdate( )(default)
This hint can be toggled on and off at runtime.
-
-
SDL_HINT_EVENT_LOGGINGA variable controlling whether SDL logs all events pushed onto its internal queue.
This variable can be set to the following values:
-
0Don't log any events (default)
-
1Log all events except mouse and finger motion, which are pretty spammy.
-
2Log all events.
This is generally meant to be used to debug SDL itself, but can be useful for application developers that need better visibility into what is going on in the event queue. Logged events are sent through
SDL_Log( ), which means by default they appear on stdout on most platforms or maybeOutputDebugString( )on Windows, and can be funneled by the app withSDL_LogSetOutputFunction( ), etc.This hint can be toggled on and off at runtime, if you only need to log events for a small subset of program execution.
-
-
SDL_HINT_WAVE_RIFF_CHUNK_SIZEControls how the size of the RIFF chunk affects the loading of a WAVE file.
The size of the RIFF chunk (which includes all the sub-chunks of the WAVE file) is not always reliable. In case the size is wrong, it's possible to just ignore it and step through the chunks until a fixed limit is reached.
Note that files that have trailing data unrelated to the WAVE file or corrupt files may slow down the loading process without a reliable boundary. By default, SDL stops after 10000 chunks to prevent wasting time. Use the environment variable SDL_WAVE_CHUNK_LIMIT to adjust this value.
This variable can be set to the following values:
-
forceAlways use the RIFF chunk size as a boundary for the chunk search
-
ignorezeroLike "force", but a zero size searches up to 4 GiB (default)
-
ignoreIgnore the RIFF chunk size and always search up to 4 GiB
-
maximumSearch for chunks until the end of file (not recommended)
-
-
SDL_HINT_WAVE_TRUNCATIONControls how a truncated WAVE file is handled.
A WAVE file is considered truncated if any of the chunks are incomplete or the data chunk size is not a multiple of the block size. By default, SDL decodes until the first incomplete block, as most applications seem to do.
This variable can be set to the following values:
-
verystrictRaise an error if the file is truncated
-
strictLike "verystrict", but the size of the RIFF chunk is ignored
-
dropframeDecode until the first incomplete sample frame
-
dropblockDecode until the first incomplete block (default)
-
-
SDL_HINT_WAVE_FACT_CHUNKControls how the fact chunk affects the loading of a WAVE file.
The fact chunk stores information about the number of samples of a WAVE file. The Standards Update from Microsoft notes that this value can be used to 'determine the length of the data in seconds'. This is especially useful for compressed formats (for which this is a mandatory chunk) if they produce multiple sample frames per block and truncating the block is not allowed. The fact chunk can exactly specify how many sample frames there should be in this case.
Unfortunately, most application seem to ignore the fact chunk and so SDL ignores it by default as well.
This variable can be set to the following values:
-
truncateUse the number of samples to truncate the wave data if the fact chunk is present and valid
-
strictLike "truncate", but raise an error if the fact chunk is invalid, not present for non-PCM formats, or if the data chunk doesn't have that many samples
-
ignorezeroLike "truncate", but ignore fact chunk if the number of samples is zero
-
ignoreIgnore fact chunk entirely (default)
-
-
SDL_HINT_DISPLAY_USABLE_BOUNDSOverride for
SDL_GetDisplayUsableBounds( )If set, this hint will override the expected results for
SDL_GetDisplayUsableBounds( )for display index 0. Generally you don't want to do this, but this allows an embedded system to request that some of the screen be reserved for other uses when paired with a well-behaved application.The contents of this hint must be 4 comma-separated integers, the first is the bounds x, then y, width and height, in that order.
-
SDL_HINT_AUDIO_DEVICE_APP_NAMESpecify an application name for an audio device.
Some audio backends (such as PulseAudio) allow you to describe your audio stream. Among other things, this description might show up in a system control panel that lets the user adjust the volume on specific audio streams instead of using one giant master volume slider.
This hints lets you transmit that information to the OS. The contents of this hint are used while opening an audio device. You should use a string that describes your program ("My Game 2: The Revenge")
Setting this to "" or leaving it unset will have SDL use a reasonable default: probably the application's name or "SDL Application" if SDL doesn't have any better information.
On targets where this is not supported, this hint does nothing.
-
SDL_HINT_AUDIO_DEVICE_STREAM_NAMESpecify an application name for an audio device.
Some audio backends (such as PulseAudio) allow you to describe your audio stream. Among other things, this description might show up in a system control panel that lets the user adjust the volume on specific audio streams instead of using one giant master volume slider.
This hints lets you transmit that information to the OS. The contents of this hint are used while opening an audio device. You should use a string that describes your what your program is playing ("audio stream" is probably sufficient in many cases, but this could be useful for something like "team chat" if you have a headset playing VoIP audio separately).
Setting this to "" or leaving it unset will have SDL use a reasonable default: "audio stream" or something similar.
On targets where this is not supported, this hint does nothing.
-
SDL_HINT_AUDIO_DEVICE_STREAM_ROLESpecify an application role for an audio device.
Some audio backends (such as Pipewire) allow you to describe the role of your audio stream. Among other things, this description might show up in a system control panel or software for displaying and manipulating media playback/capture graphs.
This hints lets you transmit that information to the OS. The contents of this hint are used while opening an audio device. You should use a string that describes your what your program is playing (Game, Music, Movie, etc...).
Setting this to "" or leaving it unset will have SDL use a reasonable default: "Game" or something similar.
On targets where this is not supported, this hint does nothing.
-
SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBEDSpecify the behavior of Alt+Tab while the keyboard is grabbed.
By default, SDL emulates Alt+Tab functionality while the keyboard is grabbed and your window is full-screen. This prevents the user from getting stuck in your application if you've enabled keyboard grab.
The variable can be set to the following values:
-
0SDL will not handle Alt+Tab. Your application is responsible for handling Alt+Tab while the keyboard is grabbed.
-
1SDL will minimize your window when Alt+Tab is pressed (default)
-
-
SDL_HINT_PREFERRED_LOCALESOverride for SDL_GetPreferredLocales( )
If set, this will be favored over anything the OS might report for the user's preferred locales. Changing this hint at runtime will not generate a SDL_LOCALECHANGED event (but if you can change the hint, you can push your own event, if you want).
The format of this hint is a comma-separated list of language and locale, combined with an underscore, as is a common format: "en_GB". Locale is optional: "en". So you might have a list like this: "en_GB,jp,es_PT"
:logcategory
The predefined log categories
By default the application category is enabled at the INFO level, the assert category is enabled at the WARN level, test is enabled at the VERBOSE level and all other categories are enabled at the CRITICAL level.
SDL_LOG_CATEGORY_APPLICATIONSDL_LOG_CATEGORY_ERRORSDL_LOG_CATEGORY_ASSERTSDL_LOG_CATEGORY_SYSTEMSDL_LOG_CATEGORY_AUDIOSDL_LOG_CATEGORY_VIDEOSDL_LOG_CATEGORY_RENDERSDL_LOG_CATEGORY_INPUTSDL_LOG_CATEGORY_TESTSDL_LOG_CATEGORY_RESERVED1SDL_LOG_CATEGORY_RESERVED2SDL_LOG_CATEGORY_RESERVED3SDL_LOG_CATEGORY_RESERVED4SDL_LOG_CATEGORY_RESERVED5SDL_LOG_CATEGORY_RESERVED6SDL_LOG_CATEGORY_RESERVED7SDL_LOG_CATEGORY_RESERVED8SDL_LOG_CATEGORY_RESERVED9SDL_LOG_CATEGORY_RESERVED10SDL_LOG_CATEGORY_CUSTOM
:logpriority
The predefined log priorities.
SDL_LOG_PRIORITY_VERBOSESDL_LOG_PRIORITY_DEBUGSDL_LOG_PRIORITY_INFOSDL_LOG_PRIORITY_WARNSDL_LOG_PRIORITY_ERRORSDL_LOG_PRIORITY_CRITICALSDL_NUM_LOG_PRIORITIES
:windowflags
The flags on a window.
-
SDL_WINDOW_FULLSCREEN- Fullscreen window -
SDL_WINDOW_OPENGL- Window usable with OpenGL context -
SDL_WINDOW_SHOWN- Window is visible -
SDL_WINDOW_HIDDEN- Window is not visible -
SDL_WINDOW_BORDERLESS- No window decoration -
SDL_WINDOW_RESIZABLE- Window can be resized -
SDL_WINDOW_MINIMIZED- Window is minimized -
SDL_WINDOW_MAXIMIZED- Window is maximized -
SDL_WINDOW_MOUSE_GRABBED- Window has grabbed mouse input -
SDL_WINDOW_INPUT_FOCUS- Window has input focus -
SDL_WINDOW_MOUSE_FOCUS- Window has mouse focus -
SDL_WINDOW_FULLSCREEN_DESKTOP- Fullscreen window without frame -
SDL_WINDOW_FOREIGN- Window not created by SDL -
SDL_WINDOW_ALLOW_HIGHDPI- Window should be created in high-DPI mode if supported.On macOS NSHighResolutionCapable must be set true in the application's Info.plist for this to have any effect.
-
SDL_WINDOW_MOUSE_CAPTURE- Window has mouse captured (unrelated toMOUSE_GRABBED) -
SDL_WINDOW_ALWAYS_ON_TOP- Window should always be above others -
SDL_WINDOW_SKIP_TASKBAR- Window should not be added to the taskbar -
SDL_WINDOW_UTILITY- Window should be treated as a utility window -
SDL_WINDOW_TOOLTIP- Window should be treated as a tooltip -
SDL_WINDOW_POPUP_MENU- Window should be treated as a popup menu -
SDL_WINDOW_KEYBOARD_GRABBED- Window has grabbed keyboard input -
SDL_WINDOW_VULKAN- Window usable for Vulkan surface -
SDL_WINDOW_METAL- Window usable for Metal view -
SDL_WINDOW_INPUT_GRABBED- Equivalent toSDL_WINDOW_MOUSE_GRABBEDfor compatibility
:windowEventID
Event subtype for window events.
SDL_WINDOWEVENT_NONE- Never usedSDL_WINDOWEVENT_SHOWN- Window has been shownSDL_WINDOWEVENT_HIDDEN- Window has been hiddenSDL_WINDOWEVENT_EXPOSED- Window has been exposed and should be redrawnSDL_WINDOWEVENT_MOVED- Window has been moved todata1, data2SDL_WINDOWEVENT_RESIZED- Window has been resized todata1 x data2SDL_WINDOWEVENT_SIZE_CHANGED- The window size has changed, either as a result of an API call or through the system or user changing the window size.SDL_WINDOWEVENT_MINIMIZED- Window has been minimizedSDL_WINDOWEVENT_MAXIMIZED- Window has been maximizedSDL_WINDOWEVENT_RESTORED- Window has been restored to normal size and positionSDL_WINDOWEVENT_ENTER- Window has gained mouse focusSDL_WINDOWEVENT_LEAVE- Window has lost mouse focusSDL_WINDOWEVENT_FOCUS_GAINED- Window has gained keyboard focusSDL_WINDOWEVENT_FOCUS_LOST- Window has lost keyboard focusSDL_WINDOWEVENT_CLOSE- The window manager requests that the window be closedSDL_WINDOWEVENT_TAKE_FOCUS- Window is being offered a focus (shouldSetWindowInputFocus( )on itself or a subwindow, or ignore)SDL_WINDOWEVENT_HIT_TEST- Window had a hit test that wasn'tSDL_HITTEST_NORMAL.
:displayEventID
Event subtype for display events.
SDL_DISPLAYEVENT_NONE- Never usedSDL_DISPLAYEVENT_ORIENTATION- Display orientation has changed to data1SDL_DISPLAYEVENT_CONNECTED- Display has been added to the systemSDL_DISPLAYEVENT_DISCONNECTED- Display has been removed from the system
:displayOrientation
SDL_ORIENTATION_UNKNOWN- The display orientation can't be determinedSDL_ORIENTATION_LANDSCAPE- The display is in landscape mode, with the right side up, relative to portrait modeSDL_ORIENTATION_LANDSCAPE_FLIPPED- The display is in landscape mode, with the left side up, relative to portrait modeSDL_ORIENTATION_PORTRAIT- The display is in portrait modeSDL_ORIENTATION_PORTRAIT_FLIPPED- The display is in portrait mode, upside down
:glAttr
OpenGL configuration attributes.
SDL_GL_RED_SIZESDL_GL_GREEN_SIZESDL_GL_BLUE_SIZESDL_GL_ALPHA_SIZESDL_GL_BUFFER_SIZESDL_GL_DOUBLEBUFFERSDL_GL_DEPTH_SIZESDL_GL_STENCIL_SIZESDL_GL_ACCUM_RED_SIZESDL_GL_ACCUM_GREEN_SIZESDL_GL_ACCUM_BLUE_SIZESDL_GL_ACCUM_ALPHA_SIZESDL_GL_STEREOSDL_GL_MULTISAMPLEBUFFERSSDL_GL_MULTISAMPLESAMPLESSDL_GL_ACCELERATED_VISUALSDL_GL_RETAINED_BACKINGSDL_GL_CONTEXT_MAJOR_VERSIONSDL_GL_CONTEXT_MINOR_VERSIONSDL_GL_CONTEXT_EGLSDL_GL_CONTEXT_FLAGSSDL_GL_CONTEXT_PROFILE_MASKSDL_GL_SHARE_WITH_CURRENT_CONTEXTSDL_GL_FRAMEBUFFER_SRGB_CAPABLESDL_GL_CONTEXT_RELEASE_BEHAVIORSDL_GL_CONTEXT_RESET_NOTIFICATIONSDL_GL_CONTEXT_NO_ERROR
:glProfile
SDL_GL_CONTEXT_PROFILE_CORESDL_GL_CONTEXT_PROFILE_COMPATIBILITYSDL_GL_CONTEXT_PROFILE_ES
:glContextFlag
SDL_GL_CONTEXT_DEBUG_FLAGSDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAGSDL_GL_CONTEXT_ROBUST_ACCESS_FLAGSDL_GL_CONTEXT_RESET_ISOLATION_FLAG
:glContextReleaseFlag
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONESDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH
:glContextResetNotification
SDL_GL_CONTEXT_RESET_NO_NOTIFICATIONSDL_GL_CONTEXT_RESET_LOSE_CONTEXT
:rendererFlags
Flags used when creating a rendering context.
SDL_RENDERER_SOFTWARE- The renderer is a software fallbackSDL_RENDERER_ACCELERATED- The renderer uses hardware accelerationSDL_RENDERER_PRESENTVSYNC- Present is synchronized with the refresh rateSDL_RENDERER_TARGETTEXTURE- The renderer supports rendering to texture
:scaleMode
The scaling mode for a texture.
SDL_SCALEMODENEAREST- nearest pixel samplingSDL_SCALEMODELINEAR- linear filteringSDL_SCALEMODEBEST- anisotropic filtering
:textureAccess
The access pattern allowed for a texture.
SDL_TEXTUREACCESS_STATIC- Changes rarely, not lockableSDL_TEXTUREACCESS_STREAMING- Changes frequently, lockableSDL_TEXTUREACCESS_TARGET- Texture can be used as a render target
:textureModulate
The texture channel modulation used in SDL_RenderCopy( ... ).
SDL_TEXTUREMODULATE_NONE- No modulationSDL_TEXTUREMODULATE_COLOR- srcC = srcC * colorSDL_TEXTUREMODULATE_ALPHA- srcA = srcA * alpha
:renderFlip
Flip constants for SDL_RenderCopyEx( ... ).
SDL_FLIP_NONE- do not flipSDL_FLIP_HORIZONTAL- flip horizontallySDL_FLIP_VERTICAL- flip vertically
:blendMode
The blend mode used in SDL_RenderCopy( ... ) and drawing operations.
-
SDL_BLENDMODE_NONE- no blendingdstRGBA = srcRGBA -
SDL_BLENDMODE_BLEND- alpha blendingdstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) dstA = srcA + (dstA * (1-srcA)) -
SDL_BLENDMODE_ADD- additive blendingdstRGB = (srcRGB * srcA) + dstRGB dstA = dstA -
SDL_BLENDMODE_MOD- color modulatedstRGB = srcRGB * dstRGB dstA = dstA -
SDL_BLENDMODE_MUL- color multiplydstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)) dstA = (srcA * dstA) + (dstA * (1-srcA)) -
SDL_BLENDMODE_INVALID-
Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode( ... )
:blendOperation
The blend operation used when combining source and destination pixel components.
SDL_BLENDOPERATION_ADD-dst + src: supported by all renderersSDL_BLENDOPERATION_SUBTRACT-dst - src: supported by D3D9, D3D11, OpenGL, OpenGLESSDL_BLENDOPERATION_REV_SUBTRACT-src - dst: supported by D3D9, D3D11, OpenGL, OpenGLESSDL_BLENDOPERATION_MINIMUM-min(dst, src): supported by D3D11SDL_BLENDOPERATION_MAXIMUM-max(dst, src): supported by D3D11
:blendFactor
The normalized factor used to multiply pixel components.
SDL_BLENDFACTOR_ZERO-0, 0, 0, 0SDL_BLENDFACTOR_ONE-1, 1, 1, 1SDL_BLENDFACTOR_SRC_COLOR-srcR, srcG, srcB, srcASDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR-1-srcR, 1-srcG, 1-srcB, 1-srcASDL_BLENDFACTOR_SRC_ALPHA-srcA, srcA, srcA, srcASDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA-1-srcA, 1-srcA, 1-srcA, 1-srcASDL_BLENDFACTOR_DST_COLOR-dstR, dstG, dstB, dstASDL_BLENDFACTOR_ONE_MINUS_DST_COLOR-1-dstR, 1-dstG, 1-dstB, 1-dstASDL_BLENDFACTOR_DST_ALPHA-dstA, dstA, dstA, dstASDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA-1-dstA, 1-dstA, 1-dstA, 1-dstA
:audio
Audio format flags.
These are what the 16 bits in SDL_AudioFormat currently mean... (Unspecified bits are always zero).
++-----------------------sample is signed if set
||
|| ++-----------sample is bigendian if set
|| ||
|| || ++---sample is float if set
|| || ||
|| || || +---sample bit size---+
|| || || | |
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
There are macros in SDL 2.0 and later to query these bits.
Audio flags
SDL_AUDIO_MASK_BITSIZESDL_AUDIO_MASK_DATATYPESDL_AUDIO_MASK_ENDIANSDL_AUDIO_MASK_SIGNEDSDL_AUDIO_BITSIZESDL_AUDIO_ISFLOATSDL_AUDIO_ISBIGENDIANSDL_AUDIO_ISSIGNEDSDL_AUDIO_ISINTSDL_AUDIO_ISLITTLEENDIANSDL_AUDIO_ISUNSIGNED
Audio format flags
Defaults to LSB byte order.
AUDIO_U8- Unsigned 8-bit samplesAUDIO_S8- Signed 8-bit samplesAUDIO_U16LSB- Unsigned 16-bit samplesAUDIO_S16LSB- Signed 16-bit samplesAUDIO_U16MSB- As above, but big-endian byte orderAUDIO_S16MSB- As above, but big-endian byte orderAUDIO_U16-AUDIO_U16LSBAUDIO_S16-AUDIO_S16LSB
int32 support
AUDIO_S32LSB- 32-bit integer samplesAUDIO_S32MSB- As above, but big-endian byte orderAUDIO_S32-AUDIO_S32LSB
float32 support
AUDIO_F32LSB- 32-bit floating point samplesAUDIO_F32MSB- As above, but big-endian byte orderAUDIO_F32-AUDIO_F32LSB
Native audio byte ordering
AUDIO_U16SYSAUDIO_S16SYSAUDIO_S32SYSAUDIO_F32SYS
Allow change flags
Which audio format changes are allowed when opening a device.
SDL_AUDIO_ALLOW_FREQUENCY_CHANGESDL_AUDIO_ALLOW_FORMAT_CHANGESDL_AUDIO_ALLOW_CHANNELS_CHANGESDL_AUDIO_ALLOW_SAMPLES_CHANGESDL_AUDIO_ALLOW_ANY_CHANGE
Development
SDL2 is still in early development: the majority of SDL's functions have yet to be implemented and the interface may also grow to be less sugary leading up to an eventual 1.0 release. If you like stable, well tested software that performs as documented, you should hold off on trying to use SDL2 for a bit.
LICENSE
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the terms found in the Artistic License 2. Other copyrights, terms, and conditions may apply to data transmitted through this module.
AUTHOR
Sanko Robinson sanko@cpan.org