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")
|
|
|
|
)
|
|
|
|
|
2019-10-06 16:19:56 +02:00
|
|
|
func getProcAddress(namea string) uintptr {
|
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 {
|
2019-10-06 16:19:56 +02:00
|
|
|
return r
|
2018-12-08 18:35:13 +01:00
|
|
|
}
|
|
|
|
p := opengl32.NewProc(namea)
|
|
|
|
if err := p.Find(); err != nil {
|
|
|
|
// The proc is not found.
|
2019-10-06 16:19:56 +02:00
|
|
|
return 0
|
2018-12-08 18:35:13 +01:00
|
|
|
}
|
2019-10-06 16:19:56 +02:00
|
|
|
return p.Addr()
|
2018-12-08 18:35:13 +01:00
|
|
|
}
|