Move camera, platform dummy functions, fix examples

This commit is contained in:
Milan Nikolic 2017-02-21 14:15:24 +01:00
parent 5cec8900be
commit 5d5a0e708f
7 changed files with 116 additions and 56 deletions

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -7,7 +7,11 @@ package raylib
#include <stdlib.h>
*/
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)