first commit
This commit is contained in:
10
rendering_api/metal/src/bridge/info.txt
Normal file
10
rendering_api/metal/src/bridge/info.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
(this file is because I have zero god damn clue what is going on)
|
||||
|
||||
UHHHHHHH I FUCKING HATE APPLE WHY DO I HAVE TO WRITE OBJECTIVE C JUST SO THAT I CAN OPEN A WINDOW
|
||||
AND THAN DRAW SHIT TO IT WHY DONT YOU JUST LET ME DO ALL THIS SHIT IN PLAIN C LIKE ANY OTHER
|
||||
OPERATING SYSTEM EVEN FUCKING MICROSOFT LETS ME DO THIS SHIT IN C YOU ARE A BITCH APPLE
|
||||
NO ONE IN THERE LIFE HAS EVER WANTED TO WRITE OBJECTIVE C BECAUSE IT IS THE BIGGEST
|
||||
PEICE OF SHIT OF ALL TIME BUT THIS IS THE LITTLE OBJECTIVE C THAT I NEEDED TO WRITE TO GET
|
||||
ALL OF THIS TO WORK.
|
||||
|
||||
(please disregard this file this is just for when I forget how this project works and I want to remember why there is objective-c in here)
|
55
rendering_api/metal/src/bridge/metal_bridege.mm
Normal file
55
rendering_api/metal/src/bridge/metal_bridege.mm
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "metal_bridge.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <QuartzCore/CAMetalLayer.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import <Metal/Metal.h>
|
||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <GLFW/glfw3native.h>
|
||||
|
||||
void mtlObjectCSetContentViewsLayer(void* window, void* layer) {
|
||||
[CATransaction begin];
|
||||
[CATransaction setDisableActions:YES];
|
||||
|
||||
NSWindow* nsWindow = (NSWindow*)glfwGetCocoaWindow((GLFWwindow*)window);
|
||||
NSView* contentView = [nsWindow contentView];
|
||||
|
||||
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;
|
||||
}
|
5
rendering_api/metal/src/bridge/metal_bridge.h
Normal file
5
rendering_api/metal/src/bridge/metal_bridge.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
void mtlObjectCSetContentViewsLayer(void* window, void* layer);
|
||||
void* mtlCreateContentView(void* targetWindow);
|
||||
void mtlInitializeMetalLayer(void* layer, bool vsync);
|
Reference in New Issue
Block a user