arsa  2.7
Typedefs
SDL_metal.h File Reference
#include "SDL_video.h"
#include "begin_code.h"
#include "close_code.h"

Go to the source code of this file.

Typedefs

typedef voidSDL_MetalView
 A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS). More...
 

Functions

Metal support functions
DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView (SDL_Window *window)
 Create a CAMetalLayer-backed NSView/UIView and attach it to the specified window. More...
 
DECLSPEC void SDLCALL SDL_Metal_DestroyView (SDL_MetalView view)
 Destroy an existing SDL_MetalView object. More...
 

Detailed Description

Header file for functions to creating Metal layers and views on SDL windows.

Definition in file SDL_metal.h.

Typedef Documentation

◆ SDL_MetalView

typedef void* SDL_MetalView

A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS).

Note
This can be cast directly to an NSView or UIView.

Definition at line 44 of file SDL_metal.h.

Function Documentation

◆ SDL_Metal_CreateView()

DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView ( SDL_Window window)

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, and the CAMetalLayer can be accessed from the view's 'layer' property.

SDL_MetalView metalview = SDL_Metal_CreateView(window);
UIView *uiview = (__bridge UIView *)metalview;
CAMetalLayer *metallayer = (CAMetalLayer *)uiview.layer;
// [...]
See also
SDL_Metal_DestroyView

◆ SDL_Metal_DestroyView()

DECLSPEC void SDLCALL SDL_Metal_DestroyView ( SDL_MetalView  view)

Destroy an existing SDL_MetalView object.

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

See also
SDL_Metal_CreateView