Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Choose GetProcAddr function inside each generated package.
This replaces the old procaddr/* packages.
- Loading branch information
Showing
4 changed files
with
87 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// This file implements GlowGetProcAddress for each platform. The correct | ||
// version is chosen automatically based on build tags: | ||
// | ||
// windows: WGL | ||
// darwin: CGL | ||
// linux: 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 {{.Name}} | ||
|
||
/* | ||
#cgo windows CFLAGS: -DTAG_WINDOWS | ||
#cgo windows LDFLAGS: -lopengl32 | ||
|
||
#cgo darwin CFLAGS: -DTAG_DARWIN | ||
#cgo darwin LDFLAGS: -framework OpenGL | ||
|
||
#cgo linux CFLAGS: -DTAG_LINUX | ||
#cgo linux LDFLAGS: -lGL | ||
|
||
#cgo egl CFLAGS: -DTAG_EGL | ||
#cgo egl LDFLAGS: -lEGL | ||
|
||
#ifdef TAG_WINDOWS | ||
#define WIN32_LEAN_AND_MEAN 1 | ||
#include <windows.h> | ||
#include <stdlib.h> | ||
static HMODULE ogl32dll = NULL; | ||
void* GlowGetProcAddress(const char* name) { | ||
void* pf = wglGetProcAddress((LPCSTR)name); | ||
if(pf) { | ||
return pf; | ||
} | ||
if(ogl32dll == NULL) { | ||
ogl32dll = LoadLibraryA("opengl32.dll"); | ||
} | ||
return GetProcAddress(ogl32dll, (LPCSTR)name); | ||
} | ||
#endif | ||
|
||
#ifdef TAG_DARWIN | ||
#include <stdlib.h> | ||
#include <dlfcn.h> | ||
void* GlowGetProcAddress(const char* name) { | ||
return dlsym(RTLD_DEFAULT, name); | ||
} | ||
#endif | ||
|
||
#ifdef TAG_LINUX | ||
#include <stdlib.h> | ||
#include <GL/glx.h> | ||
void* GlowGetProcAddress(const char* name) { | ||
return glXGetProcAddress(name); | ||
} | ||
#endif | ||
|
||
#ifdef TAG_EGL | ||
#include <stdlib.h> | ||
#include <EGL/egl.h> | ||
void* GlowGetProcAddress(const char* name) { | ||
return eglGetProcAddress(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(cname) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters