From 5d5a0e708fb517c2e9dc84da2ea757024a314e54 Mon Sep 17 00:00:00 2001 From: Milan Nikolic Date: Tue, 21 Feb 2017 14:15:24 +0100 Subject: [PATCH] Move camera, platform dummy functions, fix examples --- examples/core/3d_mode/main.go | 2 +- examples/models/box_collisions/main.go | 2 +- examples/models/geometric_shapes/main.go | 2 +- raylib/camera.go | 53 ++++++++++++++++++++++++ raylib/core.go | 52 ----------------------- raylib/platform_android.go | 40 ++++++++++++++++++ raylib/platform_arm.go | 21 +++++++++- 7 files changed, 116 insertions(+), 56 deletions(-) diff --git a/examples/core/3d_mode/main.go b/examples/core/3d_mode/main.go index 5636eed..34532b6 100644 --- a/examples/core/3d_mode/main.go +++ b/examples/core/3d_mode/main.go @@ -8,7 +8,7 @@ func main() { raylib.InitWindow(800, 450, "raylib [core] example - 3d mode") camera := raylib.Camera{} - camera.Position = raylib.NewVector3(5.0, 10.0, 10.0) + camera.Position = raylib.NewVector3(0.0, 10.0, 10.0) camera.Target = raylib.NewVector3(0.0, 0.0, 0.0) camera.Up = raylib.NewVector3(0.0, 1.0, 0.0) camera.Fovy = 45.0 diff --git a/examples/models/box_collisions/main.go b/examples/models/box_collisions/main.go index 9c9af6b..e75aacd 100644 --- a/examples/models/box_collisions/main.go +++ b/examples/models/box_collisions/main.go @@ -11,7 +11,7 @@ func main() { raylib.InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions") camera := raylib.Camera{} - camera.Position = raylib.NewVector3(10.0, 10.0, 10.0) + camera.Position = raylib.NewVector3(0.0, 10.0, 10.0) camera.Target = raylib.NewVector3(0.0, 0.0, 0.0) camera.Up = raylib.NewVector3(0.0, 1.0, 0.0) camera.Fovy = 45.0 diff --git a/examples/models/geometric_shapes/main.go b/examples/models/geometric_shapes/main.go index c066304..31cad1a 100644 --- a/examples/models/geometric_shapes/main.go +++ b/examples/models/geometric_shapes/main.go @@ -11,7 +11,7 @@ func main() { raylib.InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes") camera := raylib.Camera{} - camera.Position = raylib.NewVector3(0.1, 10.0, 10.0) + camera.Position = raylib.NewVector3(0.0, 10.0, 10.0) camera.Target = raylib.NewVector3(0.0, 0.0, 0.0) camera.Up = raylib.NewVector3(0.0, 1.0, 0.0) camera.Fovy = 45.0 diff --git a/raylib/camera.go b/raylib/camera.go index 5a983f1..e955f86 100644 --- a/raylib/camera.go +++ b/raylib/camera.go @@ -6,6 +6,59 @@ package raylib #include "raylib.h" */ import "C" +import "unsafe" + +// Camera type, defines a camera position/orientation in 3d space +type Camera struct { + // Camera position + Position Vector3 + // Camera target it looks-at + Target Vector3 + // Camera up vector (rotation over its axis) + Up Vector3 + // Camera field-of-view apperture in Y (degrees) + Fovy float32 +} + +func (c *Camera) cptr() *C.Camera { + return (*C.Camera)(unsafe.Pointer(c)) +} + +// Returns new Camera +func NewCamera(pos, target, up Vector3, fovy float32) Camera { + return Camera{pos, target, up, fovy} +} + +// Returns new Camera from pointer +func NewCameraFromPointer(ptr unsafe.Pointer) Camera { + return *(*Camera)(ptr) +} + +// Camera2D type, defines a 2d camera +type Camera2D struct { + // Camera offset (displacement from target) + Offset Vector2 + // Camera target (rotation and zoom origin) + Target Vector2 + // Camera rotation in degrees + Rotation float32 + // Camera zoom (scaling), should be 1.0f by default + Zoom float32 +} + +func (c *Camera2D) cptr() *C.Camera2D { + return (*C.Camera2D)(unsafe.Pointer(c)) +} + +// Returns new Camera2D +func NewCamera2D(offset, target Vector2, rotation, zoom float32) Camera2D { + return Camera2D{offset, target, rotation, zoom} +} + +// Returns new Camera2D from pointer +func NewCamera2DFromPointer(ptr unsafe.Pointer) Camera2D { + return *(*Camera2D)(ptr) +} // Camera mode type CameraMode int32 diff --git a/raylib/core.go b/raylib/core.go index 78588b8..18608d7 100644 --- a/raylib/core.go +++ b/raylib/core.go @@ -349,58 +349,6 @@ func NewRectangleFromPointer(ptr unsafe.Pointer) Rectangle { return *(*Rectangle)(ptr) } -// Camera type, defines a camera position/orientation in 3d space -type Camera struct { - // Camera position - Position Vector3 - // Camera target it looks-at - Target Vector3 - // Camera up vector (rotation over its axis) - Up Vector3 - // Camera field-of-view apperture in Y (degrees) - Fovy float32 -} - -func (c *Camera) cptr() *C.Camera { - return (*C.Camera)(unsafe.Pointer(c)) -} - -// Returns new Camera -func NewCamera(pos, target, up Vector3, fovy float32) Camera { - return Camera{pos, target, up, fovy} -} - -// Returns new Camera from pointer -func NewCameraFromPointer(ptr unsafe.Pointer) Camera { - return *(*Camera)(ptr) -} - -// Camera2D type, defines a 2d camera -type Camera2D struct { - // Camera offset (displacement from target) - Offset Vector2 - // Camera target (rotation and zoom origin) - Target Vector2 - // Camera rotation in degrees - Rotation float32 - // Camera zoom (scaling), should be 1.0f by default - Zoom float32 -} - -func (c *Camera2D) cptr() *C.Camera2D { - return (*C.Camera2D)(unsafe.Pointer(c)) -} - -// Returns new Camera2D -func NewCamera2D(offset, target Vector2, rotation, zoom float32) Camera2D { - return Camera2D{offset, target, rotation, zoom} -} - -// Returns new Camera2D from pointer -func NewCamera2DFromPointer(ptr unsafe.Pointer) Camera2D { - return *(*Camera2D)(ptr) -} - // Bounding box type BoundingBox struct { // Minimum vertex box-corner diff --git a/raylib/platform_android.go b/raylib/platform_android.go index 01ebef6..3bde6ac 100644 --- a/raylib/platform_android.go +++ b/raylib/platform_android.go @@ -48,6 +48,46 @@ func androidMain(app *C.struct_android_app) { } } +// Shows cursor +func ShowCursor() { + return +} + +// Hides cursor +func HideCursor() { + return +} + +// Returns true if cursor is not visible +func IsCursorHidden() bool { + return false +} + +// Enables cursor +func EnableCursor() { + return +} + +// Disables cursor +func DisableCursor() { + return +} + +// Check if a file have been dropped into window +func IsFileDropped() bool { + return false +} + +// Retrieve dropped files into window +func GetDroppedFiles(count *int32) (files []string) { + return +} + +// Clear dropped files paths buffer +func ClearDroppedFiles() { + return +} + // Open asset func OpenAsset(name string) (Asset, error) { cname := C.CString(name) diff --git a/raylib/platform_arm.go b/raylib/platform_arm.go index 7d4d348..0fe8c21 100644 --- a/raylib/platform_arm.go +++ b/raylib/platform_arm.go @@ -7,7 +7,11 @@ package raylib #include */ import "C" -import "unsafe" + +import ( + "os" + "unsafe" +) // Initialize Window and OpenGL Graphics func InitWindow(width int32, height int32, t interface{}) { @@ -54,6 +58,21 @@ func DisableCursor() { C.DisableCursor() } +// Check if a file have been dropped into window +func IsFileDropped() bool { + return false +} + +// Retrieve dropped files into window +func GetDroppedFiles(count *int32) (files []string) { + return +} + +// Clear dropped files paths buffer +func ClearDroppedFiles() { + return +} + // Open asset func OpenAsset(name string) (Asset, error) { f, err := os.Open(name)