30 #if SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_RENDER_METAL)
34 @implementation SDL_cocoametalview
39 return NSClassFromString(
@"CAMetalLayer");
43 - (BOOL)wantsUpdateLayer
51 - (CALayer*)makeBackingLayer
53 return [
self.class.layerClass layer];
56 - (instancetype)initWithFrame:(NSRect)frame
59 if ((
self = [super initWithFrame:
frame])) {
60 self.highDPI = highDPI;
61 self.wantsLayer = YES;
64 self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
66 [
self updateDrawableSize];
77 - (
void)updateDrawableSize
79 CAMetalLayer *metalLayer = (CAMetalLayer *)
self.
layer;
80 CGSize
size =
self.bounds.size;
81 CGSize backingSize =
size;
87 backingSize = [
self convertSizeToBacking:size];
90 metalLayer.contentsScale = backingSize.height /
size.height;
91 metalLayer.drawableSize = backingSize;
95 - (
void)resizeWithOldSuperviewSize:(NSSize)oldSize
97 [
super resizeWithOldSuperviewSize:oldSize];
98 [
self updateDrawableSize];
107 NSView *view = data->
nswindow.contentView;
109 SDL_cocoametalview *metalview;
111 metalview = [[SDL_cocoametalview alloc] initWithFrame:view.frame highDPI:highDPI];
112 [view addSubview:metalview];
120 NSView *view = data->
nswindow.contentView;
121 SDL_cocoametalview* metalview = [view viewWithTag:METALVIEW_TAG];
123 CAMetalLayer *
layer = (CAMetalLayer*)metalview.layer;
126 *w = layer.drawableSize.width;
129 *h = layer.drawableSize.height;
GLfloat GLfloat GLfloat GLfloat h
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLuint GLint GLint layer
#define SDL_GetWindowSize
GLubyte GLubyte GLubyte GLubyte w
EGLSurface EGLNativeWindowType * window
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
The type used to identify a window.