zorldo

Goofing around with Ebiten
git clone git://bsandro.tech/zorldo
Log | Files | Refs | README

procaddr_notwindows.go (1543B)


      1 // SPDX-License-Identifier: MIT
      2 
      3 //go:build !windows
      4 // +build !windows
      5 
      6 // This file implements GlowGetProcAddress for every supported platform. The
      7 // correct version is chosen automatically based on build tags:
      8 //
      9 // darwin: CGL
     10 // linux freebsd: GLX
     11 //
     12 // Use of EGL instead of the platform's default (listed above) is made possible
     13 // via the "egl" build tag.
     14 //
     15 // It is also possible to install your own function outside this package for
     16 // retrieving OpenGL function pointers, to do this see InitWithProcAddrFunc.
     17 
     18 package gl
     19 
     20 /*
     21 #cgo darwin CFLAGS: -DTAG_DARWIN
     22 #cgo darwin LDFLAGS: -framework OpenGL
     23 #cgo linux freebsd CFLAGS: -DTAG_POSIX
     24 #cgo linux freebsd pkg-config: gl
     25 #cgo egl CFLAGS: -DTAG_EGL
     26 #cgo egl pkg-config: egl
     27 // Check the EGL tag first as it takes priority over the platform's default
     28 // configuration of WGL/GLX/CGL.
     29 #if defined(TAG_EGL)
     30 	#include <stdlib.h>
     31 	#include <EGL/egl.h>
     32 	static void* GlowGetProcAddress_gl21(const char* name) {
     33 		return eglGetProcAddress(name);
     34 	}
     35 #elif defined(TAG_DARWIN)
     36 	#include <stdlib.h>
     37 	#include <dlfcn.h>
     38 	static void* GlowGetProcAddress_gl21(const char* name) {
     39 		return dlsym(RTLD_DEFAULT, name);
     40 	}
     41 #elif defined(TAG_POSIX)
     42 	#include <stdlib.h>
     43 	#include <GL/glx.h>
     44 	static void* GlowGetProcAddress_gl21(const char* name) {
     45 		return glXGetProcAddress((const GLubyte *) name);
     46 	}
     47 #endif
     48 */
     49 import "C"
     50 import "unsafe"
     51 
     52 func getProcAddress(namea string) unsafe.Pointer {
     53 	cname := C.CString(namea)
     54 	defer C.free(unsafe.Pointer(cname))
     55 	return C.GlowGetProcAddress_gl21(cname)
     56 }