native_darwin.go (1048B)
1 package glfw 2 3 /* 4 #define GLFW_EXPOSE_NATIVE_COCOA 5 #define GLFW_EXPOSE_NATIVE_NSGL 6 #include "glfw/include/GLFW/glfw3.h" 7 #include "glfw/include/GLFW/glfw3native.h" 8 9 // workaround wrappers needed due to a cgo and/or LLVM bug. 10 // See: https://github.com/go-gl/glfw/issues/136 11 void *workaround_glfwGetCocoaWindow(GLFWwindow *w) { 12 return (void *)glfwGetCocoaWindow(w); 13 } 14 void *workaround_glfwGetNSGLContext(GLFWwindow *w) { 15 return (void *)glfwGetNSGLContext(w); 16 } 17 */ 18 import "C" 19 import "unsafe" 20 21 // GetCocoaMonitor returns the CGDirectDisplayID of the monitor. 22 func (m *Monitor) GetCocoaMonitor() uintptr { 23 ret := uintptr(C.glfwGetCocoaMonitor(m.data)) 24 panicError() 25 return ret 26 } 27 28 // GetCocoaWindow returns the NSWindow of the window. 29 func (w *Window) GetCocoaWindow() unsafe.Pointer { 30 ret := C.workaround_glfwGetCocoaWindow(w.data) 31 panicError() 32 return ret 33 } 34 35 // GetNSGLContext returns the NSOpenGLContext of the window. 36 func (w *Window) GetNSGLContext() unsafe.Pointer { 37 ret := C.workaround_glfwGetNSGLContext(w.data) 38 panicError() 39 return ret 40 }