The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

SDL2::shape - Functions for the Shaped Window API

SYNOPSIS

    use SDL2 qw[:shape];

DESCRIPTION

SDL2::shape exposes functions which allow you to create windows with custom shapes.

Functions

These functions may be imported by name or with the :shape tag.

SDL_CreateShapedWindow( ... )

Create a window that can be shaped with the specified position, dimensions, and flags.

Expected parameters include:

title - The title of the window, in UTF-8 encoding
x - The x position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED
y - The y position of the window, SDL_WINDOWPOS_CENTERED, or DL_WINDOWPOS_UNDEFINED.
w - The width of the window.
h - The height of the window.
flags

The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: SDL_WINDOW_OPENGL, SDL_WINDOW_INPUT_GRABBED, DL_WINDOW_HIDDEN, SDL_WINDOW_RESIZABLE, SDL_WINDOW_MAXIMIZED, SDL_WINDOW_MINIMIZED.

SDL_WINDOW_BORDERLESS is always set, and SDL_WINDOW_FULLSCREEN is always unset.

Returns the window created, or undef if window creation failed.

SDL_IsShapedWindow( ... )

Return whether the given window is a shaped window.

Expected parameters include:

window - the window to query for being shaped

Returns SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or undef.

SDL_SetWindowShape( ... )

Set the shape and parameters of a shaped window.

Expected parameters include:

window - the shaped window whose parameters should be set
shape - a surface encoding the desired shape for the window
shape_mode - the parameters to set for the shaped window

Returns 0 on success, SDL_INVALID_SHAPE_ARGUMENT on an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW if the SDL2::Window given does not reference a valid shaped window.

SDL_GetShapedWindowMode( ... )

Get the shape parameters of a shaped window.

Expected parameters include:

window - the shaped window whose parameters should be retrieved
shape_mode - an empty shape-mode structure to fill, or undef to check whether the window has a shape

Returns 0 if the window has a shape and, provided shape_mode was not undef, shape_mode has been filled with the mode data, SDL_NONSHAPEABLE_WINDOW if the SDL2::Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if the SDL2::Window given is a shapeable window currently lacking a shape.

Defined Variables and Enumerations

Variables may be imported by name or with the :shape tag.

SDL_NONSHAPEABLE_WINDOW
SDL_INVALID_SHAPE_ARGUMENT
SDL_WINDOW_LACKS_SHAPE

WindowShapeMode

An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. These may be imported with the :windowShapeMode tag.

ShapeModeDefault - The default mode, a binarized alpha cutoff of 1
ShapeModeBinarizeAlpha - A binarized alpha cutoff with a given integer value
ShapeModeReverseBinarizeAlpha - A binarized alpha cutoff with a given integer value, but with the opposite comparison
ShapeModeColorKey - A color key is applied.

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>