My Project
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 void * SDL_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...
 
DECLSPEC void *SDLCALL SDL_Metal_GetLayer (SDL_MetalView view)
 Get a pointer to the backing CAMetalLayer for the given view. More...
 
DECLSPEC void SDLCALL SDL_Metal_GetDrawableSize (SDL_Window *window, int *w, int *h)
 Get the size of a window's underlying drawable in pixels (for use with setting viewport, scissor & etc). More...
 

Detailed Description

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

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.

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. To access the backing CAMetalLayer, call SDL_Metal_GetLayer().

Note
window must be created with the SDL_WINDOW_METAL flag.
See also
SDL_Metal_DestroyView
SDL_Metal_GetLayer

◆ 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

◆ SDL_Metal_GetDrawableSize()

DECLSPEC void SDLCALL SDL_Metal_GetDrawableSize ( SDL_Window window,
int *  w,
int *  h 
)

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

Parameters
windowSDL_Window from which the drawable size should be queried
wPointer to variable for storing the width in pixels, may be NULL
hPointer to variable for storing the height in pixels, may be NULL

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.
See also
SDL_GetWindowSize()
SDL_CreateWindow()

◆ SDL_Metal_GetLayer()

DECLSPEC void* SDLCALL SDL_Metal_GetLayer ( SDL_MetalView  view)

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

See also
SDL_MetalCreateView