native_darwin.go 1.0 KB

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