SDL2-FFI
view release on metacpan or search on metacpan
lib/SDL2/video.pm view on Meta::CPAN
You can use C<SDL_GetNumVideoDrivers( )> and C<SDL_GetVideoDriver( )> to find a
specific C<driver_name>.
Expected parameters include:
=over
=item C<driver_name> - the name of a video driver to initialize, or C<undef> for the default driver
=back
Returns C<0> on success or a negative error code on failure; call
C<SDL_GetError( )> for more information.
=head2 C<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.
=head2 C<SDL_GetCurrentVideoDriver( ... )>
Get the name of the currently initialized video driver.
my $driver = SDL_GetCurrentVideoDriver( );
Returns the name of the current video driver or C<undef> if no driver has been
initialized.
=head2 C<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 C<SDL_GetError(
)> for more information.
=head2 C<SDL_GetDisplayName( ... )>
Get the name of a display in UTF-8 encoding.
my $screen = SDL_GetDisplayName( 0 );
Expected parameters include:
=over
=item C<displayIndex> the index of display from which the name should be queried
=back
Returns the name of a display or C<undef> for an invalid display index or
failure; call C<SDL_GetError( )> for more information.
=head2 C<SDL_GetDisplayBounds( ... )>
Get the desktop area represented by a display.
SDL_GetDisplayBounds( 0, my $rect );
The primary display (C<displayIndex> zero) is always located at C<0,0>.
Expected parameters include:
=over
=item C<displayIndex> - the index of the display to query
=item C<rect> - the L<SDL2::Rect> structure filled in with the display bounds
=back
Returns C<0> on success or a negative error code on failure; call
C<SDL_GetError( )> for more information.
=head2 C<SDL_GetDisplayUsableBounds( ... )>
Get the usable desktop area represented by a display.
SDL_GetDisplayUsableBounds( 0, my $rect );
The primary display (C<displayIndex> zero) is always located at C<0,0>.
This is the same area as C<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.
The parameter C<rect> is ignored if it is C<undef>.
This function also returns C<-1> if the parameter C<displayIndex> is out of
range.
Expected parameters include:
=over
=item C<displayIndex> - the index of the display to query the usable bounds from
=item C<rect> - the L<SDL2::Rect> structure filled in with the display bounds
=back
Returns C<0> on success or a negative error code on failure; call
C<SDL_GetError( )> for more information.
=head2 C<SDL_GetDisplayDPI( ... )>
Get the dots/pixels-per-inch for a display.
SDL_GetDisplayDPI( 0, \my $ddpi, \my $hdpi, \my $vdpi );
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 C<displayIndex> is out of range.
Expected parameters include:
=over
=item C<displayIndex> - the index of the display from which DPI information should be queried
=item C<ddpi> - a pointer filled in with the diagonal DPI of the display; may be C<undef>
=item C<hdpi> - a pointer filled in with the horizontal DPI of the display; may be C<undef>
=item C<vdpi> - a pointer filled in with the vertical DPI of the display; may be C<undef>
=back
Returns C<0> on success or a negative error code on failure; call
C<SDL_GetError( )> for more information.
lib/SDL2/video.pm view on Meta::CPAN
=back
Returns The SDL_DisplayOrientation enum value of the display, or
C<SDL_ORIENTATION_UNKNOWN> if it isn't available.
=head2 C<SDL_GetNumDisplayModes( ... )>
Get the number of available display modes.
The C<displayIndex> needs to be in the range from 0 to
C<SDL_GetNumVideoDisplays( ) - 1>.
Expected parameters include:
=over
=item C<displayIndex> - the index of the display to query
=back
Returns a number >= 1 on success or a negative error code on failure; call
C<SDL_GetError( )> for more information.
=head2 C<SDL_GetDisplayMode( ... )>
Get information about a specific display mode.
The display modes are sorted in this priority:
=over
=item - width -> largest to smallest
=item - height -> largest to smallest
=item - bits per pixel -> more colors to fewer colors
=item - packed pixel layout -> largest to smallest
=item - refresh rate -> highest to lowest
=back
Expected parameters include:
=over
=item C<displayIndex> - the index of the display to query
=item C<modeIndex> - the index of the display mode to query
=item C<mode> - an L<SDL2::DisplayMode> structure filled in with the mode at C<modeIndex>
=back
Returns C<0> on success or a negative error code on failure; call
C<SDL_GetError( )> for more information.
=head2 C<SDL_GetDesktopDisplayMode( ... )>
Get information about the desktop's display mode.
There's a difference between this function and L<< C<SDL_GetCurrentDisplayMode(
... )>|/C<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:
=over
=item C<displayIndex> - the index of the display to query
=item C<mode> - an L<SDL2::DisplayMode> structure filled in with the current display mode
=back
Returns C<0> on success or a negative error code on failure; call
C<SDL_GetError( )> for more information.
=head2 C<SDL_GetCurrentDisplayMode( ... )>
Get information about the current display mode.
There's a difference between this function and L<< C<SDL_GetDesktopDisplayMode(
... )>|/C<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:
=over
=item C<displayIndex> - the index of the display to query
=item C<mode> - an L<SDL2::DisplayMode> structure filled in with the current display mode
=back
Returns C<0> on success or a negative error code on failure; call
C<SDL_GetError( )> for more information.
=head2 C<SDL_GetClosestDisplayMode( ... )>
Get the closest match to the requested display mode.
The available display modes are scanned and C<closest> is filled in with the
closest mode matching the requested mode and returned. The mode format and
refresh rate default to the desktop mode if they are set to C<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 C<undef> is returned.
Expected parameters include:
=over
=item C<displayIndex> - the index of the display to query
=item C<mode> - an L<SDL2::DisplayMode> structure containing the desired display mode
=item C<closest> - an L<SDL2::DisplayMode> structure filled in with the closest match of the available display modes
=back
Returns the passed in value C<closest> or C<undef> if no matching video mode
was available; call C<SDL_GetError( )> for more information.
=head2 C<SDL_GetWindowDisplayIndex( ... )>
Get the index of the display associated with a window.
Expected parameters include:
=over
=item C<window> - the window to query
=back
Returns the index of the display containing the center of the window on success
or a negative error code on failure; call C<SDL_GetError( )> for more
information.
=head2 C<SDL_SetWindowDisplayMode( ... )>
Set the display mode to use when a window is visible at fullscreen.
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().
Expected parameters include:
=over
=item C<window> - the window to affect
=item C<mode> - the L<SDL2::DisplayMode> structure representing the mode to use, or C<undef> to use the window's dimensions and the desktop's format and refresh rate
=back
Returns C<0> on success or a negative error code on failure; call
C<SDL_GetError( )> for more information.
=head2 C<SDL_GetWindowDisplayMode( ... )>
Query the display mode to use when a window is visible at fullscreen.
Expected parameters include:
=over
=item C<window> - the window to query
=item C<mode> - an L<SDL2::DisplayMode> structure filled in with the fullscreen display mode
=back
Returns C<0> on success or a negative error code on failure; call
C<SDL_GetError( )> for more information.
=head2 C<SDL_GetWindowPixelFormat( ... )>
Get the pixel format associated with the window.
Expected parameters include:
=over
=item C<window> - the window to query
=back
Returns the pixel format of the window on success or C<SDL_PIXELFORMAT_UNKNOWN>
on failure; call C<SDL_GetError( )> for more information.
=head2 C<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
);
C<flags> may be any of the following OR'd together:
=over
=item C<SDL_WINDOW_FULLSCREEN> - fullscreen window
=item C<SDL_WINDOW_FULLSCREEN_DESKTOP> - fullscreen window at desktop resolution
=item C<SDL_WINDOW_OPENGL> - window usable with an OpenGL context
=item C<SDL_WINDOW_VULKAN> - window usable with a Vulkan instance
=item C<SDL_WINDOW_METAL> - window usable with a Metal instance
=item C<SDL_WINDOW_HIDDEN> - window is not visible
=item C<SDL_WINDOW_BORDERLESS> - no window decoration
=item C<SDL_WINDOW_RESIZABLE> - window can be resized
=item C<SDL_WINDOW_MINIMIZED> - window is minimized
=item C<SDL_WINDOW_MAXIMIZED> - window is maximized
=item C<SDL_WINDOW_INPUT_GRABBED> - window has grabbed input focus
=item C<SDL_WINDOW_ALLOW_HIGHDPI> - window should be created in high-DPI mode if supported (>= SDL 2.0.1)
=back
C<SDL_WINDOW_SHOWN> is ignored by C<SDL_CreateWindow( )>. The SDL_Window is
implicitly shown if C<SDL_WINDOW_HIDDEN> is not set. C<SDL_WINDOW_SHOWN> may be
queried later using L<< C<SDL_GetWindowFlags( ... )>|/C<SDL_GetWindowFlags( ...
)> >>.
On Apple's macOS, you B<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 C<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 L<< C<SDL_GetWindowSize( ...
)>|/C<SDL_GetWindowSize( ... )> >> to query the client area's size in screen
coordinates, and L<< C<SDL_GL_GetDrawableSize( ...
)>|/C<SDL_GL_GetDrawableSize( ... )> >> or C<SDL_GetRendererOutputSize( ... )>
to query the drawable size in pixels.
If the window is set fullscreen, the width and height parameters C<w> and C<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
C<SDL_WINDOW_VULKAN> flags, then the corresponding LoadLibrary function (L<<
C<SDL_GL_LoadLibrary( ... )>|/C<SDL_GL_LoadLibrary( ... )> >> or
C<SDL_Vulkan_LoadLibrary( ... )>) is called and the corresponding
C<UnloadLibrary> function is called by L<< C<SDL_DestroyWindow( ...
)>|/C<SDL_DestroyWindow( ... )> >>.
If C<SDL_WINDOW_VULKAN> is specified and there isn't a working Vulkan driver,
C<SDL_CreateWindow( ... )> will fail because C<SDL_Vulkan_LoadLibrary( ... )>
will fail.
If C<SDL_WINDOW_METAL> is specified on an OS that does not support Metal,
C<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
lib/SDL2/video.pm view on Meta::CPAN
=over
=item C<window> - the window to hide
=back
=head2 C<SDL_RaiseWindow( ... )>
Raise a window above other windows and set the input focus.
Expected parameters include:
=over
=item C<window> - the window to raise
=back
=head2 C<SDL_MaximizeWindow( ... )>
Make a window as large as possible.
Expected parameters include:
=over
=item C<window> - the window to maximize
=back
=head2 C<SDL_MinimizeWindow( ... )>
Minimize a window to an iconic representation.
Expected parameters include:
=over
=item C<window> - the window to minimize
=back
=head2 C<SDL_RestoreWindow( ... )>
Restore the size and position of a minimized or maximized window.
Expected parameters include:
=over
=item C<window> - the window to restore
=back
=head2 C<SDL_SetWindowFullscreen( ... )>
Set a window's fullscreen state.
C<flags> may be C<SDL_WINDOW_FULLSCREEN>, for "real" fullscreen with a
videomode change; C<SDL_WINDOW_FULLSCREEN_DESKTOP> for "fake" fullscreen that
takes the size of the desktop; and 0 for windowed mode.
Expected parameters include:
=over
=item C<window> - the window to change
=item C<flags> - C<SDL_WINDOW_FULLSCREEN>, C<SDL_WINDOW_FULLSCREEN_DESKTOP> or C<0>
=back
Returns C<0> on success or a negative error code on failure; call
C<SDL_GetError( )> for more information.
=head2 C<SDL_GetWindowSurface( ... )>
Get the SDL surface associated with the 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 C<SDL_HINT_FRAMEBUFFER_ACCELERATION>.
Expected parameters include:
=over
=item C<window> - the window to query
=back
Returns the surface associated with the window, or NULL on failure; call
C<SDL_GetError( )> for more information.
=head2 C<SDL_UpdateWindowSurface( ... )>
Copy the window surface to the screen.
This is the function you use to reflect any changes to the surface on the
screen.
Expected parameters include:
=over
=item C<window> - the window to update
=back
Returns C<0> on success or a negative error code on failure; call
C<SDL_GetError( )> for more information.
=head2 C<SDL_UpdateWindowSurfaceRects( ... )>
( run in 2.040 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )