SDL  2.0
SDL_metal.h File Reference
#include "SDL_video.h"
#include "begin_code.h"
#include "close_code.h"
+ Include dependency graph for SDL_metal.h:
+ This graph shows which files directly or indirectly include this file:

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
SDL_MetalView SDL_Metal_CreateView (SDL_Window *window)
 Create a CAMetalLayer-backed NSView/UIView and attach it to the specified window. More...
 
void 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()

SDL_MetalView 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.

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

Definition at line 4218 of file SDL_video.c.

4219 {
4221 
4222  if (_this->Metal_CreateView) {
4223  return _this->Metal_CreateView(_this, window);
4224  } else {
4225  SDL_SetError("Metal is not supported.");
4226  return NULL;
4227  }
4228 }

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::Metal_CreateView, NULL, and SDL_SetError.

◆ SDL_Metal_DestroyView()

void 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

Definition at line 4231 of file SDL_video.c.

4232 {
4233  if (_this && view && _this->Metal_DestroyView) {
4234  _this->Metal_DestroyView(_this, view);
4235  }
4236 }

References _this, and SDL_VideoDevice::Metal_DestroyView.

SDL_VideoDevice::Metal_DestroyView
void(* Metal_DestroyView)(_THIS, SDL_MetalView view)
Definition: SDL_sysvideo.h:283
NULL
#define NULL
Definition: begin_code.h:167
SDL_Metal_DestroyView
#define SDL_Metal_DestroyView
Definition: SDL_dynapi_overrides.h:728
SDL_MetalView
void * SDL_MetalView
A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS).
Definition: SDL_metal.h:44
_this
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_VideoDevice::Metal_CreateView
SDL_MetalView(* Metal_CreateView)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:282
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_Metal_CreateView
#define SDL_Metal_CreateView
Definition: SDL_dynapi_overrides.h:727
CHECK_WINDOW_MAGIC
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123