remove all objective c++
This commit is contained in:
29
rendering_api/metal/src/bridge/metal_bridege.m
Normal file
29
rendering_api/metal/src/bridge/metal_bridege.m
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "metal_bridge.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <QuartzCore/CAMetalLayer.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import <Metal/Metal.h>
|
||||
|
||||
void mtlObjectCSetContentViewsLayer(void* view, void* layer) {
|
||||
[CATransaction begin];
|
||||
[CATransaction setDisableActions:YES];
|
||||
|
||||
NSView* contentView = (__bridge NSView*)view;
|
||||
|
||||
CAMetalLayer* metalLayer = (__bridge CAMetalLayer*)layer;
|
||||
|
||||
[contentView setWantsLayer:YES];
|
||||
[contentView setLayer:metalLayer];
|
||||
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
void mtlInitializeMetalLayer(void* layer, gnBool vsync) {
|
||||
CAMetalLayer* metalLayer = (__bridge CAMetalLayer*)layer;
|
||||
metalLayer.maximumDrawableCount = 3;
|
||||
if (vsync == gnTrue)
|
||||
metalLayer.displaySyncEnabled = true;
|
||||
else
|
||||
metalLayer.displaySyncEnabled = false;
|
||||
metalLayer.framebufferOnly = true;
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
#include "metal_bridge.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <QuartzCore/CAMetalLayer.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import <Metal/Metal.h>
|
||||
|
||||
void mtlObjectCSetContentViewsLayer(void* view, void* layer) {
|
||||
[CATransaction begin];
|
||||
[CATransaction setDisableActions:YES];
|
||||
|
||||
NSView* contentView = (__bridge NSView*)view;
|
||||
|
||||
CAMetalLayer* metalLayer = (__bridge CAMetalLayer*)layer;
|
||||
|
||||
[contentView setWantsLayer:YES];
|
||||
[contentView setLayer:metalLayer];
|
||||
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
// void* mtlCreateContentView(void* targetWindow) {
|
||||
// NSWindow* window = (__bridge NSWindow*)targetWindow;
|
||||
// NSRect frame = [[window contentView] frame]; // fallback size
|
||||
// NSView* contentView = [[NSView alloc] initWithFrame:frame];
|
||||
// [window setContentView:contentView];
|
||||
|
||||
// if (contentView == nullptr)
|
||||
// frame = NSMakeRect(0, 0, window.frame.size.width, window.frame.size.height);
|
||||
|
||||
// return contentView;
|
||||
// }
|
||||
|
||||
// void* mtlInitContentView(void* targetView) {
|
||||
// NSView* view = (__bridge NSView*)targetView;
|
||||
|
||||
// CAMetalLayer* metalLayer = [CAMetalLayer layer];
|
||||
// // metalLayer.device = metalDevice;
|
||||
// metalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
||||
// metalLayer.contentsScale = [view.window backingScaleFactor];
|
||||
// metalLayer.framebufferOnly = YES;
|
||||
// view.layer = metalLayer;
|
||||
// view.wantsLayer = YES;
|
||||
// return metalLayer;
|
||||
// }
|
||||
|
||||
void mtlInitializeMetalLayer(void* layer, bool vsync) {
|
||||
CAMetalLayer* metalLayer = (__bridge CAMetalLayer*)layer;
|
||||
metalLayer.maximumDrawableCount = 3;
|
||||
metalLayer.displaySyncEnabled = vsync;
|
||||
metalLayer.framebufferOnly = true;
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "gryphn/gryphn_utils.h"
|
||||
|
||||
void mtlObjectCSetContentViewsLayer(void* view, void* layer);
|
||||
// void* mtlCreateContentView(void* targetView);
|
||||
void mtlInitializeMetalLayer(void* layer, bool vsync);
|
||||
void mtlInitializeMetalLayer(void* layer, gnBool vsync);
|
||||
|
Reference in New Issue
Block a user