NAME

SDL2::metal - Metal Laysers and Views on SDL Windows

SYNOPSIS

use SDL2 qw[:metal];

DESCRIPTION

This package contains functions to creating Metal layers and views on SDL windows.

Functions

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

SDL_Metal_CreateView( ... )

Create a CAMetalLayer-backed NSView/UIView and attach it to the specified window.

On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on its own. It is up to user code to do that.

Expected parameters include:

window - SDL2::Window from which the drawable size should be queried

The returned handle can be cast directly to a NSView or UIView. To access the backing CAMetalLayer, call SDL_Metal_GetLayer( ... ).

Note: window must be created with the SDL_WINDOW_METAL flag.

SDL_Metal_DestroyView( ... )

Destroy an existing SDL2::MetalView object.

This should be called before SDL_DestroyWindow( ... ), if SDL_Metal_CreateView( ... ) was called after SDL_CreateWindow( ... ).

Expected parameters include:

view - SDL2::MetalView to destroy

SDL_Metal_GetLayer( ... )

Get a pointer to the backing CAMetalLayer for the given view.

Expected parameters include:

view - SDL2::MetalView to query

Returns an opaque pointer.

SDL_Metal_GetDrawableSize( ... )

Get the size of a window's underlying drawable in pixels (for use with setting viewport, scissor & etc).

Expected parameters include:

window - SDL2::Window from which the drawable size should be queried
w - pointer to variable for storing the width in pixels, may be undef
h - Pointer to variable for storing the height in pixels, may be <undef>

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.

Note: On macOS high-DPI support must be enabled for an application by setting NSHighResolutionCapable to true in its Info.plist.

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>