Giter Site home page Giter Site logo

shadowapex / godot-go Goto Github PK

View Code? Open in Web Editor NEW
362.0 362.0 31.0 9.94 MB

Go language bindings for the Godot Engine's GDNative API.

License: MIT License

Go 92.12% Shell 0.02% Makefile 0.01% C 7.60% C++ 0.26%
gdnative godot godot-engine godot-go godotengine golang language-bindings nativescript

godot-go's People

Contributors

1l0 avatar karroffel avatar khairul169 avatar lupodharkael avatar pastaq avatar rameshravone avatar shadowapex avatar worrel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

godot-go's Issues

Probelm with AnimationPlayer (suspecting gd.Real does not translate well)

Description

I started using godot-go recently and I gotta say - the work you've done here is amazing and I'd love to contribute and make it more stable - that saying, I have a problem I can't figure how to solve.

The bindings work fine but for some reason, the AnimationPlayer element is behaving odd.
Calling .Play() or .GetCurrentAnimationLength() seem to behave as if the gd.Real parameters and return values map to 0.

Things I've tried doing with no success:

  • Editing .Play() on AnimationPlayer and AnimationPlayerImplementer to accept gd.Float instead of gd.Real
  • Making gd.Float underlying type be float32 instead of float64

I've created an example project repo for convenience:
https://github.com/mastern2k3/godot-go-animtest

Would love help on this or maybe a new thread to follow, thanks in advance!

Details

Go version go version go1.11 linux/amd64
Godot version 3.1.stable.official
Godot-Go version/commit hash master branch "1746202"
OS Linux Mint 19.1 linux/amd64

Does not have a library for the current platform error

Description

0:00:00:0247 - does not have a library for the current platform

Type:Error
Description: does not have a library for the current platform
Time: 0:00:00:0247
C Error: Condition ' lib_path.length() == 0 ' is true.
C Source: modules/gdnative/nativescript/nativescript.cpp:1031
C Function: init_library

As you can see, I've tried adding the library various ways, but always get the same error.
image

Details

Go version go1.11.4 linux/amd64
Godot version v3.0.6.stable.official.8314054
Godot-Go version/commit hash 1746202 (latest)
OS Arch Linux

Generate Go structures for all Godot objects.

We need to write code parsing and code generation to create native Go structures for all available Godot objects. This will allow us to embed Godot objects into Go structs to make all of their methods and properties available to the "child" class.

Not work gdnative

Hi! I tried to add gdnative support. When I run a game have a error:
2017-12-20 22 02 28

I am set in node script dynamic lib:
2017-12-20 22 02 36

What I do wrong?

Doesn't compile under windows

Description

Can't get it to work under windows.
Can't compile the example in windows due to the following error:
(this is with the 1.11beta2, with the normal released version in windows. the Realesed 1.10.x version get issues with the filname path to long, but this is a go win issue. Its fixed in 1.11)
c:/program files/mingw-w64/x86_64-7.2.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: Error: export ordinal too large: 74588

When I cross compile it in Linux I get the following errors:

go build -buildmode=c-shared -o simple.dll FSM.go
github.com/shadowapex/godot-go/vendor/github.com/vitaminwater/cgo.wchar /home/dio/.go/src/github.com/shadowapex/godot-go/vendor/github.com/vitaminwater/cgo.wchar/wchar.go:15:12: undefined: convertWcharToGoRune /home/dio/.go/src/github.com/shadowapex/godot-go/vendor/github.com/vitaminwater/cgo.wchar/wchar.go:23:9: undefined: convertGoRuneToWchar /home/dio/.go/src/github.com/shadowapex/godot-go/vendor/github.com/vitaminwater/cgo.wchar/wchar.go:47:9: undefined: convertGoStringToWcharString /home/dio/.go/src/github.com/shadowapex/godot-go/vendor/github.com/vitaminwater/cgo.wchar/wchar.go:128:14: undefined: convertWcharStringToGoString /home/dio/.go/src/github.com/shadowapex/godot-go/vendor/github.com/vitaminwater/cgo.wchar/wchar.go:141:9: undefined: convertWcharStringToGoString /home/dio/.go/src/github.com/shadowapex/godot-go/vendor/github.com/vitaminwater/cgo.wchar/wchar.go:150:9: undefined: convertWcharStringToGoString /home/dio/.go/src/github.com/shadowapex/godot-go/vendor/github.com/vitaminwater/cgo.wchar/wchar.go:158:9: undefined: convertWcharToGoRune
my go env:

GOARCH="amd64" GOBIN="" GOCACHE="/home/dio/.cache/go-build" GOEXE=".exe" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="windows" GOPATH="/home/dio/.go" GORACE="" GOROOT="/usr/bin/go" GOTMPDIR="" GOTOOLDIR="/usr/bin/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="x86_64-linux-gnu-gcc" CXX="x86_64-linux-gnu-g++" CGO_ENABLED="0" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-m64 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build621006750=/tmp/go-build -gno-record-gcc-switches"

Details

Go version 1.11beta2 windows /1.10.3 linux
OS windows

Compiling for iOS and Android

Description

How can we compile this for android and ios. You have mentioned it for Windows and MacOS only.

Details

Go version
Godot version
Godot-Go version/commit hash
OS

libgodot.so: undefined symbol: godot_rect3_get_shortest_axis_size

Using the example (pong.go), made a shorter version, but when trying to run it from Godot, gives the error:

> ERROR: open_dynamic_library: Can't open dynamic library: /Apps/GODOT/3.0/PRJS/grad1/libgodot.so. 
> Error: /Apps/GODOT/3.0/PRJS/grad1/libgodot.so: undefined symbol: godot_rect3_get_shortest_axis_size
>    At: drivers/unix/os_unix.cpp:407.
> ERROR: get_symbol: No valid library handle, can't get symbol from GDNative object
>    At: modules/gdnative/gdnative.cpp:346.
> ERROR: init_library: No godot_nativescript_init in "res://libgodot.so" found
>    At: modules/gdnative/nativescript/nativescript.cpp:1016.

The only difference from the configuration process is that I didn't put the library as a global (as it doesn't seem to exist anymore; see #27 ) The code is used is the following:

package main

import (
	"log"

	"github.com/shadowapex/godot-go/godot"
)

type FooClass struct {
	godot.Node2D
	direction *godot.Vector2
}

func NewFooClass() godot.Class {
	fooClass := &FooClass{
		direction: godot.NewVector2(1.0, 0.0),
	}

	return fooClass
}

func (p *FooClass) X_ready() {
	screenSize := p.GetViewportRect()
	godot.Log.Warning("***Screen size***")
	godot.Log.Warning(screenSize.AsString())
	godot.Log.Warning(p)
	godot.Log.Warning(p.GetOwner())
	godot.Log.Warning(p.GetName())
	godot.Log.Warning(p.GetClass())
}

func init() {
	godot.SetGodotGDNativeInit(func(options *godot.GodotGDNativeInitOptions) {
		log.Println("This is being called from foo.go!")
	})

	godot.Register(NewFooClass)
}

func main() {
}

If I check the library I generated (using latest headers from github) with objdump, I see UND for godot_rect3_get_shortest_axis_size:

$ objdump -x libgodot.so |grep godot_rect3_get_shortest_axis_size
0000000001a01cd0 l     O .data	0000000000000008              github.com/shadowapex/godot-go/godot._cgo_1a4ce146d54f_Cfunc_godot_rect3_get_shortest_axis_size
0000000000754c20 l     F .text	0000000000000087              github.com/shadowapex/godot-go/godot._Cfunc_godot_rect3_get_shortest_axis_size
0000000000000000         *UND*	0000000000000000              godot_rect3_get_shortest_axis_size
0000000000bf3f90 g     F .text	000000000000003a              _cgo_1a4ce146d54f_Cfunc_godot_rect3_get_shortest_axis_size

Readme example does not compile

The README has basically this as an intro example.

package main

import (
	"github.com/ShadowApex/godot-go/godot"
)

func init() {
	// Register will register the given class constructor with Godot.
	godot.Register(NewSimpleClass)
}

func main() {
}

// SimpleClass is a simple go struct that can be attached to a Godot Node2D object.
type SimpleClass struct {
	godot.Node2D
}

// X_ready is called as soon as the node enters the scene.
func (h *SimpleClass) X_ready() {
	godot.Log.Warning("Hello World!")
}

// NewSimpleClass is a constructor that we can pass to godot.
func NewSimpleClass() godot.Class {
	return &SimpleClass{}
}

However will not compile: undefined: godot.Node2D. The docs appear to be out of date.

Crash on example DodgeTheCreeps

The app could be launched and the player could be controlled,
screen shot 2018-03-22 at 6 15 36
but after a couple of seconds the app will crash.
Go version: go1.10 darwin/amd64
Godot version: 3.0.2.stable.official or 3.0.0.stable.official

$ godot -v
arguments
0: godot
1: -v
Current path: $GOPATH/src/github.com/ShadowApex/godot-go/examples/godot/DodgeTheCreeps
Using GLES3 video driver
OpenGL ES 3.0 Renderer: NVIDIA GeForce 320M OpenGL Engine
CoreAudio: detected 2 channels
CoreAudio: audio buffer frames: 512 calculated latency: 11ms
CORE API HASH: 5483915881153564253
EDITOR API HASH: -5919760101651613804
load resource: res://default_env.tres
load resource: res://Main.tscn
load resource: res://libgodot.gdnlib
load resource: res://Mob.tscn
load resource: res://libgodot.gdnlib (cached)
load resource: res://art/enemySwimming_1.png
load resource: res://art/enemySwimming_2.png
load resource: res://art/enemyWalking_1.png
load resource: res://art/enemyWalking_2.png
load resource: res://art/enemyFlyingAlt_1.png
load resource: res://art/enemyFlyingAlt_2.png
load resource: res://libgodot.gdnlib (cached)
2018/03/22 06:04:58 godot.go:74: Discovering classes to register with Godot...
load resource: res://art/enemySwimming_1.png (cached)
load resource: res://art/enemySwimming_2.png (cached)
load resource: res://art/enemyWalking_1.png (cached)
load resource: res://art/enemyWalking_2.png (cached)
load resource: res://art/enemyFlyingAlt_1.png (cached)
load resource: res://art/enemyFlyingAlt_2.png (cached)
load resource: res://Player.tscn
load resource: res://libgodot.gdnlib (cached)
load resource: res://art/playerGrey_walk1.png
load resource: res://art/playerGrey_walk2.png
load resource: res://art/playerGrey_up1.png
load resource: res://art/playerGrey_up2.png
load resource: res://libgodot.gdnlib (cached)
load resource: res://art/playerGrey_walk1.png (cached)
load resource: res://art/playerGrey_walk2.png (cached)
load resource: res://art/playerGrey_up1.png (cached)
load resource: res://art/playerGrey_up2.png (cached)
load resource: res://libgodot.gdnlib (cached)
load resource: res://Mob.tscn (cached)
load resource: res://Player.tscn (cached)
2018/03/22 06:04:58 player.go:34: X_Ready called!
2018/03/22 06:04:58 player.go:37: Getting animated sprite...
2018/03/22 06:04:58 player.go:40: Got animated sprite with ID: 0x7fe081ed91a0
2018/03/22 06:04:58 main.go:53: X_Ready called!
2018/03/22 06:04:58 main.go:54: Registry: &{map[0x7fe081ecf1c0:0xc4200d1b80 0x7fe081ed8ce0:0xc4200ea0a0]}
2018/03/22 06:04:58 main.go:95: New Game
FPS: 1
FPS: 1
FPS: 7
FPS: 60
2018/03/22 06:05:01 main.go:102: Start timer timeout
FPS: 60
2018/03/22 06:05:01 main.go:113: Mob timer timeout
handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
-- END OF BACKTRACE --
Abort trap: 6

compiling on OSX ?

This looks very interesting..
golang and native script with godot is a pretty compelling solution.

Has anyone gotten an OSX make file ?
Just trying to get going fast to try things out.

Implement all Godot Variant types in Go.

Currently we support basic Godot variant type like godot_string, godot_int, etc. We need to finish implementing the other types as their own Go structures that wrap around the underlying variant.

Provide an example of using Go code for networking

Given that Go has excellent networking library and it's a breeze to code network stuff in Go, could you provide an example of writing some dead-simple network lib in Go and interfacing it from Godot scripts /C++ ?

Path Error on Windows & gofmt error due to error generating type.

Description

  1. When generating wrappers in windows, go confuses "\" depending on the method used for getting the file name. This can be fixed with: preHeader := filepath.ToSlash(headerName) on line 361 of types/generate.go
  2. As soon as this fix was done, gofmt throws an error saying it expects a symbol and found newline. Output as attachment. output.txt

Details

Go version go1.11.5
Godot version based on the output: /c/Users/*****/scoop/shims/godot (3.0.6
Godot-Go version/commit hash 1746202
OS windows/amd64

Editor crashes after loading GDNative

Description

I've used example from https://github.com/ShadowApex/godot-go/tree/master/examples/gdnative/SimpleDemo but this seems to not work.
Ouput from console when running game looks like:

OpenGL ES 2.0 Renderer: GeForce GTX 860M/PCIe/SSE2
ERROR: _get_socket_error: Socket error: 10054
   At: drivers/unix/net_socket_posix.cpp:190
WARNING: main.nativeScriptInit: Initializing nativescript from Go!
     At: C:/path/to/main.go:20
WARNING: main.nativeScriptInit: Registering SIMPLE class...
     At: C:/path/to/main.go:39
WARNING: main.nativeScriptInit: Registering SIMPLE method...
     At: C:/path/to/main.go:48
Cetn e ipels.
Dsryn ipels ihI:x00808.

I suppose, last two lines are from main.go.
gdnative.Log.Println("Creating new SimpleClass...") and gdnative.Log.Println("Destroying SimpleClass with ID:", userData, "..."). If I change gdnative.Log.Println to gdnative.Log.Warning this logs seems to be working but editor still crashes.

Details

Go version go version go1.12 windows/amd64
Godot version v3.1.beta8.official
Godot-Go version/commit hash 1746202
OS windows10 64bit

Individual Class Files

Having a single file to contain all built in classes provides extra difficulty. Namely:

  1. Text editor error checking is heavily bogged down as it needs to parse the entire classes.go file rather than the specific class or parent that is being referenced. I sometimes must wait up to 1 minute to see if a line I corrected removed a compile error.
  2. Navigating a single 120k line file is fairly obnoxious, regardless of the editor or keyboard shortcuts. This is especially true when editing/adding single lines in functions to elucidate issues during troubleshooting. If a fix is found, remembering everything that was modified to add to the template sometimes becomes difficult. For context, the entire pull request for the AMD DC into DRM-next, an effort that had been underway more than a year, was the same size.
  3. Related to the above issue, I acknowledge that these classes should be generated with generate.go and not directly modified. However; regenerating all classes for each test when troubleshooting the cause is quite absurd. It is much simpler to troubleshoot the errant class, then modify the template and regenerate once a working solution is discovered.

To solve these problems, I propose that classes.go be replaced with a directory structure such as ../godot/classes/className.go.

Problem passing multiple parameters to "RegisterMethod" registered method

Currently i'm implementing a library in Go which needs to get multiple parameters on a method call:

https://github.com/chiguireitor/godot-gobtcsuite/blob/154bc8fec32c87dc9a8c8f7dba0a67c3850f5605/src/gobtcsuite.go#L280

That call is getting the first parameter right, but the rest of the Variants in the args array come with weird values. For example, calling with 3 ints i do:

fmt.Sprintf("%d %d %d", args[0].GetType(), args[1].GetType(), args[2].GetType()) 

and get

2 81748992 81748992

as result

Edit: It should be noted that the expected result should be 2 2 2 seems like the args array is only getting initialized on the first value, i've been trying to debug this but can't find where's my method getting called to change it on godot's or godot-go's code.

Implement Singletons Classes

There are several global singleton classes that aren't meant to be embedded. For example, calling godot.OS.GetScreenSize(). We might want to make Singleton classes private and only expose them as variables.

Implement Godot Constants

There's a few constants like "MARGIN_LEFT" that are defined globally in Godot. We should generate and expose these.

KinematicBody2D Move and Collide crashes game

Description

When calling the MoveAndCollide function for the kinematicBody2D the game crashes right after launch with no error, the code snippet below works fine with the line commented out. I can just set the position but collisions will not be calculated then.

// X_Process is called every frame
func (r *Robot) X_Process(delta gd.Real) {

	velocity := gd.NewVector2(0, 0)

	if godot.Input.IsActionPressed("ui_right") {
		velocity.SetX(velocity.GetX() + 1)
	}
	if godot.Input.IsActionPressed("ui_left") {
		velocity.SetX(velocity.GetX() - 1)
	}
	if godot.Input.IsActionPressed("ui_down") {
		velocity.SetY(velocity.GetY() + 1)
	}
	if godot.Input.IsActionPressed("ui_up") {
		velocity.SetY(velocity.GetY() - 1)
	}

	if velocity.Length() > 0 {
		normal := velocity.Normalized()
		velocity = normal.OperatorMultiplyScalar(speed)
	}

	r.MoveAndCollide(velocity.OperatorMultiplyScalar(delta))
}

Details

Go version 1.16.2
Godot version 3.2.3
Godot-Go version/commit hash Current
OS Arch Linux 5.11.6

Windows compiled DLL closes without error Godot

Description

I compiled a simple library for linux and it worked without any problem:
When compiling on Windows the editor crashes without any error on console or a dialog when it loses focus.

This is the GDNative:

https://github.com/chiguireitor/godot-gobtcsuite

Details

|Go version | 1.12.6 |
|Godot version | 3.1 stable on windows / 3.2 HEAD on linux |
|Godot-Go version/commit hash | Will ask tomorrow my teammate on his windows version |
|OS | Windows |

Error on android

Description

I tried to compile for Android. I have many problems with libiconv but finaly I fixed
bug when I run game on android give me this error

No implementation found for void org.godotengine.godot.GodotLib.initialize(org.godotengine.godot.Godot, boolean, java.lang.Object, boolean) (tried Java_org_godotengine_godot_GodotLib_initialize and Java_org_godotengine_godot_GodotLib_initialize__Lorg_godotengine_godot_Godot_2ZLjava_lang_Object_2Z)

I build shared library with this command

CC="$PWD/android/toolchainarm64/bin/aarch64-linux-android-gcc" \
    CXX="$PWD/android/toolchainarm64/bin/aarch64-linux-android-g++" \
    CGO_ENABLED=1  \
    GOOS=android GOARCH=arm64   \
    go build   -buildmode=c-shared -o lib/libgodot_android.so src/*.go

Details

Go version 1.10.2
Godot version 3.0.2
Godot-Go version/commit hash 1746202
OS android 7

Debugging

Hey, I was wondering if you all could provide a short guide on how to set this up for debugging. I am honestly new to Go and pretty new to Godot too.

Is it possible to debug this shared library while Godot is running?

Question about running on mac.

Description

Does godot-go work with the current version of godot and golang? I was getting an error:  does not have a library for the current platform. Thanks

Details

Go version go1.10 darwin/amd64
Godot version 3.0.2.stable.official
Godot-Go version/commit hash 1746202
OS Mac

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.