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>
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>
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>
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>
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.
Fixesgolang/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>
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.
Fixesgolang/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>
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>
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>
Windows bindings had few invalid bindings.
Debug type had a typo, making gldebug non-compilable.
Use consistently .c() for types.
Fixesgolang/go#23451
Change-Id: Ic9e68b1aafcd732dd5e4d8f883324723a35d24c3
Reviewed-on: https://go-review.googlesource.com/87855
Reviewed-by: Elias Naur <elias.naur@gmail.com>
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.
Fixesgolang/go#17075
Change-Id: Ic1a4ee72b313861e48fe3e1cfaec91c91da6ddb3
Reviewed-on: https://go-review.googlesource.com/53531
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Also add missing switch cases which cause a compiler warning on OS X.
They are unused so far.
Fixesgolang/go#16071
Change-Id: I5ced5a814a7abc956b0b0cdad211ecd69a54a95b
Reviewed-on: https://go-review.googlesource.com/24177
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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>
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.
Fixesgolang/go#16067
Change-Id: I56be73f373d9985c067a07e5084fa6b9f1ef76a0
Reviewed-on: https://go-review.googlesource.com/24140
Reviewed-by: David Crawshaw <crawshaw@golang.org>
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>
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.
Fixesgolang/go#14403
Change-Id: I11109c983316f5975a79f42dc51d7a180e222b91
Reviewed-on: https://go-review.googlesource.com/19703
Reviewed-by: David Crawshaw <crawshaw@golang.org>
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>
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>
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>
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>
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>
This means that if the OpenGL driver crashes, the stack trace will
contain a goroutine blocked in the function that caused the panic.
Fixesgolang/go#12786
Change-Id: I039c74f9e24de777b925475a50e8c96129692f70
Reviewed-on: https://go-review.googlesource.com/15160
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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>
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>
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>
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>
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>
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.
Resolvesgolang/go#10218 again.
Change-Id: I5b822235d9485701186a43dae0b9fd898cc6a3d8
Reviewed-on: https://go-review.googlesource.com/8166
Reviewed-by: David Crawshaw <crawshaw@golang.org>
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.
Resolvesgolang/go#10218.
Change-Id: Ib33dfff7c22c4d178b2e6b8d228f80f3c17308a8
Reviewed-on: https://go-review.googlesource.com/8000
Reviewed-by: David Crawshaw <crawshaw@golang.org>