SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Metal Support

Functions to creating Metal layers and views on SDL windows. More...

Classes

struct  SDL::MetalView
 A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS). More...

Typedefs

using SDL::MetalViewRaw = SDL_MetalView
 Alias to raw representation for MetalView.
using SDL::MetalViewRef = ResourceRef<MetalView>
 Reference for MetalView.

Functions

MetalView SDL::Metal_CreateView (WindowRef window)
 Create a CAMetalLayer-backed NSView/UIView and attach it to the specified window.
void SDL::Metal_DestroyView (MetalViewRaw view)
 Destroy an existing MetalView object.
void * SDL::Metal_GetLayer (MetalViewRef view)
 Get a pointer to the backing CAMetalLayer for the given view.
 SDL::MetalView::MetalView (WindowRef window)
 Create a CAMetalLayer-backed NSView/UIView and attach it to the specified window.
void SDL::MetalView::Destroy ()
 Destroy an existing MetalView object.
void * SDL::MetalView::GetLayer ()
 Get a pointer to the backing CAMetalLayer for the given view.

Detailed Description

Functions to creating Metal layers and views on SDL windows.

This provides some platform-specific glue for Apple platforms. Most macOS and iOS apps can use SDL without these functions, but this API they can be useful for specific OS-level integration tasks.

Typedef Documentation

◆ MetalViewRef

Reference for MetalView.

This does not take ownership!

Function Documentation

◆ Destroy()

void SDL::MetalView::Destroy ( )
inline

Destroy an existing MetalView object.

This should be called before Window.Destroy, if Metal_CreateView was called after CreateWindow.

Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Metal_CreateView

◆ GetLayer()

void * SDL::MetalView::GetLayer ( )
inline

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

Returns
a pointer.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ Metal_CreateView()

MetalView SDL::Metal_CreateView ( WindowRef window)
inline

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.

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

Parameters
windowthe window.
Returns
handle NSView or UIView.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
MetalView.Destroy
MetalView.GetLayer

◆ Metal_DestroyView()

void SDL::Metal_DestroyView ( MetalViewRaw view)
inline

Destroy an existing MetalView object.

This should be called before Window.Destroy, if Metal_CreateView was called after CreateWindow.

Parameters
viewthe MetalView object.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Metal_CreateView

◆ Metal_GetLayer()

void * SDL::Metal_GetLayer ( MetalViewRef view)
inline

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

Parameters
viewthe MetalView object.
Returns
a pointer.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ MetalView()

SDL::MetalView::MetalView ( WindowRef window)
inline

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.

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

Parameters
windowthe window.
Postcondition
handle NSView or UIView.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
MetalView.Destroy
MetalView.GetLayer