Support functions for gl in golang.org/x/mobile/

418 views
Skip to first unread message

Sri Gogineni

unread,
May 7, 2015, 3:30:24 PM5/7/15
to golan...@googlegroups.com
Hi Gophers,

I'm pretty excited about writing Android apps in Go, especially with the ability to leverage OpenGL ES! 

While working on the Android graphics tutorials, I noticed some functions which greatly ease development like Matrix manipulations (e.g. android.opengl.Matrix.*) and camera perspective helper functions (OpenGL GLUT documentation for gluLookAt) are not readily available, to my knowledge, in Go. Where would be the appropriate place to add these functions?

David Crawshaw

unread,
May 7, 2015, 5:05:09 PM5/7/15
to Sri Gogineni, golan...@googlegroups.com
There's a lot of useful tools in http://github.com/go-gl, some of
which is compatible with Android. Check out the mathgl package.
> --
> You received this message because you are subscribed to the Google Groups
> "golang-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-dev+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Sri Gogineni

unread,
May 10, 2015, 5:09:47 PM5/10/15
to golan...@googlegroups.com, sriakhil...@gmail.com
Thanks David! I'll take a deeper look at those libraries.

I'm also playing around with EGL on Android 4.4. With the current toolchain, I was able to access EGL functionality by adding:

/*
#include <EGL/egl.h>
#include <EGL/eglplatform.h>
#cgo LDFLAGS: -lEGL
*/

import "C"


and an example function:

/*
  eglQueryString(eglGetCurrentDisplay(), EGLint)

  VENDOR      = 0x3053
  VERSION     = 0x3054
  EXTENSIONS  = 0x3055
  CLIENT_APIS = 0x308D
*/

func eglGetQueryString
(name int32) string {
 
return C.GoString(C.eglQueryString(C.eglGetCurrentDisplay(), C.EGLint(name)))
}

Although this works, it doesn't seem idiomatic at all. Will EGL be included in /x/mobile/egl ?

Nigel Tao

unread,
May 10, 2015, 8:32:41 PM5/10/15
to Sri Gogineni, golang-dev
On Mon, May 11, 2015 at 7:09 AM, Sri Gogineni
<sriakhil...@gmail.com> wrote:
> Will EGL be included in /x/mobile/egl ?

crawshaw is the person to ask, but he's on vacation right now.

My guess is that the answer is no, and that we're aiming to offer
something a lot more focused than wrapping the entirety of all the
numerous *GL* C APIs.

Sri Gogineni

unread,
Jun 18, 2015, 5:16:47 PM6/18/15
to golan...@googlegroups.com, sriakhil...@gmail.com
Go coverage of the EGL API allows for obtaining a native window/surface without having to call out to EGL C code. This increases portability and allows for a complete OpenGL ES application to be built entirely in Go.

David Crawshaw

unread,
Jun 18, 2015, 8:28:41 PM6/18/15
to Sri Gogineni, golan...@googlegroups.com
EGL only works on Android. A goal of the x/mobile packages is to be
portable across different mobile devices, so the x/mobile/app package
uses EGL on Android but does not expose it directly.

I think there is a place for a good Go EGL binding, but I don't think
it's in the x/mobile repository.

Anthony Starks

unread,
Jun 19, 2015, 11:18:23 AM6/19/15
to golan...@googlegroups.com, sriakhil...@gmail.com
What is your opinion on devices like the Raspberry Pi, which includes EGL?
Should x/mobile support these kind of devices which tend to have mobile-style GPUs and libraries?

David Crawshaw

unread,
Jun 19, 2015, 11:29:08 AM6/19/15
to Anthony Starks, golan...@googlegroups.com, Sri Gogineni
My only use of a Raspberry Pi was early in its life, running a
headless debian install, so I'm sure EGL wouldn't work there. If there
is a standard Raspberry Pi distribution today that by default uses
EGL, I think it would be reasonable to make the x/mobile/app package
run on it.

Though I do not yet have the mobile sub-repository running
continuously on build.golang.org, which makes it hard to even keep our
current environments building. I would like to see x/mobile trybots
for OS X, linux/x11, android, and iOS before adding more build
configurations.

Anthony Starks

unread,
Jun 19, 2015, 1:20:55 PM6/19/15
to golan...@googlegroups.com, sriakhil...@gmail.com, ajst...@gmail.com


On Friday, June 19, 2015 at 11:29:08 AM UTC-4, David Crawshaw wrote:
My only use of a Raspberry Pi was early in its life, running a
headless debian install, so I'm sure EGL wouldn't work there. If there
is a standard Raspberry Pi distribution today that by default uses
EGL, I think it would be reasonable to make the x/mobile/app package
run on it.

That's good news.  FYI, https://github.com/ajstarks/openvg has a Go wrapper for OpenVG which uses a bit of EGL 
Reply all
Reply to author
Forward
0 new messages