Page 16 of 26

Re: Android Port

Posted: Sun Jul 28, 2013 9:03 am
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?

Re: Android Port

Posted: Sun Jul 28, 2013 11:06 am
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.

Re: Android Port

Posted: Sun Jul 28, 2013 11:27 am
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.

Re: Android Port

Posted: Sun Jul 28, 2013 1:41 pm
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 :)

Re: Android Port

Posted: Sun Jul 28, 2013 5:01 pm
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

Re: Android Port

Posted: Sun Jul 28, 2013 8:47 pm
by Nadro
Definitly we should integrate support for it inside engine.

Re: Android Port

Posted: Mon Jul 29, 2013 7:54 am
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;

Re: Android Port

Posted: Thu Aug 08, 2013 1:44 pm
by ent1ty
Any idea when we could get OpenGL ES 3.0 driver?

Handle Andoid EGLContext losing

Posted: Fri Aug 09, 2013 8:45 am
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.

Re: Android Port

Posted: Fri Aug 09, 2013 10:03 am
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;
 

Re: Android Port

Posted: Fri Aug 09, 2013 10:47 am
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.

Re: Android Port

Posted: Mon Aug 12, 2013 3:47 am
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.

Re: Android Port

Posted: Mon Aug 12, 2013 7:19 am
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?

Re: Android Port

Posted: Mon Aug 12, 2013 11:01 am
by Nadro
Irrlicht need some changes to support GLSurfaceView as alternative for EGL window created from C++ code.

Re: Android Port

Posted: Fri Aug 23, 2013 6:41 pm
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?