Native Android port

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.

Re: Native Android port

Postby Nadro » Wed Feb 19, 2014 11:10 am

No, Irrlicht require native activity.
Nadro
 
Posts: 1647
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Native Android port

Postby sohamdutta13 » Wed Feb 19, 2014 1:39 pm

I am using a surfaceview in java for camera with the QCAR library. this is in ogles 2 and i need to pass the context of that view to the irrlicht natice activity. the problem i am facing is that i have the view for QCAR in java and the irrlicht in the native code. is there anyway to make them use the same surface?
Right now running them parallely makes the irrlicht surface overlap the QCAR camera view.
sohamdutta13
 
Posts: 3
Joined: Wed Feb 19, 2014 4:59 am

Re: Native Android port

Postby Agent_X » Fri Apr 25, 2014 3:30 pm

I've come to consult the oracle! I'm trying to get the back button on the device to emulate a keyboard escape key press. By default the back button causes the NativeActivity to run finish() which effectively closes the app. I can get it to ignore presses of the back button, but I want it to post an escape key event to Irrlicht. What I've done is added some code (shown below) to the handleInput() method in CIrrDeviceAndroid.cpp and then did a complete recompile of Irrlicht. What am I missing?

cpp Code: Select all
 
if (AInputEvent_getType(androidEvent) == AINPUT_EVENT_TYPE_KEY)
{
    SEvent Event;
    Event.EventType = EET_KEY_INPUT_EVENT;
 
    if (AKeyEvent_getKeyCode(androidEvent) == AKEYCODE_BACK)
    {
        Event.KeyInput.Key = KEY_ESCAPE;
        Event.KeyInput.PressedDown = false;
        device->postEventFromUser(Event);
        Status = 1;
    }
}
 


This makes the Android device ignore presses of the back button while in the app, so I know I'm on the right track.
User avatar
Agent_X
 
Posts: 41
Joined: Sun Sep 16, 2012 3:44 am

Re: Native Android port

Postby Agent_X » Fri Apr 25, 2014 3:52 pm

I feel stupid now! :oops: There was a flaw in my program's event receiver code - I had it explicitly ignoring keyboard input if the platform was Android. Sorry for the mistake. By the way that bit of code works perfectly for controlling the behavior of the device's back button. The same concept could be used for the other Android action bar keys... :D
User avatar
Agent_X
 
Posts: 41
Joined: Sun Sep 16, 2012 3:44 am

Re: Native Android port

Postby Nadro » Fri Apr 25, 2014 9:30 pm

BTW. You don't have to recompile Irrlicht if you want change input controller etc. You can do something like that:
// H
cpp Code: Select all
class GameAndroid
{
public:
    GameAndroid(android_app* pApplication);
 
    // some methods here
 
private:
    static void handleCommand(android_app* pApplication, int32_t pCommand);
    static int32_t handleInput(android_app* pApplication, AInputEvent* pEvent);
 
    static void (*irrlichtCommand)(android_app* pApplication, int32_t pCommand);
    static int32_t (*irrlichtInput)(android_app* pApplication, AInputEvent* pEvent);
};


// CPP
cpp Code: Select all
void (*GameAndroid::irrlichtCommand)(android_app* pApplication, int32_t pCommand) = 0;
int32_t (*GameAndroid::irrlichtInput)(android_app* pApplication, AInputEvent* pEvent) = 0;
 
GameAndroid::GameAndroid(android_app* pApplication)
{
    // Init Irrlicht here -> createDevice
 
    irrlichtCommand = pApplication->onAppCmd;
    pApplication->onAppCmd = handleCommand;
 
    irrlichtInput = pApplication->onInputEvent;
    pApplication->onInputEvent = handleInput;
}
 
void GameAndroid::handleCommand(android_app* pApplication, int32_t pCommand)
{
    switch (pCommand)
    {
        case APP_CMD_GAINED_FOCUS:
            // Do something.
            irrlichtCommand(pApplication, pCommand);
            break;
        case APP_CMD_LOST_FOCUS:
            // Do something.
            irrlichtCommand(pApplication, pCommand);
        break;
        case APP_CMD_DESTROY:
            // Do something.
            break;
        default:
            irrlichtCommand(pApplication, pCommand);
            break;
    }
}
 
int32_t GameAndroid::handleInput(android_app* pApplication, AInputEvent* pEvent)
{
    int32_t Status = irrlichtInput(pApplication, pEvent);
 
    switch (AKeyEvent_getKeyCode(pEvent))
    {
    case AKEYCODE_BACK:
    case AKEYCODE_MENU:
        Status = 1;
        break;
    default:
        break;
    }
 
    return Status;
}
Nadro
 
Posts: 1647
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Native Android port

Postby Agent_X » Mon Apr 28, 2014 3:49 pm

I initially tried to do it from inside my application code but I couldn't figure out how to tell the android_app object to execute the IrrlichtDevice's postEventFromUser() method. Now, looking at this example, I see what I was missing. Much cleaner. Thanks Nadro.
User avatar
Agent_X
 
Posts: 41
Joined: Sun Sep 16, 2012 3:44 am

Re: Native Android port

Postby tecan » Sat May 17, 2014 2:31 am

i found that with the latest ogl-es branch the resolution of (0,0) did not automatically set to the detected 320 x 480 on android 2.3 was seeing only a grey screen with one pixel out on the bottom left, after setting it manually it worked perfectly(except for some color glitching on sydney).

heres the original output using 0,0
I/Irrlicht(15825): Using renderer: OpenGL ES-CM 1.1
I/Irrlicht(15825): Qualcomm
I/Irrlicht(15825): GL_AMD_compressed_ATC_texture GL_AMD_performance_monitor GL_APPLE_texture_2D_limited_npot GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_EXT_texture_type_2_10_10_10_REV GL_OES_blend_equation_separate GL_OES_blend_func_separate GL_OES_blend_subtract GL_OES_compressed_ETC1_RGB8_texture GL_OES_compressed_paletted_texture GL_OES_depth_texture GL_OES_draw_texture GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_framebuffer_object GL_OES_matrix_palette GL_OES_packed_depth_stencil GL_OES_point_size_array GL_OES_point_sprite GL_OES_read_format GL_OES_rgb8_rgba8 GL_OES_stencil_wrap GL_OES_texture_cube_map GL_OES_texture_env_crossbar GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_texture_mirrored_repeat GL_QCOM_binning_control GL_QCOM_extended_get GL_QCOM_tiled_rendering GL_AMD_compressed_3DC_texture
I/Irrlicht(15825): GL_INVALID_ENUM
I/Irrlicht(15825): Could not bind Texture
I/Irrlicht(15825): Android command APP_CMD_GAINED_FOCUS
I/Irrlicht(15825): Window size:(320/480)
I/Irrlicht(15825): Display size:(320/480)
Live long and phosphor!
-- https://github.com/tecan/Luna Status 85%
User avatar
tecan
 
Posts: 345
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada

Re: Native Android port

Postby tecan » Tue May 20, 2014 12:54 pm

heres a cb project file that compiles and uploads via ndk via shell script
http://www.xup.to/dl,18903709/example_27_extras.7z/
Live long and phosphor!
-- https://github.com/tecan/Luna Status 85%
User avatar
tecan
 
Posts: 345
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada

Re: Native Android port

Postby bmiller » Mon Jul 25, 2016 10:47 pm

sohamdutta13 wrote:Hi have you managed to run the irrrlicht engine without the native activity. i already have a glsurface that i am drawing on and i would like to draw the 3d model on that surface with irrlicht. the problem is that when i draw the 3d model the background becomes black. Also i am trying to accomplish this using gles 2


Did you find any way to use Irrlicht without a native activity (android_main) ?
bmiller
 
Posts: 4
Joined: Fri Jul 01, 2016 6:50 pm

Previous

Return to Open Discussion and Dev Announcements

Who is online

Users browsing this forum: No registered users and 1 guest