What's native code implement ?

Anything libgdx related goes here!

What's native code implement ?

Postby tuanphong » Wed Dec 22, 2010 8:21 am

Hi, I found that libGDX use some native code.
So which function is implement in these file:
libgdx.so
libandroidgl20.so
tuanphong
 
Posts: 10
Joined: Mon Dec 20, 2010 3:44 pm

Re: What's native code implement ?

Postby mzechner » Wed Dec 22, 2010 2:50 pm

libandroidgl20.so houses native bindings for OpenGL ES 2.0 i wrote earlier this year. Reason: the official Java bindings are broken up until 2.3. see http://code.google.com/p/gl2-android/ for more info.

libgdx.so implements a ton of functionality: Box2D wrapper, Mpg123/Tremor wrapper, KissFFT wrapper, many utilities that make things in libgdx perform a lot faster (e.g. workaround for FloatBuffer.put(float[]) which is totally borked on Android).

In short: you'll need it :)
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: What's native code implement ?

Postby Maff » Wed Dec 22, 2010 4:59 pm

mzechner wrote:libgdx.so implements a ton of functionality: Box2D wrapper, Mpg123/Tremor wrapper, KissFFT wrapper, many utilities that make things in libgdx perform a lot faster (e.g. workaround for FloatBuffer.put(float[]) which is totally borked on Android).


This is probably a noob question. Is there a way to build your own libgdx.so? It's native in C++, right? If I'm not using Box2d, FFT, etc. i could cut down on download size, right? Is the source available?
Maff
 
Posts: 27
Joined: Sat Nov 27, 2010 6:54 am

Re: What's native code implement ?

Postby mzechner » Wed Dec 22, 2010 5:11 pm

All the source of libgdx is available, see the Google Code project page.

Building the natives for Android isn't a problem either. However, you'll have to fight with the build system yourself as i can't possibly give support for all that. We use the standard Android NDK toolchain so you can find all the needed information in the NDK docs.

As it stands though the natives for Android are a mere 560kb. I wouldn't consider this to be an issue. While you end up with a little over ~1mb if you also include the armeabi-v7a binaries (which you don't have to but it's better for performance reasons) the installer will only install the binaries for the platform it runs on. So you always only add 500kb to the installation on any device.
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: What's native code implement ?

Postby Maff » Wed Dec 22, 2010 7:36 pm

Ahh, that makes sense! Thanks for the clarification.

(I was confused about what gets compiled into what. I still am, but slightly less so) :)
Maff
 
Posts: 27
Joined: Sat Nov 27, 2010 6:54 am

Re: What's native code implement ?

Postby tuanphong » Fri Dec 24, 2010 7:57 am

I have some questions:
1. Is OpenGL ES 2.0 faster than 1.x ?
2. If I use OpenGL ES 2.0 implemented on libGDX, does performance ensure fast like I write OpenGL ES 2.0 in native code ?

Android emulator does not support OpenGL ES 2.0. libGDX solved this problem.
Many thanks to libGDX.
tuanphong
 
Posts: 10
Joined: Mon Dec 20, 2010 3:44 pm

Re: What's native code implement ?

Postby mzechner » Fri Dec 24, 2010 8:13 am

GLES 2.0 can be faster, however handling it is a little bit more involved. We provide a couple of helper classes (e.g. ShaderProgram) that should make your life easier dealing with it.

Given that you are working in Java with libgdx there's of course a little overhead as compared to going full native. It's neglible though and the performance increase is not justified by the increase in pain you have when developing a native C/C++ app.
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: What's native code implement ?

Postby tuanphong » Fri Dec 24, 2010 8:47 am

Do you have any example using OpenGL ES 2.0 with libGDX ?
Thanks.
tuanphong
 
Posts: 10
Joined: Mon Dec 20, 2010 3:44 pm

Re: What's native code implement ?

Postby mzechner » Fri Dec 24, 2010 10:56 am

Yeah, look into MeshShaderTest or SpriteBatchShaderTest for examples on how to use OpenGL ES 2.0 with libgdx. There's a couple more tests you can look at, don't know any from the top of my head. Remember though that a lot of Android devices don't support OpenGL ES 2.0 and that GLES 1.x is incompatible with 2.0 (no matrix stacks etc.).
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: What's native code implement ?

Postby tuanphong » Fri Dec 24, 2010 12:04 pm

Where can I find MeshShaderTest and SpriteBatchShaderTest example ?

GLES 1.x in libGDX isn't implemented by native code.
I use libGDX to write a 3D game, the speed and memory must be optimized.
So I think I must implements it in native code and GLES 2.0 in libGDX is the best choice for me.
In the future, you may implement GLES 1.x in native code to boost game performance.
tuanphong
 
Posts: 10
Joined: Mon Dec 20, 2010 3:44 pm

Next

Return to Libgdx

Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 1 guest