Commit Graph

35 Commits

Author SHA1 Message Date
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
David Crawshaw c0dc93779f gl/glutil: context is only for desktop darwin
Only used in package tests that are only
supported on OS X / linux (for now).

Change-Id: I9708cd370ccf52c231d66dec9ccc1c06b45f4acd
Reviewed-on: https://go-review.googlesource.com/5490
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-02-21 01:04:00 +00:00
David Crawshaw 25e80f6a77 gl: build on darwin/arm
Change-Id: I9962d49a4e620fb734bc218ebfa558336ade8e06
Reviewed-on: https://go-review.googlesource.com/5200
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-02-19 15:56:40 +00:00
Michael Matloob 4c31c789d7 gl: fix func name in doc comment for GetRenderbufferParameteri
Also s/bufer/buffer/ in comment for VertexAttribPointer.

Change-Id: Icb2ce35e4fed91939ebd00012e5caf88453fcbbf
Reviewed-on: https://go-review.googlesource.com/3959
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-02-06 09:33:13 +00:00
Hyang-Ah Hana Kim 90d6854261 mobile: add extra build tags.
missing ones from https://go-review.googlesource.com/#/c/2902/

Change-Id: If42f9e53bdd7be468315ad746ba35d397a874ee6
Reviewed-on: https://go-review.googlesource.com/2965
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-01-20 15:15:48 +00:00
Hyang-Ah Hana Kim a8fcf739b9 mobile: limit app/font/gl packages to linux/darwin.
They don't make sense for other platforms yet.

See golang/go#9603

Change-Id: I2ed269a00b1e1961aadf0a47fc95bbe3cd230113
Reviewed-on: https://go-review.googlesource.com/2902
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-01-15 20:16:28 +00:00
David Crawshaw e8bfa872c4 gl: use Uniform type for consistency
Change-Id: I90a813c0823498297ff0bb7718bee6cd61b87581
Reviewed-on: https://go-review.googlesource.com/1517
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-15 17:53:49 +00:00
David Crawshaw 4ab8f01b53 gl: fix documentation URL
Change-Id: I73a6d37ecc1827fa65c94cd6d743874785f7e93a
Reviewed-on: https://go-review.googlesource.com/1374
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-11 21:20:01 +00:00
David Symonds 7b659348a5 mobile: add import comments.
Change-Id: I0ff6d42a8e11f49df6fc3066e86be75015b93631
Reviewed-on: https://go-review.googlesource.com/1238
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-10 01:59:04 +00:00
Hana (Hyang-Ah) Kim daf6d8060b gl: use go generate to generate gldebug.go by invoking gendebug.go
Change-Id: I7d682d153da5b200f9dd5cea8d09d76935daa18c
Reviewed-on: https://go-review.googlesource.com/1225
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2014-12-09 17:31:03 +00:00
David Crawshaw 81f7d26930 gl: regen gldebug.go and stop logging on glBoolean
Change-Id: Icad6cb694b31924164483609e0fd9c7cce8e3f0d
Reviewed-on: https://go-review.googlesource.com/1185
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-08 23:39:28 +00:00
David Crawshaw 23d89f24b5 gl: merge gl_linux.go and gl_darwin.go
C changes the types silently, so there's no need for the code to be
different (beyond the standard header ifdef boilerplate).

Change-Id: I0eddb5fa050c083cdac9db499634bf3d1bb9bb04
Reviewed-on: https://go-review.googlesource.com/1184
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-08 21:38:56 +00:00
David Crawshaw 410ed12d25 gl: convert Glclampf to GLfloat in C to avoid variations between GL headers
Change-Id: I2ff85d2b4529fc12e08404c93266b827dd88b8ef
Reviewed-on: https://go-review.googlesource.com/1183
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-08 20:15:17 +00:00
David Crawshaw 5875cc8cf7 x/mobile/go: remove GLES2 headers
LGTM=nigeltao
R=rsc, nigeltao
CC=golang-codereviews
https://golang.org/cl/174590043
2014-12-05 10:14:12 -05:00
Shenghou Ma f456aa415e go.mobile/gl: fix typos.
Fixes golang/go#9151.

LGTM=crawshaw
R=crawshaw, nathan.behary
CC=golang-codereviews
https://golang.org/cl/180160043
2014-11-23 17:42:30 -05:00
Andrew Gerrand 9470e0ba58 go.mobile: use golang.org/x/... import paths
LGTM=bradfitz, rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/162710043
2014-11-10 08:55:57 +11:00
Nigel Tao 3e603f3a38 go.mobile/gl/glutil: enable glimage_test on linux/X11.
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/167020043
2014-11-03 10:31:19 +11:00
David Crawshaw b208e914e7 go.mobile/gl/glutil: take advantage of new degree of freedom in test
LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/166030043
2014-11-01 07:48:07 -04:00
Nigel Tao 970a0a0162 go.mobile/gl/glutil: let Image.Draw draw non-axis-aligned quads.
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/160710043
2014-10-31 14:32:34 +11:00
David Crawshaw 0ac70a3835 go.mobile/gl/glutil, go.mobile/app/debug: create glimage with pixel size
LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/165940043
2014-10-30 19:43:51 -04:00
David Crawshaw fd18e8dcec go.mobile/gl/glutil: correct image size and switch to testpattern.png
LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/167910043
2014-10-30 17:30:38 -04:00
David Crawshaw 897e5be307 go.mobile/gl/glutil: use correct image bounds in translation
I have included the gl.LINEAR bugfix here as it changes the
images substantially.

Based on Nigel's excellent analysis in cl/160710043.

LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/168820043
2014-10-30 17:26:23 -04:00
Nigel Tao 2457abfa93 go.mobile/f32: add a f32.Bytes function.
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/166720044
2014-10-29 09:19:38 +11:00
Nigel Tao 3aced57cb0 go.mobile/gl/glutil: use a triangle strip instead of two triangles.
It's not a big deal in this case, but we'll probably want to do the same
for the sprite/gl package.

LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/163990043
2014-10-28 10:55:58 +11:00
Nigel Tao fab1e51609 go.mobile/geom: rename Scale to PixelsPerPt.
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/160160043
2014-10-22 13:50:04 +11:00
David Crawshaw 17b03aaff9 go.mobile: a test for glutil.Image
LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/152420043
2014-10-12 18:01:54 -07:00
David Crawshaw 8a5f40b7b3 go.mobile: move glimage to glutil package and export
Drawing now supports defining both the source and destination
bounds, which is equivalent to clipping and scaling an image.

LGTM=nigeltao
R=nigeltao, crawshaw
CC=adg, golang-codereviews
https://golang.org/cl/144480043
2014-10-12 17:58:22 -07:00
Nigel Tao 4f42fa989e go.mobile/gl: use column major ordering.
Also rename some files:
types.go      -> types_prod.go
typesdebug.go -> types_debug.go
(new file)       types_common.go

In discussing https://golang.org/cl/144480043/ crawshaw said:

The third argument to glUniformMatrix* is "transpose." According to the
linked documentation, which is usually better:

"If transpose is GL_FALSE, each matrix is assumed to be supplied in
column major order. If transpose is GL_TRUE, each matrix is assumed to
be supplied in row major order."

However, the documentation for OpenGL ES 2 doesn't bother even telling
you, it just says that this parameter must always be set to GL_FALSE. So
it's not supported on most Android devices. (Sadly the older
documentation appears to have been discontinued.)

So yes, GL seems to default to column-major, and the older GLES2 I'm
targeting left the transpose argument in but doesn't support it. Hence
I'm not exposing it through this API.

LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/148690043
2014-10-09 14:00:00 +11:00
David Crawshaw b1ea4eba37 go.mobile/gl: f32 utilities and extra debugging
Split constants out into their own file. Hide the
values in named types in a struct, so that when
using the gldebug tag we can attach extra
information (such as the name of a uniform and
attribute).

LGTM=nigeltao
R=golang-codereviews, bryanturley, nigeltao
CC=davidday, golang-codereviews
https://golang.org/cl/137630043
2014-09-17 18:07:50 -04:00
David Crawshaw 1d1714ebe9 go.mobile/gl/glutil: OpenGL utilities package
No tests yet. I am working on a gltest package that can
create a windowless context on a variety of platforms for
testing GL code, but given current priorities it is a
couple of weeks away.

LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/135450043
2014-09-05 14:02:43 -04:00
David Crawshaw 6acad32cab go.mobile/gl: import OpenGL 2 ES headers
Various versions of these headers cause harmless (but frustrating)
compile errors, e.g. *C.char being swapped out in some function
definitions for *C.uchar. To simplify builds, importing the
headers from khronos.org.

LGTM=nigeltao
R=golang-codereviews, nigeltao
CC=golang-codereviews
https://golang.org/cl/127020043
2014-09-03 09:03:42 -04:00
David Crawshaw 3bd69d3fcc go.mobile/gl: tracing debug mode
Compiling a binary with "-tags gldebug" will add log
tracing to each GL function call. This is the best I
can offer in lieu of of real error handling.

A colleague has accused me of Aspect-oriented
programming. The wikipedia article on the topic lost
me in the first paragraph, so just for the record,
this was inspired by the way the cover tool rewrites
source code.

LGTM=sameer
R=golang-codereviews, sameer
CC=golang-codereviews
https://golang.org/cl/128640043
2014-08-26 10:03:00 -04:00
David Crawshaw 0394fdc6fe go.mobile/gl: OpenGL ES 2 bindings
A new set of bindings, as none of the existing open source
ones meet all the desired criteria:

- just ES 2/3, no deprecated/wider interfaces
- no hiding of GL functions behind higher-level interfaces
- no exported use of C types
- no other library dependencies
- no exported use of unsafe.Pointer
- use Go slices for passing arrays

Function stubs were generated from the gl.xml spec file,
however there were enough special cases (and few enough
functions in the ES spec) that it was easier to construct
most of this file by hand rather than complete a generator
script. So it is not included in this CL.

LGTM=adg
R=golang-codereviews, bryanturley, adg, capnm9
CC=golang-codereviews
https://golang.org/cl/127870043
2014-08-25 08:17:08 -04:00