1 /*
2     DSDL
3     Copyright (C) 2025 Inochi2D Project <luna@foxgirls.gay>
4 
5     This software is provided 'as-is', without any express or implied
6     warranty.  In no event will the authors be held liable for any damages
7     arising from the use of this software.
8 
9     Permission is granted to anyone to use this software for any purpose,
10     including commercial applications, and to alter it and redistribute it
11     freely, subject to the following restrictions:
12 
13     1. The origin of this software must not be misrepresented; you must not
14         claim that you wrote the original software. If you use this software
15         in a product, an acknowledgment in the product documentation would be
16         appreciated but is not required.
17     2. Altered source versions must be plainly marked as such, and must not be
18         misrepresented as being the original software.
19     3. This notice may not be removed or altered from any source distribution.
20 
21     ==========================================================================
22 
23     Simple DirectMedia Layer
24     Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
25 
26     This software is provided 'as-is', without any express or implied
27     warranty.  In no event will the authors be held liable for any damages
28     arising from the use of this software.
29 
30     Permission is granted to anyone to use this software for any purpose,
31     including commercial applications, and to alter it and redistribute it
32     freely, subject to the following restrictions:
33 
34     1. The origin of this software must not be misrepresented; you must not
35         claim that you wrote the original software. If you use this software
36         in a product, an acknowledgment in the product documentation would be
37         appreciated but is not required.
38     2. Altered source versions must be plainly marked as such, and must not be
39         misrepresented as being the original software.
40     3. This notice may not be removed or altered from any source distribution.
41 */
42 
43 /**
44     Metal Interface
45 
46     See_Also:
47         $(LINK2 https://wiki.libsdl.org/SDL3/CategoryMetal, SDL3 Metal Documentation)
48     
49     Copyright: © 2025 Inochi2D Project, © 1997-2025 Sam Lantinga
50     License: Subject to the terms of the Zlib License, as written in the LICENSE file.
51     Authors: 
52         Luna Nielsen
53 */
54 module sdl.metal;
55 import sdl.d;
56 import sdl.stdc;
57 import sdl.video;
58 
59 extern(C) nothrow @nogc:
60 
61 /**
62     A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS).
63 */
64 alias SDL_MetalView = OpaqueHandle!("SDL_MetalView");
65 
66 /**
67     A handle to a CAMetalLayer.
68 */
69 alias SDL_MetalLayer = OpaqueHandle!("SDL_MetalLayer");
70 
71 /**
72     Create a CAMetalLayer-backed NSView/UIView and attach it to the specified
73     window.
74 
75     On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on
76     its own. It is up to user code to do that.
77 
78     The returned handle can be casted directly to a NSView or UIView. To access
79     the backing CAMetalLayer, call $(D SDL_Metal_GetLayer).
80 
81     Params:
82         window = the window
83     
84     Returns:
85         NSView or UIView handle.
86 
87     See_Also:
88         $(D SDL_Metal_DestroyView)
89         $(D SDL_Metal_GetLayer)
90 */
91 extern SDL_MetalView SDL_Metal_CreateView(SDL_Window* window);
92 
93 /**
94     Destroy an existing SDL_MetalView object.
95 
96     This should be called before $(D SDL_DestroyWindow), 
97     if $(D SDL_Metal_CreateView) was called after $(D SDL_CreateWindow).
98 
99     Params:
100         view = the SDL_MetalView object.
101 
102     See_Also:
103         $(D SDL_Metal_CreateView)
104 */
105 extern void SDL_Metal_DestroyView(SDL_MetalView view);
106 
107 /**
108     Get a pointer to the backing CAMetalLayer for the given view.
109     
110     Params:
111         view = the $(D SDL_MetalView) object.
112     
113     Returns:
114         a CAMetalLayer handle.
115 
116     See_Also:
117         $(D SDL_Metal_CreateView)
118 */
119 extern SDL_MetalLayer SDL_Metal_GetLayer(SDL_MetalView view);