Android Port

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
SethRobinson
Posts: 7
Joined: Mon Nov 23, 2009 10:49 am
Location: Japan
Contact:

Re: Android Port

Post by SethRobinson »

Proton uses STL and BOOST which is not properly supported by the official NDK r5, and even when using the Crystal fork of the NDK it doesn't work. In other words, it is very hard to get that up and running for Android.

Is there any simple tutorial/step-by-step description how to compile the Irrlicht GLES branch under Windows for Android?
Just an update, I've updated Proton's Android stuff so it now only uses the vanilla Android NDK r6 (no Crystax) - New tutorial on setting it up here: http://www.rtsoft.com/wiki/doku.php?id= ... roid_setup
Seth A. Robinson
www.rtsoft.com
marwee
Posts: 5
Joined: Mon Aug 01, 2011 2:13 am

Re: Android Port

Post by marwee »

Hi!
I am having trouble running Irrlicht with GLES 2.0. I added the missing shaders, and i have a valid GLES 2.0 Context. But when in the COGLES2Driver.cpp in line 1593:
MaterialRenderers[Material.MaterialType].Renderer->OnRender( this, video::EVT_STANDARD );
gets called. The Application dies with Signal 5. I am not debugging, so i wonder where this comes from.

Any hints?
marwee
Posts: 5
Joined: Mon Aug 01, 2011 2:13 am

Re: Android Port

Post by marwee »

For anyone also receiving this Error on Tegra 2: The reason the Application crashed was that Irrlicht intented to set a uniform array, that was optimized away. The size of all Uniforms with MAX_TEXTURE_UNITS Length was shortened from 4 to 2 because the shader never uses for example uUseTexture[2] or higher. The nicest workaround i found was setting MAX_TEXTURE_UNITS to 2 in the COGLES2FixedPipelineShader.h and also in the 2 Shader files. After that you can leave the shaders unmodified and everything works. But disappointingly slow compared to the GLES 1 Renderer.
kaliber
Posts: 117
Joined: Sat Jan 17, 2009 12:51 pm

Re: Android Port

Post by kaliber »

i get "argument list too long" error while compiling with cygwin

anyone know about this ??? :( :( :(
kaliber
Posts: 117
Joined: Sat Jan 17, 2009 12:51 pm

Re: Android Port

Post by kaliber »

kaliber wrote:i get "argument list too long" error while compiling with cygwin

anyone know about this ??? :( :( :(
solved by move the ndk folder to root of the drive. (eg : "D:\android-ndk-r5c")
kaliber
Posts: 117
Joined: Sat Jan 17, 2009 12:51 pm

Re: Android Port

Post by kaliber »

the GUI is not renderred in samsung galaxy mini
Andi.Dascalu
Posts: 14
Joined: Wed Sep 21, 2011 6:44 am

Re: Android Port

Post by Andi.Dascalu »

Hy,

I have a problem with the GLES 2.0 driver. It does not load my textures. GLES 1.0 works fine with the same textures.
I have a LG Optimus Black.

Anyone know what is the solution to this problem?
mixa
Posts: 2
Joined: Sun Nov 20, 2011 5:12 pm

Re: Android Port

Post by mixa »

Thanks for the port.

apk sample files from http://www.scigems.org/downloads/ works OK on my NookColor. I tried to build the port myself from sources, built OK, but it fails at run-time on device with this trace:

********** Crash dump: **********
Build fingerprint: 'enc/zoom2/zoom2/zoom2:2.2.1/MASTER/1.3.0:user/test-keys'
pid: 2588, tid: 2595 >>> com.ellismarkov.irrlicht <<<
signal 11 (SIGSEGV), fault addr 00000014
Stack frame #00 pc 00138ce4 /data/data/com.ellismarkov.irrlicht/lib/libirrlicht.so: Routine setUniform in /home/mixa/NookColor/irrlichtandroid/project/jni/COGLES2SLMaterialRenderer.cpp:470
Stack frame #01 pc 0013cdb0 /data/data/com.ellismarkov.irrlicht/lib/libirrlicht.so: Routine COGLES2Renderer2d in /home/mixa/NookColor/irrlichtandroid/project/jni/COGLES2Renderer2D.cpp:38
Stack frame #02 pc 00132964 /data/data/com.ellismarkov.irrlicht/lib/libirrlicht.so: Routine genericDriverInit in /home/mixa/NookColor/irrlichtandroid/project/jni/COGLES2Driver.cpp:241
Stack frame #03 pc 001330fc /data/data/com.ellismarkov.irrlicht/lib/libirrlicht.so: Routine COGLES2Driver in (null):0
Stack frame #04 pc 00133174 /data/data/com.ellismarkov.irrlicht/lib/libirrlicht.so: Routine createOGLES2Driver in /home/mixa/NookColor/irrlichtandroid/project/jni/COGLES2Driver.cpp:2687
Stack frame #05 pc 000fcda4 /data/data/com.ellismarkov.irrlicht/lib/libirrlicht.so: Routine createDriver in /home/mixa/NookColor/irrlichtandroid/project/jni/CIrrDeviceAndroid.cpp:68
Stack frame #06 pc 000fcf6c /data/data/com.ellismarkov.irrlicht/lib/libirrlicht.so: Routine CIrrDeviceAndroid in /home/mixa/NookColor/irrlichtandroid/project/jni/CIrrDeviceAndroid.cpp:34
Stack frame #07 pc 00332780 /data/data/com.ellismarkov.irrlicht/lib/libirrlicht.so: Routine createDeviceEx in /home/mixa/NookColor/irrlichtandroid/project/jni/Irrlicht.cpp:119
Stack frame #08 pc 003328a8 /data/data/com.ellismarkov.irrlicht/lib/libirrlicht.so: Routine createDevice in /home/mixa/NookColor/irrlichtandroid/project/jni/Irrlicht.cpp:70
Stack frame #09 pc 000fc63c /data/data/com.ellismarkov.irrlicht/lib/libirrlicht.so: Routine Java_com_ellismarkov_irrlicht_IrrlichtTest_nativeInitGL in /home/mixa/NookColor/irrlichtandroid/project/jni/android-activity.cpp:60
Stack frame #10 pc 00016e34 /system/lib/libdvm.so
Stack frame #11 pc 000452c4 /system/lib/libdvm.so
Stack frame #12 pc 0004a9ea /system/lib/libdvm.so
Stack frame #13 pc 0001bd98 /system/lib/libdvm.so
Stack frame #14 pc 00022794 /system/lib/libdvm.so
Stack frame #15 pc 00021634 /system/lib/libdvm.so
Stack frame #16 pc 0005c5dc /system/lib/libdvm.so
Stack frame #17 pc 0005c80c /system/lib/libdvm.so
Stack frame #18 pc 0004fae0 /system/lib/libdvm.so
Stack frame #19 pc 00010f14 /system/lib/libc.so
Stack frame #20 pc 00010a00 /system/lib/libc.so
---

I think that all files on sdcard are in place, since prebuilt apk run OK.

I'm completely new with Irrlicht - could somebody give an idea what the matter can be? I saw in this forum that quake example runs even in emulator with Open GL ES 1, but my build is for ES 2 - can it matter? How to switch test build to use ES 1 driver instead of ES 2?

Thanks in advance
Mike
mixa
Posts: 2
Joined: Sun Nov 20, 2011 5:12 pm

Re: Android Port

Post by mixa »

Yes, the problem was in ES 2 driver - changed to ES 1 and it works OK now
SG57
Posts: 66
Joined: Fri May 18, 2007 5:51 am

Re: Android Port

Post by SG57 »

Hey hey - saw this thread ages ago but never really cared for it since I didn't have an android... now that I do however - i'm interested! I've been dinking around in Java with jpct-ae, libgdx and even raw Opengl. I cannot find a new framework/engine to really call my home, Irrlicht's 3d scene graph is trumps anything i can find. Closest to a 3d scene graph is jpct-ae and even then it feels incomplete. I've worked with Irrlicht for years now, from games to editing an old PSP port's version of Irrlicht to do what i need. I know it quite well...

I'm really tempted to just stick with Irrlicht even for android, but I can't seem to find a clear, concise sample. Proton SDK looks promising, but it looks like another abstraction layer on top of Irrlicht... Java's garbage collection scares me as well which just pushes me back towards C++ even more..

tl;dr ---- Has anyone compiled together a simple Irrlict-for-android eclipse/vs/dev-c++/w.e project? Is irrlicht on android demonstrating equal frame rates as native java 3d frameworks? Thanks heaps!
__________________________________
...you'll never know what it's like, living your whole life in a dream...
guafeng
Posts: 1
Joined: Thu Dec 01, 2011 1:52 am

Re: Android Port

Post by guafeng »

Andi.Dascalu wrote:Hy,

I have a problem with the GLES 2.0 driver. It does not load my textures. GLES 1.0 works fine with the same textures.
I have a LG Optimus Black.

Anyone know what is the solution to this problem?
I have the same issue. GLES 1.x OK, but GLES 2.0 cant apply texture. I am currently trying to find the answer, and anybody could give some advice. Thanks in advance.
SG57
Posts: 66
Joined: Fri May 18, 2007 5:51 am

Re: Android Port

Post by SG57 »

That's interesting considering I can't get OGLES 1.x to bind textures, havent tried 2.0. Did you have to make any adjustments to your irrlicht compilation to get textures working for 1.x? What version of irrlicht - 1.7-beta ?
__________________________________
...you'll never know what it's like, living your whole life in a dream...
skreamz_
Posts: 24
Joined: Sun Jan 17, 2010 9:56 pm

Re: Android Port

Post by skreamz_ »

okay guys, just thought others might like this

you will have to change a few thing in the code to get it to work.
also you will need minizip from the zlib download its in the contrib folder of the download

just so you know this code removes the need to write the data to sdcard before loading it. it opens the apk file which is a jar file renamed.

jarreader.h

Code: Select all

 
#ifndef JARREADER_H
#define JARREADER_H
 
#include "includes.h" //wrapper for all my includes, including irrlicht, 
 
//! Archiveloader capable of loading jar Archives
class JarReaderLoader : public IArchiveLoader
{
public:
 
        //! Constructor
        JarReaderLoader(io::IFileSystem* fs);
 
        //! returns true if the file maybe is able to be loaded by this class
        //! based on the file extension (e.g. ".zip")
        virtual bool isALoadableFileFormat(const io::path& filename) const;
 
        //! Check if the file might be loaded by this class
        /** Check might look into the file.
        \param file File handle to check.
        \return True if file seems to be loadable. */
        virtual bool isALoadableFileFormat(io::IReadFile* file) const;
 
        //! Check to see if the loader can create archives of this type.
        /** Check based on the archive type.
        \param fileType The archive type to check.
        \return True if the archile loader supports this type, false if not */
        virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const;
 
        //! Creates an archive from the filename
        /** \param file File handle to check.
        \return Pointer to newly created archive, or 0 upon error. */
        virtual IFileArchive* createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const;
 
        //! creates/loads an archive from the file.
        //! \return Pointer to the created archive. Returns 0 if loading failed.
        virtual io::IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const;
 
        //! Returns the type of archive created by this loader
        virtual E_FILE_ARCHIVE_TYPE getType() const
        {
                return EFAT_PAK;
        }
 
private:
        io::IFileSystem* FileSystem;
};
 
 
//! reads from jar
class JarReader : public virtual IFileArchive
{
public:
 
        JarReader(unzFile file, bool ignoreCase, bool ignorePaths, stringc fname);
        virtual ~JarReader();
 
        // file archive methods
 
        //! return the id of the file Archive
        virtual const io::path& getArchiveName() const
        {
                return filename;
        }
 
        //! opens a file by file name
        virtual IReadFile* createAndOpenFile(const io::path& filename);
 
        //! opens a file by index
        virtual IReadFile* createAndOpenFile(u32 index);
 
        //! returns the list of files
        virtual const IFileList* getFileList() const;
 
        //! get the class Type
        virtual E_FILE_ARCHIVE_TYPE getType() const
        {
                return EFAT_PAK;
        }
 
private:
 
        unzFile File;
        
        IFileList *filelist;
 
        stringc filename;
        
        struct jarfiles
        {
                stringc fullname;
                stringc name;
        };
        
        std::vector<jarfiles> jflist;
};
 
#endif // JARREADER_H
 
 
jarreader.cpp

Code: Select all

 
#include "jarreader.h"
#include <android-logger.h>
 
extern IrrlichtDevice *device;
 
//! Constructor
JarReaderLoader::JarReaderLoader(io::IFileSystem* fs)
        : FileSystem(fs)
{
#ifdef _DEBUG
        setDebugName("JarReaderLoader");
#endif
}
 
 
//! returns true if the file maybe is able to be loaded by this class
bool JarReaderLoader::isALoadableFileFormat(const io::path& filename) const
{
        return core::hasFileExtension(filename, "jar") || core::hasFileExtension(filename, "apk");
}
 
//! Check to see if the loader can create archives of this type.
bool JarReaderLoader::isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const
{
        return fileType == EFAT_UNKNOWN;
}
 
//! Creates an archive from the filename
/** \param file File handle to check.
\return Pointer to newly created archive, or 0 upon error. */
IFileArchive* JarReaderLoader::createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const
{
        IFileArchive *archive = 0;
        io::IReadFile* file = FileSystem->createAndOpenFile(filename);
 
        if(file)
        {
                archive = createArchive(file, ignoreCase, ignorePaths);
                file->drop();
        }
 
        return archive;
}
 
//! creates/loads an archive from the file.
//! \return Pointer to the created archive. Returns 0 if loading failed.
IFileArchive* JarReaderLoader::createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const
{
        IFileArchive *archive = 0;
 
        stringc fn = file->getFileName();
 
        unzFile zf = unzOpen(fn.c_str());
 
        if(zf == NULL)
                return false;
 
        archive = new JarReader(zf, ignoreCase, ignorePaths, fn);
 
        return archive;
}
 
 
//! Check if the file might be loaded by this class
/** Check might look into the file.
\param file File handle to check.
\return True if file seems to be loadable. */
bool JarReaderLoader::isALoadableFileFormat(io::IReadFile* file) const
{
        stringc fn = file->getFileName();
 
        unzFile zf = unzOpen(fn.c_str());
 
        if(zf == NULL)
                return false;
 
        unzClose(zf);
 
        return true;
}
 
 
/*!
        Jar Reader
*/
JarReader::JarReader(unzFile file, bool ignoreCase, bool ignorePaths, stringc fname) : File(file), filename(fname)
{
        filelist = device->getFileSystem()->createEmptyFileList(fname, ignoreCase, ignorePaths);
 
        unzGoToFirstFile(file);
 
        do
        {
                unz_file_info pfile_info;
                char fn[256];
 
                unzGetCurrentFileInfo(file, &pfile_info, fn, 256, NULL, 0, NULL, 0);
 
                //__android_log_print(ANDROID_LOG_INFO, "Irrlicht", (stringc("adding ") + stringc(fn)).c_str());
 
                filelist->addItem(stringc(fn), pfile_info.uncompressed_size, false);
 
                jarfiles jf;
                jf.fullname = stringc(fn);
                jf.name = device->getFileSystem()->getFileBasename(stringc(fn));
 
                jflist.push_back(jf);
 
        }
        while(unzGoToNextFile(file) != UNZ_END_OF_LIST_OF_FILE);
 
        filelist->sort();
}
 
 
JarReader::~JarReader()
{
        unzClose(File);
}
 
 
const IFileList* JarReader::getFileList() const
{
        return filelist;
}
 
//! opens a file by file name
IReadFile* JarReader::createAndOpenFile(const io::path& filename)
{
        s32 index = filelist->findFile(filename, false);
 
        if(index != -1)
                return createAndOpenFile(index);
 
        return 0;
}
 
 
//! opens a file by index
IReadFile* JarReader::createAndOpenFile(u32 index)
{
        if(index < filelist->getFileCount())
        {
                __android_log_print(ANDROID_LOG_INFO, "Irrlicht", "Locating File");
 
                __android_log_print(ANDROID_LOG_INFO, "Irrlicht", filelist->getFullFileName(index).c_str());
 
                stringc opener;
 
                foreach(jarfiles jf, jflist)
                {
                        if(jf.name == filelist->getFullFileName(index))
                        {
                                opener = jf.fullname;
                                break;
                        }
                }
 
                if(unzLocateFile(File, opener.c_str(), 2) == UNZ_END_OF_LIST_OF_FILE)
                        return 0;
 
                __android_log_print(ANDROID_LOG_INFO, "Irrlicht", "Found");
 
                unsigned char *buffer = new unsigned char[filelist->getFileSize(index)];
 
                __android_log_print(ANDROID_LOG_INFO, "Irrlicht", "Opening File");
                if(unzOpenCurrentFile(File) != UNZ_OK)
                {
                        delete buffer;
                        return 0;
                }
 
                __android_log_print(ANDROID_LOG_INFO, "Irrlicht", "Done");
 
                __android_log_print(ANDROID_LOG_INFO, "Irrlicht", "Reading File");
 
                if(unzReadCurrentFile(File, buffer, filelist->getFileSize(index)) != filelist->getFileSize(index))
                {
                        __android_log_print(ANDROID_LOG_INFO, "Irrlicht", "Failed");
                        delete buffer;
                        unzCloseCurrentFile(File);
 
                        return 0;
                }
 
                __android_log_print(ANDROID_LOG_INFO, "Irrlicht", "Done");
 
                unzCloseCurrentFile(File);
 
                return createMemoryReadFile(buffer, filelist->getFileSize(index), filelist->getFileName(index), true);
        }
        else
                return 0;
}
 
 

you can use the loader via

Code: Select all

 
device->getFileSystem()->addArchiveLoader(new JarReaderLoader(device->getFileSystem()));
        
device->getFileSystem()->addFileArchive(gapkPath.c_str());
 
and you can get the apk path from the java side

Code: Select all

 
        PackageManager packMgmr = getPackageManager();
 
        ApplicationInfo appInfo = null;
                try
                {
                        appInfo = packMgmr.getApplicationInfo("package.name.goes.here", 0);
                } catch(NameNotFoundException e)
                {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        String apkFilePath = appInfo.sourceDir; 
                
        nativeEnvJ2C(Environment.getExternalStorageDirectory().getAbsolutePath(), apkFilePath); //added the perimeter and sent it along to cpp
 
have fun..
tonic
Posts: 69
Joined: Mon Dec 10, 2007 6:18 pm
Contact:

Re: Android Port

Post by tonic »

You can just open the apk as a zip file with the default zip reader.
skreamz_
Posts: 24
Joined: Sun Jan 17, 2010 9:56 pm

Re: Android Port

Post by skreamz_ »

ive tried that, the irrlicht zip reader seems buggy and does not locate all of my files within the apk file.
Post Reply