Commit Graph

82 Commits

Author SHA1 Message Date
Russ Cox ce6a79cf6a all: gofmt
Gofmt to update doc comments to the new formatting.

For golang/go#51082.

Change-Id: I9b4c287e2d25aa108adfa9fe2f972c8fd3d68fe1
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/399597
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
2022-04-14 15:34:00 +00:00
Hajime Hoshi 4a8be17bd2 all: add go:build comments for .m and .c files
Change-Id: I24fbde8ec50be43000b9fcf3e7801f1ad25238cb
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/374498
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-01-04 18:42:38 +00:00
Hajime Hoshi 5579029ea0 all: add -DGLES_SILENCE_DEPRECATION instead of #define
Defining GLES_SILENCE_DEPRECATION did not take any effects. Use -D
instead.

Change-Id: I9c0602b38d39020b9539fdb8030fef3a7b366929
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/374499
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-01-04 18:42:24 +00:00
Hajime Hoshi cde37c62e1 all: add GLES_SILENCE_DEPRECATION to suppress warnings
Change-Id: I8544e7cd8c4e3d2b71fd1850f7043eabe25231d0
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/374497
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-01-04 17:11:26 +00:00
Russ Cox bdb1ca9a1e all: go fmt ./...
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).

Not strictly necessary but will avoid spurious changes
as files are edited.

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Change-Id: I30822eb504168b037ed3ec0f7759da1f41251f52
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/294374
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-20 03:30:13 +00:00
Dmitri Shuralyov e6ae53a27f gl: add darwin/arm64 (macOS) support
Update the build constraints so that OpenGL is used both on
macOS AMD64 and ARM64, while OpenGL ES is used on iOS.
This fixes the build on M1 Macs.

For golang/go#43237.

Change-Id: Iad2d406eaf0ddbe72f221f497dd074ad0b22015e
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/278779
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
2020-12-17 15:07:44 +00:00
Hajime Hoshi 0c13fd3166 gl: enable use of buffer objects for TexSubImage2D by nil
This CL enables use of a bound buffer at TexSubImage2D by allowing
nil (0) data, which indicates the head of the bound buffer.

In the long run, we need to be able to pass non-0 integer to not
only TexSubImage2D but also other functions like TexImage2D. As we
might change the API, let's revisit this issue later.

Fixes golang/go#36355

Change-Id: I66f6650b10fca9a346cfa6eba246ea9286ed3a85
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/213077
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-01-19 07:00:23 +00:00
Nigel Tao d2bd2a29d0 gl: provide dummy impl when cgo is disabled
The dummy implementation doesn't do anything (at runtime), but it does
compile (when CGO_ENABLED=0), which e.g. unbreaks some build bots.

The work_other.go file is new, faking what's in work.go.

The changes to the other (existing) files simply re-order the
GOOS-related build constraints to be in a consistent order (alphabetical
order), the same as the existing order in work.go.

Fixes golang/go#32837

Change-Id: I19a196d4307b9ebc2f770fe41e1aec717a699288
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/185017
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2019-07-19 00:42:57 +00:00
Elias Naur 874a4fb9cd app,exp,gl: fix build
Ignore deprecation warning for OpenGL and replace deprecated enum
names.

Change-Id: Ie07c566f1b28610add074dc4da8ab66399cef94b
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/165578
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-06 14:40:52 +00:00
Elias Naur 0ff817254b gl: add internalFormat to TexImage2D
The OpenGL C function glTexImage2D has the following signature:

void glTexImage2D(GLenum target,
 	GLint level,
 	GLint internalFormat,
 	GLsizei width,
 	GLsizei height,
 	GLint border,
 	GLenum format,
 	GLenum type,
 	const GLvoid * data);

However, the corresponding Context.TexImage2D method in package gl
does not include the internalFormat parameter, and use the format
argument instead. That's ok for many texture formats; for example,
RGBA textures have both format and internalFormat set to GL_RGBA.
But not always. In particular, OpenGL ES 3 allows the use of sRGB
encoded textures by specifying GL_SRGB8_ALPHA8 as internalFormat,
but keeping GL_RGBA as format.

Add the internalFormat to the Context package. This is unfortunately
a breaking change, but adding a new function ("glTexImage2D2"?) to
Context is too ugly for a parameter that should have been there all
along. (Adding a new method to the Context interface is technically
also a breaking change, but I don't expect that there are any
external implementers of the interface).

Change-Id: I12a45a34f604e51cb1be26aed906025ccfac533a
Reviewed-on: https://go-review.googlesource.com/133155
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-09-07 22:41:11 +00:00
Elias Naur 9422505f13 gl: remove duplicate build tag
Change-Id: I7dcb0b3b946cfae86eb6eed509ad96543213c409
Reviewed-on: https://go-review.googlesource.com/108335
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-19 21:32:52 +00:00
Elias Naur bcd28df570 all: fix non-standard "DO NOT EDIT" comments for generated files
In the spirit of CL 99955, fix all non-standard generated code
headers and re-run the generators. Some generated files needed
git gofmt afterwards, but that problem is left for now.

Change-Id: I6b3131fb1753dc427d05af03107031120755cab0
Reviewed-on: https://go-review.googlesource.com/99975
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-14 14:08:28 +00:00
Egon Elbre 64951f83ad gl: fix typos in multiple places
Windows bindings had few invalid bindings.
Debug type had a typo, making gldebug non-compilable.
Use consistently .c() for types.

Fixes golang/go#23451

Change-Id: Ic9e68b1aafcd732dd5e4d8f883324723a35d24c3
Reviewed-on: https://go-review.googlesource.com/87855
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2018-01-17 09:46:58 +00:00
Sergiusz Bazanski b28c5379a5 gl: add OpenBSD support
This is the same as https://go-review.googlesource.com/c/exp/+/79917, but applied to the mobile project.

Change-Id: I77c7455317aaf09da8fbeaf943c14a2dab9da735
Reviewed-on: https://go-review.googlesource.com/79896
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-26 19:47:19 +00:00
Alexandre Parentea e095d655c7 gl: support (Create|Bind|Delete)VertexArray for GL ES 3
Change-Id: Ief6b7f4ab2450d7f1c3b961b19304b10b3680abd
Reviewed-on: https://go-review.googlesource.com/61370
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-09-10 23:20:06 +00:00
pankona 448c916b90 x/mobile/gl: fix building if gldebug tag is specified
in gldebug.go, Enum value TIMEOUT_IGNORED requires uint64 length
to handle it. On the other hand, Enum is declared as uint32, it causes
build error because of overflow.

Since GL_TIMEOUT_IGNORED is not a kind of GLenum, it should not be
listed in that switch statement. Introduce white list for available
Enum value to exclude such variables they cannot be classified as Enum
because of its variable length.

Fixes golang/go#17075

Change-Id: Ic1a4ee72b313861e48fe3e1cfaec91c91da6ddb3
Reviewed-on: https://go-review.googlesource.com/53531
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2017-08-09 07:17:13 +00:00
Egon Elbre d3620154ae x/mobile/gl: fix building on windows/386
Fixes golang/go#15763

Change-Id: Iead7d69367ee5c821aefd1faed56bb3b259b6a62
Reviewed-on: https://go-review.googlesource.com/32113
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-26 17:46:18 +00:00
Egon Elbre 91c29e2bb7 x/mobile/gl: fix windows context3 and dlls
Add missing context3 for Windows.
Add missing d3dcompiler_47.dll loading.
Check whether dll architecture matches.
Search ANGLE from Chrome path.

Fixes golang/go#16991

Change-Id: Ia042f75241c2398fabda03bb2d0e683eb34545c7
Reviewed-on: https://go-review.googlesource.com/28814
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2016-10-13 20:58:55 +00:00
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 4409fe621c gl: ES 3.0 constants
Change-Id: I3d2335948e88c21aa7da7c5d022da59f7fcbddc5
Reviewed-on: https://go-review.googlesource.com/24073
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-06-15 15:09:55 +00:00
Hajime Hoshi d5e078356c x/mobile/gl: Fix macro definitions for iOS
Now `gomobile bind -target ios` tries to compile a lib with
`darwin/arm`, `darwin/arm64`, and `darwin/amd64`. In the last
case, a tag `ios` is always added. In `x/mobile/gl`, the last case
`darwin/arm64` was not considered well and causes a compile error.
This CL fixes this compile error.

Fixes golang/go#16067

Change-Id: I56be73f373d9985c067a07e5084fa6b9f1ef76a0
Reviewed-on: https://go-review.googlesource.com/24140
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-15 15:09:20 +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
Hajime Hoshi c1fbaaac1c x/mobile/gl: Fix arguments passed to glBufferData from BufferInit
Before this CL, BufferInit always causes INVALID_ENUM error because
0 (a2) is always passed to 'usage' argument of glBufferData.

This CL fixes removes a2, shifts a3 to a2, and adds parg as null
pointer explicitly.

Fixes golang/go#14403

Change-Id: I11109c983316f5975a79f42dc51d7a180e222b91
Reviewed-on: https://go-review.googlesource.com/19703
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-20 03:02:31 +00:00
David Crawshaw 54b4a066d7 gl: add a comment for linux installation
OpenGL ES is not installed by default on linux distributions, which
can lead to a cryptic error. Add a comment after the #include
mentioning what packages contain OpenGL ES on Ubuntu, which is
helpfully printed in the error message. For example:

	$ go build golang.org/x/mobile/example/basic
	# golang.org/x/mobile/gl
	In file included from ../../mobile/gl/work.go:21:0:
	work.h:6:117: fatal error: GLES2/gl2.h: No such file or directory
	 #include <GLES2/gl2.h> // install on Ubuntu with: sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev libx11-dev

Change-Id: Ia7ba583cee4dfdeed408f582b29da90de9a4fab3
Reviewed-on: https://go-review.googlesource.com/18058
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2016-01-07 20:14:32 +00:00
David Crawshaw 2f30cbe53f gl: regenerate gldebug.go
Change-Id: Ifbc2664ee531fc3894e1ccdca314a00aef247e9d
Reviewed-on: https://go-review.googlesource.com/17864
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-12-18 20:31:45 +00:00
Alex Brainman a91f1aade3 x/mobile/gl: include textflag.h in work_windows_amd64.s
Fixes golang/go#13649

Change-Id: Ic552c74489e6aa11c0d2316073f623e2936d608d
Reviewed-on: https://go-review.googlesource.com/17922
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-12-17 17:59:11 +00:00
David Crawshaw 6da7fa8e54 gl: download ANGLE if necessary
For golang/go#9306

Change-Id: Ibb469d843d2bddeaa3690c59bc9ad532ea3473f7
Reviewed-on: https://go-review.googlesource.com/17810
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-12-15 16:29:01 +00:00
David Crawshaw 2fe199687c gl: fix build
Change-Id: If3888b1795ca4c701f99e2021bcac4e860f96b7b
Reviewed-on: https://go-review.googlesource.com/17774
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-12-14 15:28:16 +00:00
David Crawshaw 576c75e780 gl: remove data race on cStrings
Each GL context is used serially, so make the map context-specific.

For golang/go#9306

Change-Id: Ic8261795312bf404f765a9ae8969468f4d170dae
Reviewed-on: https://go-review.googlesource.com/17772
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-12-14 15:24:25 +00:00
David Crawshaw 8851c9af31 gl: add windows implementation based on ANGLE
ANGLE is an open source project that implements OpenGL ES on top of
DirectX. It is used by Chrome to implement WebGL:

	https://github.com/google/angle

It can be compiled into libGLESv2.dll/libEGL.dll and used directly
from Go. This CL includes the changes necessary to the gl package
to use ANGLE.

For the EGL changes, I intend to get x/exp/shiny/driver/gldriver
working, and then make x/mobile/app use it when compiling for
GOOS=windows. (The dependency on shiny's screen package will only
hold when building for desktop OSs.)

For golang/go#9306

Change-Id: I01cb39bc8b56547584b7992eab437bd7ed0312b5
Reviewed-on: https://go-review.googlesource.com/17675
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-12-14 15:00:07 +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 48637192de gl: fix comment, simplify queue capacity
Change-Id: I24f4cc3267c8db117a2c9551c5236fa2453da9f3
Reviewed-on: https://go-review.googlesource.com/15393
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-10-05 21:06:53 +00:00
David Crawshaw 27e7ed5775 gl: check for concurrent use of a gl.Context
It is an error to use a gl.Context concurrently. (Each Context
contains a state machine, so there is no way this can work.)
Up until now only the GL driver could report such a misuse, and
it generally does a poor job of it. Our command buffer adds some
small oppertunity for the race detector to help, but it makes it
harder to debug other kinds of driver crashes, so it is worth
disabling in debug mode.

To make it easy, compiling with -tags gldebug now inserts an
explicit check that there are no other active GL calls outstanding.

Adding something like:

	go func() {
		for {
			glctx.GetInteger(gl.ALPHA_BITS)
		}
	}()

to x/mobile/example/basic now reliably crashes when compiled
with -tags gldebug, providing a stack trace that includes both
misbehaving goroutines.

Change-Id: I3d85d94220bca2a15eaf2742f13b44db1f3428bf
Reviewed-on: https://go-review.googlesource.com/15180
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-09-30 15:23:41 +00:00
David Crawshaw aacc7aa5ab gl: mark all functions as blocking in debug mode
This means that if the OpenGL driver crashes, the stack trace will
contain a goroutine blocked in the function that caused the panic.

Fixes golang/go#12786

Change-Id: I039c74f9e24de777b925475a50e8c96129692f70
Reviewed-on: https://go-review.googlesource.com/15160
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-09-30 12:17:57 +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
Nigel Tao 338d60c30b gl: fix a comment typo.
Change-Id: Ib87232f67bd38ad5b7dbec5c0862ff244bdec5b0
Reviewed-on: https://go-review.googlesource.com/14930
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-24 01:48:26 +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
David Crawshaw ea3ef0580c gl: handle zero length in GetAttachedShaders
Fixes golang/go#11980

Change-Id: I914234bfd3c39e2832db49d8f389305d919e6045
Reviewed-on: https://go-review.googlesource.com/13090
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-10 17:41:14 +00:00
Hyang-Ah (Hana) Kim 68f31e14ae mobile: limit build to linux/darwin.
Change-Id: I99f3841742e8f2ea098cfb08e8f5575c84f7cf75
Reviewed-on: https://go-review.googlesource.com/12850
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-29 20:28:35 +00:00
Nigel Tao bd8fa0d7bb gl/glutil: move to exp/gl/glutil.
Change-Id: I310c365300cb3fbf8a1abb630e26661fa7ef4844
Reviewed-on: https://go-review.googlesource.com/11824
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-01 11:41:50 +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
Nigel Tao 0dbccd26eb gl: delete an unused global variable.
Change-Id: I0591a27da24a5d7eca9055db5960164eae42dfcd
Reviewed-on: https://go-review.googlesource.com/11476
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-26 01:22:12 +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
David Crawshaw d2634ce9c5 gl: darwin/arm64 support
Conflicts with cl/10396. I'll submit this first and update the it.

Change-Id: Ibc873b3fe896ecd2415a42676614807788a8d1c6
Reviewed-on: https://go-review.googlesource.com/10399
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-28 18:21:31 +00:00
Nigel Tao 7c723a6596 gl/glutil: fix TestImage.
The start/stop functions were introduced in
https://go-review.googlesource.com/#/c/9879/

Change-Id: I7aafadcbe78b60bb512c2de05f3f992e47f0df6e
Reviewed-on: https://go-review.googlesource.com/10372
Reviewed-by: Dmitri Shuralyov <shurcool@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-22 11:30:56 +00:00
David Crawshaw 73e04c3da0 gl/glutil: manage GL textures across start/stop
Change-Id: I574f9ea8ab8138c769be19df8b1e86a7fbe544a8
Reviewed-on: https://go-review.googlesource.com/9879
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-05-20 12:05:26 +00:00
Dmitri Shuralyov a01c060faa gl: Improve API signatures to match spec, improve docs.
Reorder DrawElements arguments to match OpenGL spec order:
    DrawElements(mode, ty, offset, count) -> (mode, count, ty, offset)
GetActiveAttrib, GetActiveUniform are defined by spec to accept
corresponding integer _index_, not location type. Change their
signature to do that:
    GetActiveAttrib(p Program, a Attrib) -> (p Program, index uint32)
    GetActiveUniform(p Program, u Uniform) -> (p Program, index uint32)
Clarify and make documentation, parameter names more clear for Uniform
(uniform location), Attrib (attribute location) types,
EnableVertexAttribArray, DisableVertexAttribArray, GetAttribLocation,
GetUniformLocation funcs.
Resolves golang/go#10218 again.

Change-Id: I5b822235d9485701186a43dae0b9fd898cc6a3d8
Reviewed-on: https://go-review.googlesource.com/8166
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-30 19:58:17 +00:00
Dmitri Shuralyov eaba00bca5 gl: use better spec-defined func names, fix bug, increase consistency
Change func names and parameter order to more closely follow OpenGL
ES/WebGL spec.
    BufferData(target, usage, src) -> BufferData(target, src, usage)
    GenBuffer -> CreateBuffer
    GenFramebuffer -> CreateFramebuffer
    GenRenderbuffer -> CreateRenderbuffer
    GenTexture -> CreateTexture
Fix issue where glBoolean helper was returning inverted result.
Make Attrib.String() logic consistent with others (print value, not
struct).
Make internal code of GetUniformLocation the same as GetAttribLocation
and BindAttribLocation for consistency.
Resolves golang/go#10218.

Change-Id: Ib33dfff7c22c4d178b2e6b8d228f80f3c17308a8
Reviewed-on: https://go-review.googlesource.com/8000
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-25 21:38:11 +00:00