2020-01-04 01:24:52 +00:00
|
|
|
#import "metal/4ed_metal_render.mm"
|
|
|
|
|
2020-01-05 01:13:47 +00:00
|
|
|
global Metal_Renderer metal_renderer;
|
2020-01-04 01:24:52 +00:00
|
|
|
global MTKView *metal_view;
|
|
|
|
|
|
|
|
function void
|
|
|
|
mac_metal_init(NSWindow *window){
|
|
|
|
// NOTE(yuval): Create Metal view
|
|
|
|
NSView *content_view = [window contentView];
|
|
|
|
|
|
|
|
metal_view = [[MTKView alloc] initWithFrame:[content_view bounds]];
|
|
|
|
[metal_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
|
|
|
|
|
|
|
metal_view.device = MTLCreateSystemDefaultDevice();
|
|
|
|
|
|
|
|
// NOTE(yuval): Add the Metal view as a subview of the window
|
|
|
|
[content_view addSubview:metal_view];
|
|
|
|
|
|
|
|
// NOTE(yuval): Create the Metal renderer
|
2020-01-05 01:13:47 +00:00
|
|
|
//metal_renderer = [[FCoderMetalRenderer alloc] initWithMetalKitView:metal_view];
|
|
|
|
metal_init(&metal_renderer, metal_view);
|
2020-01-04 01:24:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function void
|
|
|
|
mac_metal_render(Render_Target* target){
|
|
|
|
u64 begin_time = system_now_time();
|
2020-01-05 01:13:47 +00:00
|
|
|
//[metal_renderer drawInMTKView:metal_view];
|
|
|
|
metal_render(&metal_renderer, target);
|
2020-01-04 01:24:52 +00:00
|
|
|
u64 end_time = system_now_time();
|
|
|
|
printf("Metal Render Time: %fs\n\n", mac_get_time_diff_sec(begin_time, end_time));
|
|
|
|
}
|