procaddr.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Code generated by glow (https://github.com/go-gl/glow). DO NOT EDIT.
  2. // This file implements GlowGetProcAddress for every supported platform. The
  3. // correct version is chosen automatically based on build tags:
  4. //
  5. // windows: WGL
  6. // darwin: CGL
  7. // linux freebsd netbsd openbsd: GLX
  8. //
  9. // Use of EGL instead of the platform's default (listed above) is made possible
  10. // via the "egl" build tag.
  11. //
  12. // It is also possible to install your own function outside this package for
  13. // retrieving OpenGL function pointers, to do this see InitWithProcAddrFunc.
  14. package gles2
  15. /*
  16. #cgo windows CFLAGS: -DTAG_WINDOWS
  17. #cgo !gles2,windows LDFLAGS: -lopengl32
  18. #cgo gles2,windows LDFLAGS: -lGLESv2
  19. #cgo darwin CFLAGS: -DTAG_DARWIN
  20. #cgo !gles2,darwin LDFLAGS: -framework OpenGL
  21. #cgo gles2,darwin LDFLAGS: -framework OpenGLES
  22. #cgo linux freebsd netbsd openbsd CFLAGS: -DTAG_POSIX
  23. #cgo !egl,linux !egl,freebsd !egl,netbsd !egl,openbsd pkg-config: gl
  24. #cgo egl,linux egl,freebsd egl,netbsd egl,openbsd egl,windows CFLAGS: -DTAG_EGL
  25. #cgo egl,linux egl,freebsd egl,netbsd egl,openbsd pkg-config: egl
  26. #cgo egl,windows LDFLAGS: -lEGL
  27. #cgo egl,darwin LDFLAGS: -lEGL
  28. // Check the EGL tag first as it takes priority over the platform's default
  29. // configuration of WGL/GLX/CGL.
  30. #if defined(TAG_EGL)
  31. #include <stdlib.h>
  32. #include <EGL/egl.h>
  33. void* GlowGetProcAddress_gles231(const char* name) {
  34. return eglGetProcAddress(name);
  35. }
  36. #elif defined(TAG_WINDOWS)
  37. #define WIN32_LEAN_AND_MEAN 1
  38. #include <windows.h>
  39. #include <stdlib.h>
  40. static HMODULE ogl32dll = NULL;
  41. void* GlowGetProcAddress_gles231(const char* name) {
  42. void* pf = wglGetProcAddress((LPCSTR) name);
  43. if (pf) {
  44. return pf;
  45. }
  46. if (ogl32dll == NULL) {
  47. ogl32dll = LoadLibraryA("opengl32.dll");
  48. }
  49. return GetProcAddress(ogl32dll, (LPCSTR) name);
  50. }
  51. #elif defined(TAG_DARWIN)
  52. #include <stdlib.h>
  53. #include <dlfcn.h>
  54. void* GlowGetProcAddress_gles231(const char* name) {
  55. return dlsym(RTLD_DEFAULT, name);
  56. }
  57. #elif defined(TAG_POSIX)
  58. #include <stdlib.h>
  59. #include <GL/glx.h>
  60. void* GlowGetProcAddress_gles231(const char* name) {
  61. return glXGetProcAddress((const GLubyte *) name);
  62. }
  63. #endif
  64. */
  65. import "C"
  66. import "unsafe"
  67. func getProcAddress(namea string) unsafe.Pointer {
  68. cname := C.CString(namea)
  69. defer C.free(unsafe.Pointer(cname))
  70. return C.GlowGetProcAddress_gles231(cname)
  71. }