vulkan-go / vulkan

Vulkan API bindings for Go programming language
MIT License
744 stars 56 forks source link

Help! What do I need to do to get coding with Vulkan? #13

Closed rbxb closed 5 years ago

rbxb commented 6 years ago

I'm pretty new to Go and programming in general. I am really interested to get working with Vulkan in Go but I don't know where to start. I understand that Vulkan and some other Go packages use C code behind the scenes and this requires a different compiler. But I don't know what to get, how to install it, etc. What programs do I need to install? I currently have Go 1.9.4 windows/amd64 When I start coding a new project, where do I put the files and how to I configure them? How do I compile and run a program?

I tried figuring it out myself but I simply don't know what I need and I couldn't find a source that has all this information. Thank you for the help!

xlab commented 6 years ago

Hi, all vulkan code is go-gettable under major platforms such as Windows. I tested under Windows 10. It uses GLFW to initialize the window. See https://github.com/vulkan-go/demos for demos.

go get  github.com/vulkan-go/demos/vulkandraw
vulkandraw

But I must warn you that Vulkan API is an extremely advanced topic, I'm afraid it requires very advanced Go and Computer Graphics knowledge..

rbxb commented 6 years ago

Hey thanks for the help! I was able to get a sample GLFW program from go-gl/gflw working. I tested the sample program using the GLFW package from go-gl/gflw (v3.2) as well as the one from vulkan-go/gflw (gflw v3.3) and it worked using both. Anyway, I still cannot get a Vulkan demo to build. I have MinGW 64 installed (is this necessary?) and I got everything in vulkan-go using go get. I tried compiling the vulkan draw demo like this:

go install github.com\vulkan-go\demos\vulkandraw go install github.com\vulkan-go\demos\vulkandraw\vulkandraw_desktop

but neither worked and I got errors like:

go build github.com/vulkan-go/vulkan: invalid flag in #cgo LDFLAGS: -Wl,--allow-multiple-definition

What am I missing? Does the vulkan package need to be installed in a special way?

Also, warning noted. I'm up for the challenge, if I can get to a point where I can actually start coding >_<

xlab commented 6 years ago

@PopcornOne hey try to manually delete -Wl,--allow-multiple-definition probably your MinGW setup doesn't have that.. Btw, configuring MinGW is always pain in ass :(

Also it seems that I provided you wrong instructions about GLFW above, sorry it was relatively long time ago. This project uses vulkan-go/glfw as it only one supporting Vulkan API now. It's not statically linked, so you have to install GLFW properly in some path.

Then use the CGO_FLAG env vars from here: https://github.com/vulkan-go/vulkan/issues/1#issuecomment-258649255

Essentially

CGO_CFLAGS="-IC:\dev\glfw-3.2.1\include" CGO_LDFLAGS="-LC:\dev\glfw-3.2.1\lib-mingw-w64" go install

it should work..

rbxb commented 6 years ago

manually delete -Wl,--allow-multiple-definition

Are these the flags in vulkan-go/vulkan/vulkan_windows.go?

Also, would it be better to reinstall MinGW that does support that?

xlab commented 6 years ago

@PopcornOne

./vulkan_windows.go:#cgo windows LDFLAGS: -lglfw3 -lgdi32 -Wl,--allow-multiple-definition

Also, would it be better to reinstall MinGW that does support that?

Yes, but I always assumed we have these flags under any mingw...

rbxb commented 6 years ago

@xlab Thanks a million for the help! I got the demos working. I didn't need to install a different version of MinGW. I still get the error but it works regardless. I did have to remove the flags for the demos to build

Edit: In case any other newbies need help, this is what I did, in full.

My Go version is 1.9.4 windows/amd64

You should be able to build and run the demos now.

e.g. go install github.com\vulkan-go\demos\vulkandraw\vulkandraw_desktop %GOPATH%\bin\vulkandraw_desktop.exe

delaneyj commented 6 years ago

Thank for leaving this issue open. I'm on windows 10 pro 64bit using Mingw. Manually deleting -Wl,--allow-multiple-definition was the magic sauce plus knowing where to add the proper headers/bin. Can those options on windows be removed from master if they aren't needed and causing issues?

delaneyj commented 5 years ago

Thank you!