Commit Graph

9 Commits

Author SHA1 Message Date
David Crawshaw 2bbe618778 gl: fix build on OS X
Also add missing switch cases which cause a compiler warning on OS X.
They are unused so far.

Fixes golang/go#16071

Change-Id: I5ced5a814a7abc956b0b0cdad211ecd69a54a95b
Reviewed-on: https://go-review.googlesource.com/24177
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2016-06-16 22:06:45 +00:00
David Crawshaw 3919ffce20 gl: a few more ES 3.0 functions
Nothing exciting, just exercising the layout of the functions.

Change-Id: I460fdc1c9596968bbdfdafe7d068ea393e0029ed
Reviewed-on: https://go-review.googlesource.com/24051
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-06-15 17:57:41 +00:00
David Crawshaw b8e0f58304 gl: support for GL ES 3.0
This CL covers the basic structure for supporting ES 3.0 where the
platform provides it, and includes one ES 3.0 function as a
proof-of-concept. The rest of the functions and constant values will
follow in later CLs.

ES 3.0 is available everywhere except Android older than
version 4.3, approximately half of Android devices today:

https://developer.android.com/about/dashboards/index.html#OpenGL

Change-Id: Ief7714131227c447a0c603dadad0bd5285999bb3
Reviewed-on: https://go-review.googlesource.com/23821
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-06-09 14:35:26 +00:00
David Crawshaw 2b7eb78ade gl: factor cgo types out of gl.go
This allows a subsequent CL to introduce windows support by directly
calling an ANGLE dll.

For golang/go#9306

Change-Id: I7dbe8f2b77b9e2c744f0d848f716ee4448916fe7
Reviewed-on: https://go-review.googlesource.com/17674
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-12-14 14:29:55 +00:00
David Crawshaw 0081b7ad84 gl: compatibility with cgo pointer rules proposal
The current cgo proposal (golang/go#12416) is at:

https://github.com/golang/proposal/blob/master/design/12416-cgo-pointers.md

Maybe relevant to golang/go#12718

Change-Id: I5a399eec703ba3a793ab64d979bb73b083f23df9
Reviewed-on: https://go-review.googlesource.com/15100
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-09-29 13:55:20 +00:00
David Crawshaw 59ab51f73f gl: move to context methods
All OpenGL functions are now methods on a Context interface. The
gl.Context matches the one loaded into thread-local storage in C.

For mobile apps, the context is owned by an app.App. For now, it is
provided through the events channel on a lifecycle event. Long-term,
it should probably be available by a method on app.App, but this is
inherently racey with our current use of a channel to deliver events.

Shiny-based programs will have a gl.Context associated with a each
shiny.Window. The expectation is each Window will have different
contexts, allowing them to draw separately.

Change-Id: Ie09986fb74e493129f2ea542a151c95c6fa29812
Reviewed-on: https://go-review.googlesource.com/13431
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-09-23 23:46:16 +00:00
Hana Kim 49a82fefe3 all: support go get golang.org/x/mobile/... on Windows
Fixes golang/go#12212
Workaround for golang/go#12261 until golang/go#9306 is fixed.

Change-Id: I51c1bcfc92c1553fe2132586a0234b1c1af6aeb1
Reviewed-on: https://go-review.googlesource.com/13745
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-24 21:09:04 +00:00
Nigel Tao 42f0d17876 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>
2015-06-26 07:43:17 +00:00
David Crawshaw 068a51c195 gl: batch calls onto a dedicated context thread
All GL function calls fill out a C.struct_fnargs and drop it on the
work queue. The Start function drains the work queue and hands
over a batch of calls to C.process which runs them. This allows
multiple GL calls to be executed in a single cgo call.

A GL call is marked as blocking if it returns a value, or if it
takes a Go pointer. In this case the call will not return until
C.process sends a value on the retvalue channel.

Change-Id: I4c76b2a8ad55f57b0c98d200d0fb708d4634e042
Reviewed-on: https://go-review.googlesource.com/10452
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-01 15:35:03 +00:00