// objc++ only. appkit lives here.
#include <math.h>
#ifndef INFINITY
#define INFINITY __builtin_huge_valf()
#endif
#ifndef FLT_MAX
#define FLT_MAX __FLT_MAX__
#endif
#ifndef DBL_MAX
#define DBL_MAX __DBL_MAX__
#endif
#include <AppKit/AppKit.h>
#include <QuartzCore/CAMetalLayer.h>
#define GLFW_EXPOSE_NATIVE_COCOA
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
#include <Foundation/Foundation.hpp>
#include <Metal/Metal.hpp>
#include <QuartzCore/QuartzCore.hpp>
#include "backend/metal/mt_internal.h"
namespace mt {
CA::MetalLayer *mt_attach_metal_layer(void *glfw_window, MTL::Device *device) {
NSView *view = glfwGetCocoaView(static_cast<GLFWwindow *>(glfw_window));
CA::MetalLayer *layer = CA::MetalLayer::layer();
layer->setDevice(device);
// caller frees.
layer->retain();
CAMetalLayer *objc_layer = (__bridge CAMetalLayer *)layer;
view.wantsLayer = YES;
view.layer = objc_layer;
return layer;
}
} // namespace mt