Move camera, platform dummy functions, fix examples
This commit is contained in:
parent
5cec8900be
commit
5d5a0e708f
7 changed files with 116 additions and 56 deletions
|
@ -8,7 +8,7 @@ func main() {
|
||||||
raylib.InitWindow(800, 450, "raylib [core] example - 3d mode")
|
raylib.InitWindow(800, 450, "raylib [core] example - 3d mode")
|
||||||
|
|
||||||
camera := raylib.Camera{}
|
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.Target = raylib.NewVector3(0.0, 0.0, 0.0)
|
||||||
camera.Up = raylib.NewVector3(0.0, 1.0, 0.0)
|
camera.Up = raylib.NewVector3(0.0, 1.0, 0.0)
|
||||||
camera.Fovy = 45.0
|
camera.Fovy = 45.0
|
||||||
|
|
|
@ -11,7 +11,7 @@ func main() {
|
||||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions")
|
raylib.InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions")
|
||||||
|
|
||||||
camera := raylib.Camera{}
|
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.Target = raylib.NewVector3(0.0, 0.0, 0.0)
|
||||||
camera.Up = raylib.NewVector3(0.0, 1.0, 0.0)
|
camera.Up = raylib.NewVector3(0.0, 1.0, 0.0)
|
||||||
camera.Fovy = 45.0
|
camera.Fovy = 45.0
|
||||||
|
|
|
@ -11,7 +11,7 @@ func main() {
|
||||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes")
|
raylib.InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes")
|
||||||
|
|
||||||
camera := raylib.Camera{}
|
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.Target = raylib.NewVector3(0.0, 0.0, 0.0)
|
||||||
camera.Up = raylib.NewVector3(0.0, 1.0, 0.0)
|
camera.Up = raylib.NewVector3(0.0, 1.0, 0.0)
|
||||||
camera.Fovy = 45.0
|
camera.Fovy = 45.0
|
||||||
|
|
|
@ -6,6 +6,59 @@ package raylib
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
*/
|
*/
|
||||||
import "C"
|
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
|
// Camera mode
|
||||||
type CameraMode int32
|
type CameraMode int32
|
||||||
|
|
|
@ -349,58 +349,6 @@ func NewRectangleFromPointer(ptr unsafe.Pointer) Rectangle {
|
||||||
return *(*Rectangle)(ptr)
|
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
|
// Bounding box
|
||||||
type BoundingBox struct {
|
type BoundingBox struct {
|
||||||
// Minimum vertex box-corner
|
// Minimum vertex box-corner
|
||||||
|
|
|
@ -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
|
// Open asset
|
||||||
func OpenAsset(name string) (Asset, error) {
|
func OpenAsset(name string) (Asset, error) {
|
||||||
cname := C.CString(name)
|
cname := C.CString(name)
|
||||||
|
|
|
@ -7,7 +7,11 @@ package raylib
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
import "unsafe"
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
// Initialize Window and OpenGL Graphics
|
// Initialize Window and OpenGL Graphics
|
||||||
func InitWindow(width int32, height int32, t interface{}) {
|
func InitWindow(width int32, height int32, t interface{}) {
|
||||||
|
@ -54,6 +58,21 @@ func DisableCursor() {
|
||||||
C.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
|
// Open asset
|
||||||
func OpenAsset(name string) (Asset, error) {
|
func OpenAsset(name string) (Asset, error) {
|
||||||
f, err := os.Open(name)
|
f, err := os.Open(name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue