implement version check
This commit is contained in:
parent
c535f250e9
commit
efaf005350
1 changed files with 17 additions and 4 deletions
|
@ -5,22 +5,35 @@ package rl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/ebitengine/purego"
|
"github.com/ebitengine/purego"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
libname = "raylib.dll"
|
libname = "raylib.dll"
|
||||||
|
requiredVersion = "5.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
// loadLibrary loads the raylib dll and panics on error
|
// loadLibrary loads the raylib dll and panics on error
|
||||||
func loadLibrary() uintptr {
|
func loadLibrary() uintptr {
|
||||||
if handle, err := windows.LoadLibrary(libname); err != nil {
|
handle, err := windows.LoadLibrary(libname)
|
||||||
|
if err != nil {
|
||||||
panic(fmt.Errorf("cannot load library %s: %w", libname, err))
|
panic(fmt.Errorf("cannot load library %s: %w", libname, err))
|
||||||
} else {
|
|
||||||
return uintptr(handle)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc, err := windows.GetProcAddress(handle, "raylib_version")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
version := windows.BytePtrToString(**(***byte)(unsafe.Pointer(&proc)))
|
||||||
|
if version != requiredVersion {
|
||||||
|
panic(fmt.Errorf("version %s of %s doesn't match the required version %s", version, libname, requiredVersion))
|
||||||
|
}
|
||||||
|
|
||||||
|
return uintptr(handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
func traceLogCallbackWrapper(fn TraceLogCallbackFun) uintptr {
|
func traceLogCallbackWrapper(fn TraceLogCallbackFun) uintptr {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue