EngoEngine / engo

Engo is an open-source 2D game engine written in Go.
https://engoengine.github.io
MIT License
1.74k stars 136 forks source link

Can't build with "headless" build tag #738

Open kori-irrlicht opened 4 years ago

kori-irrlicht commented 4 years ago

I tried to build my project with the headless tag, but got the following error: github.com/!engo!engine/engo@v1.0.5/engo_empty.go:79:4: fallthrough statement out of place

Noofbiz commented 4 years ago

Hmm it looks like a fall through doesn't work with select, maybe the compiler used to build it anyway? I know I've built a headless app to make sure it worked at some point lol

All it needs is the fall through part run on it's own goroutine like it does for the glfw version. Not sure why it doesn't already though

Noofbiz commented 4 years ago

I really hoped go built smarter and only the packages actually used. That way just having that headless variable check would take care of it.

There’s a few options. You can use your headless build of oto, maybe even submit a PR to oto so it can be put in the project. I can see lots of uses for it, such as testing and building on servers. Another option is to use a dummy driver on the server. This would be very useful for testing, since you can get the byte output of the sound driver to ensure you’re outputting what you’re inputting. Your case I don’t believe it offers any advantages over the headless version. The last option is to split common/audio.go into common/audio_headless.go and common/audio.go and use build tags to ensure oto is never touched when you pass the headless tag to engo. I think this one might be good just so that next time someone tries to build with the headless tag it works as expected.