-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Allen Ray
committed
Mar 14, 2024
1 parent
83d871a
commit 08ff520
Showing
5 changed files
with
53 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa h1:Ik7QikRgeH+bFOfAcMpttCbs6XxWXxCLXMm4awxtOXk= | ||
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ= | ||
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= | ||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
github.com/ebitengine/purego v0.6.1 h1:sjN8rfzbhXQ59/pE+wInswbU9aMDHiwlup4p/a07Mkg= | ||
github.com/ebitengine/purego v0.6.1/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ= | ||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= | ||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//go:build !cgo && (darwin || freebsd || linux) | ||
|
||
package rl | ||
|
||
import ( | ||
"fmt" | ||
"unsafe" | ||
|
||
"github.com/ebitengine/purego" | ||
"golang.org/x/sys/unix" | ||
) | ||
|
||
const ( | ||
libname = "raylib.so" | ||
requiredVersion = "5.0" | ||
) | ||
|
||
// loadLibrary loads the raylib dll and panics on error | ||
func loadLibrary() uintptr { | ||
handle, err := purego.Dlopen(libname, purego.RTLD_DEFAULT) | ||
if err != nil { | ||
panic(fmt.Errorf("cannot load library %s: %w", libname, err)) | ||
} | ||
|
||
proc, err := purego.Dlsym(handle, "raylib_version") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
version := unix.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 { | ||
return purego.NewCallback(func(logLevel int32, text *byte) uintptr { | ||
fn(int(logLevel), unix.BytePtrToString(text)) | ||
return 0 | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
//go:build !cgo && windows | ||
// +build !cgo,windows | ||
//go:build !cgo | ||
// +build !cgo | ||
|
||
package rl | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
//go:build !cgo && windows | ||
// +build !cgo,windows | ||
//go:build !cgo | ||
// +build !cgo | ||
|
||
package rl | ||
|
||
|