2023-08-03 16:51:17 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2023-07-07 19:15:47 +02:00
|
|
|
// SPDX-FileCopyrightText: 2012 The glfw3-go Authors
|
|
|
|
// SPDX-FileCopyrightText: 2023 The Ebitengine Authors
|
|
|
|
|
2023-07-21 18:02:55 +02:00
|
|
|
package cglfw
|
2023-07-05 03:51:55 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
#define GLFW_EXPOSE_NATIVE_COCOA
|
|
|
|
#define GLFW_EXPOSE_NATIVE_NSGL
|
2023-07-10 16:29:25 +02:00
|
|
|
#include "glfw3.h"
|
|
|
|
#include "glfw3native.h"
|
2023-07-05 03:51:55 +02:00
|
|
|
|
|
|
|
// workaround wrappers needed due to a cgo and/or LLVM bug.
|
|
|
|
// See: https://github.com/go-gl/glfw/issues/136
|
2023-07-07 17:37:20 +02:00
|
|
|
static void *workaround_glfwGetCocoaWindow(GLFWwindow *w) {
|
2023-07-05 03:51:55 +02:00
|
|
|
return (void *)glfwGetCocoaWindow(w);
|
|
|
|
}
|
2023-07-07 17:37:20 +02:00
|
|
|
static void *workaround_glfwGetNSGLContext(GLFWwindow *w) {
|
2023-07-05 03:51:55 +02:00
|
|
|
return (void *)glfwGetNSGLContext(w);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
import "unsafe"
|
|
|
|
|
|
|
|
// GetCocoaMonitor returns the CGDirectDisplayID of the monitor.
|
|
|
|
func (m *Monitor) GetCocoaMonitor() uintptr {
|
|
|
|
ret := uintptr(C.glfwGetCocoaMonitor(m.data))
|
|
|
|
panicError()
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetCocoaWindow returns the NSWindow of the window.
|
|
|
|
func (w *Window) GetCocoaWindow() unsafe.Pointer {
|
|
|
|
ret := C.workaround_glfwGetCocoaWindow(w.data)
|
|
|
|
panicError()
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetNSGLContext returns the NSOpenGLContext of the window.
|
|
|
|
func (w *Window) GetNSGLContext() unsafe.Pointer {
|
|
|
|
ret := C.workaround_glfwGetNSGLContext(w.data)
|
|
|
|
panicError()
|
|
|
|
return ret
|
|
|
|
}
|