diff --git a/raylib/platform_web.go b/raylib/platform_web.go new file mode 100644 index 0000000..85b813e --- /dev/null +++ b/raylib/platform_web.go @@ -0,0 +1,69 @@ +// +build js + +package raylib + +import ( + "os" + "unsafe" + + "github.com/gopherjs/gopherjs/js" +) + +// InitWindow - Initialize Window and OpenGL Graphics +func InitWindow(width int32, height int32, t interface{}) { + js.Global.Get("Module").Call("_InitWindow", width, height, t.(string)) +} + +// SetCallbackFunc - Sets callback function +func SetCallbackFunc(func(unsafe.Pointer)) { +} + +// SetMainLoop - Sets main loop function +func SetMainLoop(fn func(), fps int, infinite bool) { + js.Global.Set("_go_update_function", fn) + js.Global.Get("Module").Call("_emscripten_set_main_loop_go", fps, infinite) +} + +// ShowCursor - Shows cursor +func ShowCursor() { +} + +// HideCursor - Hides cursor +func HideCursor() { +} + +// IsCursorHidden - Returns true if cursor is not visible +func IsCursorHidden() bool { + return false +} + +// EnableCursor - Enables cursor +func EnableCursor() { +} + +// DisableCursor - Disables cursor +func DisableCursor() { +} + +// IsFileDropped - Check if a file have been dropped into window +func IsFileDropped() bool { + return false +} + +// GetDroppedFiles - Retrieve dropped files into window +func GetDroppedFiles(count *int32) (f []string) { + return +} + +// ClearDroppedFiles - Clear dropped files paths buffer +func ClearDroppedFiles() { +} + +// OpenAsset - Open asset +func OpenAsset(name string) (Asset, error) { + f, err := os.Open(name) + if err != nil { + return nil, err + } + return f, nil +} diff --git a/raylib/raylib_js.go b/raylib/raylib_js.go index dbe95eb..72610c5 100644 --- a/raylib/raylib_js.go +++ b/raylib/raylib_js.go @@ -10,55 +10,6 @@ import ( "github.com/gopherjs/gopherjs/js" ) -// InitWindow - Initialize Window and OpenGL Graphics -func InitWindow(width int32, height int32, t interface{}) { - js.Global.Get("Module").Call("_InitWindow", width, height, t.(string)) -} - -// SetCallbackFunc - Sets callback function -func SetCallbackFunc(func(unsafe.Pointer)) { -} - -// SetMainLoop - Sets main loop function -func SetMainLoop(f func(), fps, simulateInfiniteLoop int) { - js.Global.Get("Module").Call("_emscripten_set_main_loop", f, fps, simulateInfiniteLoop) -} - -// ShowCursor - Shows cursor -func ShowCursor() { -} - -// HideCursor - Hides cursor -func HideCursor() { -} - -// IsCursorHidden - Returns true if cursor is not visible -func IsCursorHidden() bool { - return false -} - -// EnableCursor - Enables cursor -func EnableCursor() { -} - -// DisableCursor - Disables cursor -func DisableCursor() { -} - -// IsFileDropped - Check if a file have been dropped into window -func IsFileDropped() bool { - return false -} - -// GetDroppedFiles - Retrieve dropped files into window -func GetDroppedFiles(count *int32) (f []string) { - return -} - -// ClearDroppedFiles - Clear dropped files paths buffer -func ClearDroppedFiles() { -} - // InitAudioDevice - Initialize audio device and context func InitAudioDevice() { js.Global.Get("Module").Call("_InitAudioDevice")