2019-09-22 17:42:51 +02:00
|
|
|
// SPDX-License-Identifier: MIT
|
2018-12-08 18:35:13 +01:00
|
|
|
|
|
|
|
package gl
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
2019-09-22 17:42:51 +02:00
|
|
|
|
|
|
|
"golang.org/x/sys/windows"
|
2018-12-08 18:35:13 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2019-01-04 07:05:27 +01:00
|
|
|
opengl32 = windows.NewLazySystemDLL("opengl32")
|
2018-12-08 18:35:13 +01:00
|
|
|
wglGetProcAddress = opengl32.NewProc("wglGetProcAddress")
|
|
|
|
)
|
|
|
|
|
|
|
|
func getProcAddress(namea string) unsafe.Pointer {
|
2019-01-04 07:05:27 +01:00
|
|
|
cname, err := windows.BytePtrFromString(namea)
|
2018-12-08 18:35:13 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if r, _, _ := wglGetProcAddress.Call(uintptr(unsafe.Pointer(cname))); r != 0 {
|
|
|
|
return unsafe.Pointer(r)
|
|
|
|
}
|
|
|
|
p := opengl32.NewProc(namea)
|
|
|
|
if err := p.Find(); err != nil {
|
|
|
|
// The proc is not found.
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return unsafe.Pointer(p.Addr())
|
|
|
|
}
|