yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Simon Kallweit[gfx] metal backend skeleton (#4223)d9443d670

master
897 B39 linesraw
1#include "cocoa-util.h"
2
3#import <Cocoa/Cocoa.h>
4#import <QuartzCore/CAMetalLayer.h>
5
6namespace gfx {
7
8void CocoaUtil::getNSWindowContentSize(void* nswindow, int* widthOut, int* heightOut)
9{
10    NSWindow* window = (NSWindow*)nswindow;
11    const NSRect contentRect = [window.contentView frame];
12    *widthOut = contentRect.size.width;
13    *heightOut = contentRect.size.height;
14}
15
16void* CocoaUtil::createMetalLayer(void* nswindow)
17{
18    CAMetalLayer *layer = [CAMetalLayer layer];
19    NSWindow* window = (NSWindow*)nswindow;
20    window.contentView.layer = layer;
21    window.contentView.wantsLayer = YES;
22    return layer;
23}
24
25void* CocoaUtil::nextDrawable(void* metalLayer)
26{
27    CAMetalLayer* layer = (CAMetalLayer*)metalLayer;
28    return [layer nextDrawable];
29}
30
31void CocoaUtil::destroyMetalLayer(void* metalLayer)
32{
33    CAMetalLayer* layer = (CAMetalLayer*)metalLayer;
34    [layer release];
35}
36
37
38
39}