5 ms·
What's the standard graphics library for Go That Just Works(tm) ? I'm looking for something for Go like PyGame is for Python. I like to get surfaces rendered o
by yason 14y ago
What's the standard graphics library for Go That Just Works(tm) ?
I'm looking for something for Go like PyGame is for Python. I like to get surfaces rendered on my screen in pretty much no time as I like to learn a language by doing simple graphical demos and experiment from there.
There are few SDL bindings for Go but none of them worked. One of them did work to some extent after a lot of tweaking without the help of many examples. I quit learning after I realized I'd have to learn more how the graphics bindings were written than how to program in Go.
- easytiger 14y agobuilding a "standard graphics library" into a language that is not part of a write once run anywhere managed environment is a terrible idea and has never worked. On the other hand a more solid native 2d drawing library like java2d would be more welcome. Weekend project #34532
- deleted 14y ago[deleted]
- easytiger 14y ago> "write once run anywhere managed environment" that is not even remotely what that is. A sufficiently advanced graphics library will do considerable amounts of non trivial interaction with system dependent and even hardware dependent libraries. The parent cited SDL. Which sits atop other libraries. Which imposes certain runtime constraints.
- laumars 14y agoYou're now talking specifically about SDL, where as I was commenting about your generalisation about Go as a language (which was the context of your previous comment). I'd already said Go lacks any kind of standard graphics library and never tried to argue otherwise. But the standard packages that are included with Go's SDK are cross platform. I can (and frequently do) write Go applications using just the standard libraries that I then run on different platforms (both in terms of OS and CPU architecture) without any code changes what-so-ever. Anyhow, even that being my point, I don't agree with it myself. Thinking properly about it, Go's base packages are little more equivalent to ANSI C than JRE; Go isn't managed and thus base packages are really just a set of standard libraries rather than a runtime environment.
- errnoh 14y agoSadly that's mostly still work in progress. OpenGL bindings are at https://github.com/go-gl https://github.com/go-gl For 2D graphics there's promising project at https://github.com/skelterjohn/go.wde https://github.com/skelterjohn/go.wde which provides interface that you can use together with http://golang.org/pkg/image/draw http://golang.org/pkg/image/draw (Issue worth noting is that none of the platforms specific parts in go.wde yet have hardware acceleration so it's not yet ready for game development etc. It's quite possible that that'll change in the future though :) ) And for ascii graphics we have https://github.com/nsf/termbox-go https://github.com/nsf/termbox-go There are bunch of other libraries as well but these are the ones that I'm more or less constantly using. go.wde is probably closest to what you were looking for but also the one that still requires hardware acceleration before it can properly be used as fast canvas for experimenting with games etc. Note: None of these count as "standard library", all of them are third party projects by gophers around the world.
- zemo 14y agothere is none, just like there is none in Python. PyGame is not a standard library package. Did you install PyGame by hand, or did you use their installer? Internally, it actually has a lot of moving parts; not only does Go not have PyGame itself, it'll be a while before we even have the parts that PyGame requires to make something like it in Go. Python was nine years old by the time PyGame started, and it was another few years before it achieved traction; Go isn't nine years old now, so... it's not surprising that there's nothing quite like PyGame. We don't have that level of maturity with Go. Those things will likely come in time, but for now, that's a trade-off. Anyway, there are rumors that you can use OpenGL from Go, but I've never tried it. https://github.com/go-gl https://github.com/go-gl and if you really want graphics, why not use Processing, OpenFrameworks, Cinder, or one of the languages supported by Unity? Go tends to really shine for writing servers. Of course, you could always use Go to write a game server for a multiplayer PyGame game.
- JulienSchmidt 14y agoIt's called "net/http". It's cross-platform, has network-transparency and all that stuff. But you need a client called "browser" to view the graphics. A great example is hosted at http://tour.golang.org/ http://tour.golang.org/, which makes learning and playing around very easy.
- gillianseed 14y agoLike zemo said, pygame is not a standard 'graphics library', it's more like a game making framework which builds upon SDL (which is a low level graphics/input/sound library). There are Go-bindings for SDL but I haven't tried is myself so I can't vouch for it. I have done some tests using the Go open-gl and glfw bindings though, and I encountered no problems when using them. As for game frameworks, there's sadly nothing mature like pygame available, but I have seen a couple of such projects in development. One I came across recently and which also seems to be worked on in a regular fashion would be the GarageEngine, https://github.com/vova616/GarageEngine https://github.com/vova616/GarageEngine There are a couple of example videos on youtube: http://www.youtube.com/watch?v=iMMbf6SRb9Q http://www.youtube.com/watch?v=iMMbf6SRb9Q http://www.youtube.com/watch?v=BMRlY9dFVLg http://www.youtube.com/watch?v=BMRlY9dFVLg Like you I would love to have a game framework for Go in the style of pygame/flashpunk/flixel/löve etc, but I feel hopeful that this will arrive in due time as Go picks up users.