2019-09-22 17:42:51 +02:00
|
|
|
// SPDX-License-Identifier: MIT
|
2018-12-08 18:35:13 +01:00
|
|
|
|
2021-06-10 18:03:35 +02:00
|
|
|
//go:build !windows
|
2019-09-22 17:42:51 +02:00
|
|
|
// +build !windows
|
2018-12-08 18:35:13 +01:00
|
|
|
|
|
|
|
// This file implements GlowGetProcAddress for every supported platform. The
|
|
|
|
// correct version is chosen automatically based on build tags:
|
|
|
|
//
|
|
|
|
// darwin: CGL
|
|
|
|
// linux freebsd: GLX
|
|
|
|
//
|
|
|
|
// Use of EGL instead of the platform's default (listed above) is made possible
|
|
|
|
// via the "egl" build tag.
|
|
|
|
//
|
|
|
|
// It is also possible to install your own function outside this package for
|
|
|
|
// retrieving OpenGL function pointers, to do this see InitWithProcAddrFunc.
|
|
|
|
|
|
|
|
package gl
|
|
|
|
|
|
|
|
/*
|
|
|
|
#cgo darwin CFLAGS: -DTAG_DARWIN
|
|
|
|
#cgo darwin LDFLAGS: -framework OpenGL
|
|
|
|
#cgo linux freebsd CFLAGS: -DTAG_POSIX
|
2019-12-10 19:00:20 +01:00
|
|
|
#cgo linux freebsd pkg-config: gl
|
2018-12-08 18:35:13 +01:00
|
|
|
#cgo egl CFLAGS: -DTAG_EGL
|
2019-12-10 19:00:20 +01:00
|
|
|
#cgo egl pkg-config: egl
|
2018-12-08 18:35:13 +01:00
|
|
|
// Check the EGL tag first as it takes priority over the platform's default
|
|
|
|
// configuration of WGL/GLX/CGL.
|
|
|
|
#if defined(TAG_EGL)
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <EGL/egl.h>
|
2019-01-17 13:27:58 +01:00
|
|
|
static void* GlowGetProcAddress_gl21(const char* name) {
|
2018-12-08 18:35:13 +01:00
|
|
|
return eglGetProcAddress(name);
|
|
|
|
}
|
|
|
|
#elif defined(TAG_DARWIN)
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <dlfcn.h>
|
2019-01-17 13:27:58 +01:00
|
|
|
static void* GlowGetProcAddress_gl21(const char* name) {
|
2018-12-08 18:35:13 +01:00
|
|
|
return dlsym(RTLD_DEFAULT, name);
|
|
|
|
}
|
|
|
|
#elif defined(TAG_POSIX)
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <GL/glx.h>
|
2019-01-17 13:27:58 +01:00
|
|
|
static void* GlowGetProcAddress_gl21(const char* name) {
|
2018-12-08 18:35:13 +01:00
|
|
|
return glXGetProcAddress((const GLubyte *) name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
import "unsafe"
|
|
|
|
|
|
|
|
func getProcAddress(namea string) unsafe.Pointer {
|
|
|
|
cname := C.CString(namea)
|
|
|
|
defer C.free(unsafe.Pointer(cname))
|
|
|
|
return C.GlowGetProcAddress_gl21(cname)
|
|
|
|
}
|