zorldo

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

procaddr_windows.go (566B)


      1 // SPDX-License-Identifier: MIT
      2 
      3 package gl
      4 
      5 import (
      6 	"unsafe"
      7 
      8 	"golang.org/x/sys/windows"
      9 )
     10 
     11 var (
     12 	opengl32          = windows.NewLazySystemDLL("opengl32")
     13 	wglGetProcAddress = opengl32.NewProc("wglGetProcAddress")
     14 )
     15 
     16 func getProcAddress(namea string) uintptr {
     17 	cname, err := windows.BytePtrFromString(namea)
     18 	if err != nil {
     19 		panic(err)
     20 	}
     21 	if r, _, _ := wglGetProcAddress.Call(uintptr(unsafe.Pointer(cname))); r != 0 {
     22 		return r
     23 	}
     24 	p := opengl32.NewProc(namea)
     25 	if err := p.Find(); err != nil {
     26 		// The proc is not found.
     27 		return 0
     28 	}
     29 	return p.Addr()
     30 }