remogatto / mandala

A Go framework for writing native Android applications
MIT License
620 stars 50 forks source link

Support for OpenGLES3 ? #10

Open tbruyelle opened 10 years ago

tbruyelle commented 10 years ago

Hi Andrea,

I currently have a desktop application coded under OpenGL3 [1], and I want to embed it into Mandala [2]. Because the desktop version is based on go-gl/gl, I couldn't use remogatto/opengles2, there was too much changes. So I cloned go-gl/gl and hardly delete the code that doesn't exist in the OpenGLES implementation. I tried first to compile under OpenGLES2 but I finally get stuck because of missing methods about vertex arrays (glBindVertexArray etc...). Indeed those methods are only here since OpenGLES3. So I switched to OpenGLES3 but I still have compilation errors about the same methods.

Si I wonder if Mandala can support OpenGLES3 ?

[1] https://github.com/tbruyelle/gostuff/tree/opengl3/games/mozaik [2] https://github.com/tbruyelle/mozaik

remogatto commented 10 years ago

Is OpenGLES3 widely supported on Android devices?

http://developer.android.com/guide/topics/graphics/opengl.html

This doesn't answer to your specific question... but just wondering before thinking of a possible solution.

tbruyelle commented 10 years ago

Yes I know that, and that's a problem. But currently I'm focusing on running my app on an android device, regardless a wide support.

By the way, I noticed the vertex arrays methods are declared in gl2ext.h, with the OES suffix. So normally I should be able to use OpenGLES2 within my app. But :

$ gotask build android --flags "-a"
# github.com/tbruyelle/gl
/home/tom/android-ndk-r9d/ndk-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: $WORK/github.com/tbruyelle/gl/_obj/vertexarray.cgo2.o: in function _cgo_c921059ada17_Cfunc_glBindVertexArrayOES:/home/tom/go/src/github.com/tbruyelle/gl/vertexarray.go:36: error: undefined reference to 'glBindVertexArrayOES'
/home/tom/android-ndk-r9d/ndk-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: $WORK/github.com/tbruyelle/gl/_obj/vertexarray.cgo2.o: in function _cgo_c921059ada17_Cfunc_glDeleteVertexArraysOES:/home/tom/go/src/github.com/tbruyelle/gl/vertexarray.go:46: error: undefined reference to 'glDeleteVertexArraysOES'
/home/tom/android-ndk-r9d/ndk-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: $WORK/github.com/tbruyelle/gl/_obj/vertexarray.cgo2.o: in function _cgo_c921059ada17_Cfunc_glGenVertexArraysOES:/home/tom/go/src/github.com/tbruyelle/gl/vertexarray.go:56: error: undefined reference to 'glGenVertexArraysOES'
collect2: ld returned 1 exit status
exit status 2
cp: cannot stat ‘bin/linux_arm/myapp’: No such file or directory
exit status 1
cp: cannot stat ‘bin/linux_arm/myapp’: No such file or directory
exit status 1
FAIL        Build the application for the given platforms.
2014/06/03 16:30:21 exit status 1

If you try to reproduce the result, the repo tbruyelle/gl has 2 branches : opengles2 and opengles3, so you can switch from one to another. In the opengles2 branch, the vertex arrays methods are declared with the OES suffix.

remogatto commented 10 years ago

Any chance to replace glBindVertexArray with something else?

tbruyelle commented 10 years ago

Well I'm an OpenGL noob and I don't know how I can replace the usage of vao. The only place where I use it is here. It's a common method which is invoked by all my objects.

BTW, do you know why the project doesn't compile even if I switch to OpenGLES2 and replace the vertex array methods by their OES extension version ?

remogatto commented 10 years ago

Google says this:

https://www.google.it/#q=android+ndk+glBindVertexArrayOES

Is that of any help?

Moreover, I'm using vertex arrays in this way:

https://github.com/remogatto/mandala-examples/blob/master/cube/src/cubelib/cube.go#L188

EDIT: reference to cube.go

tbruyelle commented 10 years ago

Yeah I know that, to enable vertex arrays OES extension, the flag GL_GLEXT_PROTOTYPES must be set. I had to do that even to compile tbruyelle/gl in the opengles2 branch.

See in https://github.com/tbruyelle/gl/blob/opengles2/gl.h

I looked at the version of gl2ext.h in my NDK toolchain, and the flag is the same, so it should work.

remogatto commented 10 years ago

I'll take a look at your code ASAP. BTW, I think that the quickest way to fix the issue is to try avoiding the use of such OES extension.

tbruyelle commented 10 years ago

Ok thank you !

2014-06-06 11:33 GMT+02:00 Andrea Fazzi notifications@github.com:

I'll take a look at your code ASAP. BTW, I think that the the quickest way to fix the issue is to try avoiding the use of such OES extensions.

— Reply to this email directly or view it on GitHub https://github.com/remogatto/mandala/issues/10#issuecomment-45319089.