Android Port

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Re: Android Port

Post by ent1ty »

Thank you. :)

Nadro, you published games that use irrlicht on Google Play, right? Can you share with us your way to get the screen resolution when creating the device in jni?
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Android Port

Post by Nadro »

I published games only on AppStore, we'll publish games on Google Play in future, but currently Android port of our games isn't ready.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Re: Android Port

Post by ent1ty »

Oh... so you haven't solved this problem yet? I looked into it, they say the correct way to do this is pass the resolution from java code... no idea how to do that since I only have c++ code.
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
cww
Posts: 27
Joined: Sun Jul 28, 2013 1:29 pm

Re: Android Port

Post by cww »

my 5 cents on how to get screen resolution in android as native app: in CIrrDeviceAndroid.cpp, after APP_CMD_INIT_WINDOW is called, the screen size values is available in android_app. Look for the following code:

Code: Select all

 
while( IsReady == false )
 
After IsReady, use something like the following to get the width/height:

Code: Select all

 
// Check if screen dimension is set. If not, use size of Android->window.
DeviceWidth = (DeviceWidth > 0) ? DeviceWidth : ANativeWindow_getWidth(Android->window);
DeviceHeight = (DeviceHeight > 0) ? DeviceHeight : ANativeWindow_getHeight(Android->window);
 
i am new here and good to see an active mobile community in irrlicht. cheers :)
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Re: Android Port

Post by ent1ty »

Thank you, this helped a lot! :) I now have a way to determine the screen resolution in a few easy steps. It does require a dummy device, but that's quite ok as that's the same approach you use on desktop, no engine changes necessary.

Code: Select all

 
    SIrrlichtCreationParameters param;
    param.DriverType = EDT_OGLES2;
    param.WindowSize = dimension2d<u32>(320, 240);
    param.PrivateData = app;
    param.Bits = 24;
    param.ZBufferBits = 16;
    param.AntiAlias  = 0;
 
    device = createDeviceEx(param);
 
    int w= ANativeWindow_getWidth(app->window);
    int h= ANativeWindow_getHeight(app->window);
 
    device->closeDevice();
 
    param.WindowSize = dimension2d<u32>(w, h);
    device = createDeviceEx(param);
Cheers :)

The best way would still be to do as you said though, I'll try it out later
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Android Port

Post by Nadro »

Definitly we should integrate support for it inside engine.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Re: Android Port

Post by ent1ty »

So... after the ISReady line, this code seems to work flawlessly:

Code: Select all

 
DeviceWidth = (DeviceWidth > 0) ? DeviceWidth : ANativeWindow_getWidth(Android->window);
DeviceHeight = (DeviceHeight > 0) ? DeviceHeight : ANativeWindow_getHeight(Android->window);
CreationParams.WindowSize.Width= DeviceWidth;
CreationParams.WindowSize.Height= DeviceHeight;
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Re: Android Port

Post by ent1ty »

Any idea when we could get OpenGL ES 3.0 driver?
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
penguin03
Posts: 25
Joined: Fri Apr 19, 2013 9:52 am

Handle Andoid EGLContext losing

Post by penguin03 »

@Nadro:

When Activity onPause, the EGLContext is lost, and all textures and VBO are invalid. Any way to handle it on Irrlicht? Now the HelloMobile sample is black after press Home key and return to app.
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Re: Android Port

Post by ent1ty »

I guess you have to handle it yourself and re-create the whole device. There is a functions you can implement and then set: http://developer.android.com/reference/ ... ivity.html

Code: Select all

 
android_app* state;
...
static void engine_handle_cmd(struct android_app* app, int32_t cmd)
{
    //handle command here
}
...
state->onAppCmd = engine_handle_cmd;
 
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Android Port

Post by Nadro »

@ent1ty
Both OpenGL 3.3 and ES3.0 should be available before end of this year in shader-pipeline branch.

@penguin03
What about context lost on Android? Android 4.0+ is able to hold context, for older Android versions you have to recreate data manually as ent1ty.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
penguin03
Posts: 25
Joined: Fri Apr 19, 2013 9:52 am

Re: Android Port

Post by penguin03 »

@ent1ty
You are right, we need to re-create the whole device, it's a little tough to restore the game state after re-create the whole device. I'll try it.

@Nadro

The OpenGL es context holding depends on Hardware driver. Not all Android 4.0 + device can support it. I use Samsung Galaxy Note II to test the the HelloMobile sample, it can't support it, its Android version is 4.1.2.
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Re: Android Port

Post by ent1ty »

Nadro wrote:@ent1ty
Both OpenGL 3.3 and ES3.0 should be available before end of this year in shader-pipeline branch.
Nice! Keep up the good work :)
Nadro wrote: @penguin03
What about context lost on Android? Android 4.0+ is able to hold context, for older Android versions you have to recreate data manually as ent1ty.
penguin03 wrote:The OpenGL es context holding depends on Hardware driver. Not all Android 4.0 + device can support it. I use Samsung Galaxy Note II to test the the HelloMobile sample, it can't support it, its Android version is 4.1.2.
Yeah, same on Nexus 7 with android 4.3

Edit: this looks interesting: http://stackoverflow.com/questions/2112 ... gl-context
Does irrlicht already do this?
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Android Port

Post by Nadro »

Irrlicht need some changes to support GLSurfaceView as alternative for EGL window created from C++ code.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Re: Android Port

Post by ent1ty »

I'm getting quite horrible seams using the OGLES2 driver:
Image

On desktop there are none to barely noticeable ones(OpenGL), any advice on how to get rid of them?

Edit: my near/far values are 1.0/1800.0, i tried increasing the near value to 100.0, still didn't really help


Edit 2: I tried adding glClearDepthf(1.0); to the if (zBuffer){ ... } block in beginScene, as described here: http://stackoverflow.com/questions/1183 ... sing-glkit (thanks Strong99) but it doesn't seem to help in any way. I'm not feeling particularly 'at home' with editing irrlicht source, am I doing something wrong?
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
Post Reply