app: use one thread for both GL and other UI C code.

This change will break Darwin. I have only built and tested this on
desktop linux and Android linux. A follow-up CL will fix Darwin.

Currently, OpenGL gets its own thread, and UI C code (e.g. the Android
event loop, or the X11 event loop) gets its own thread. This relies on
multiple system-provided UI-related C libraries working nicely together,
even when running on different threads. Keeping all the C code on the
one thread seems more sound.

As side-effects:
  - In package app/debug, DrawFPS now takes an explicit Config.
  - In package app, some callbacks now take an explicit Config.
  - In package exp/sprite, Render now takes an explicit Config.
  - In package event, there are new events (Config, Draw, Lifecycle),
    and an event filter mechanism to replace multiple app Callbacks.
  - In package geom, the deprecated Width, Height and PixelsPerPt global
    variables were removed in favor of an event.Config that is
    explicitly passed around (and does not require mutex-locking).
    Converting a geom.Pt to pixels now requires passing a pixelsPerPt.
  - In package gl, the Do, Start and Stop functions are removed, as well
    as the need to call Start in its own goroutine. There is no longer a
    separate GL thread. Instead, package app explicitly performs any GL
    work (gl.DoWork) when some is available (gl.WorkAvailable).
  - In package gl/glutil, Image.Draw now takes an explicit Config.

Callbacks are no longer executed on 'the UI thread'.

Changing the app programming model from callbacks to events (since a
channel of events works with select) will be a follow-up change.

Change-Id: Id9865cd9ee1c45a98c613e9021a63c17226a64b1
Reviewed-on: https://go-review.googlesource.com/11351
Reviewed-by: David Crawshaw <crawshaw@golang.org>
26 files changed
tree: 6e2bb01b0bcf1fd41e7a873ff51b2a3b42ae5db7
  1. app/
  2. bind/
  3. cmd/
  4. event/
  5. example/
  6. exp/
  7. f32/
  8. geom/
  9. gl/
  10. testdata/
  11. .gitattributes
  12. .gitignore
  13. AUTHORS
  14. codereview.cfg
  15. CONTRIBUTING.md
  16. CONTRIBUTORS
  17. Dockerfile
  18. LICENSE
  19. PATENTS
  20. README.md
README.md

Go support for Mobile devices

The Go mobile repository holds packages and build tools for using Go on Android.

This is early work and installing the build system requires Go 1.5. Follow the build instructions on godoc.org/golang.org/x/mobile/cmd/gomobile to install the gomobile command and build the basic example.


APIs are currently very limited, but under active development. Package documentation serves as a starting point:


Contributions to Go are appreciated. See https://golang.org/doc/contribute.html.