metal.nim
Header file for procedures to creating Metal layers and views on SDL windows.
Procs
proc metalCreateView*(window: Window): MetalView {...}{.cdecl, importc: "SDL_Metal_CreateView", dynlib: SDL2_LIB.}
-
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.metalGetLayer().
Note: window must be created with the sdl.WINDOW_METAL flag.
See also:
metalDestroyView()
metalGetLayer()
proc metalDestroyView*(view: MetalView) {...}{.cdecl, importc: "SDL_Metal_DestroyView", dynlib: SDL2_LIB.}
-
Destroy an existing MetalView object.
This should be called before destroyWindow(), if metalCreateView() was called after createWindow().
See also:
metalCreateView()
proc metalGetLayer*(view: MetalView): pointer {...}{.cdecl, importc: "SDL_Metal_GetLayer", dynlib: SDL2_LIB.}
-
Get a pointer to the backing CAMetalLayer for the given view.
See also:
metalCreateView()
proc metalGetDrawableSize*(window: Window; w, h: ptr cint) {...}{.cdecl, importc: "SDL_Metal_GetDrawableSize", dynlib: SDL2_LIB.}
-
Get the size of a window's underlying drawable in pixels (for use with setting viewport, scissor & etc).
window sdl.Window from which the drawable size should be queried
w Pointer to variable for storing the width in pixels, may be nil
h Pointer to variable for storing the height in pixels, may be nil
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:
getWindowSize()
createWindow()