Page 1 of 1

Ogre 1.8 displays no Entity on Android

Posted: Wed Jan 09, 2013 3:06 pm
by McTwist
I have for quite some time now tried to port Ogre to Android. There was problem with cmake for cygwin to make the compilation, but after taking the code from Ogre 1.8 with pre-compiled dependencies, I managed to compile in Eclipse with some minor changes to solve compilation errors with parts from this mk file. Along with it was added initialization and drawing code specified here and parts from the sample code that came along Ogre. The startup code was made in Java with its dependencies, and later the native library was called in the same manner GameKit does, with two functions where one is the initialization and the other is the drawing routine. Due to Android limitations, NativeActivity is not used. Ogre and its dependencies are pre-compiled to reduce the time of the compilation when changes are made to the actual program.
Everything is loaded nicely, with proper debugging output and and no errors or crashes.

The problem that occurs is that even if everything works it doesn't display anything but the viewport background. The camera and the model loaded have been moved several times to ensure they are in the correct position. The viewport background color changes on the fly to verify the drawing routine is working properly. The compiled Ogre library was even copied to the Ogre sample program and compiled with success. Still, it does only display a black screen(Which probably could be changed to whatever color I like to).

Additional information on the setup:

Code: Select all

Eclipse: 4.2.1
Android SDK Tools: 21.0.1
Android NDK: r8c
Android API: 8
Ogre: 1.8
STL: gnustl(libc++)
ABI: armeabi-v7a
Features: exceptions rtti
OpenGL ES: 2.0
I have fallen flat to find a solution to this problem and it bugs me that GameKit managed to port their Ogre properly. Especially when I try to compile GameKit it gives the same problem as above, but when I use a pre-compiled version of GameKit, it works fine.

I assume that that I am clear at my point and the reader have the knowledge about said libraries. If there is any diffuse holes in my description I may explain it in further detail.

Re: Ogre 1.8 displays no Entity on Android

Posted: Wed Mar 20, 2013 3:47 pm
by Artem
I have the same problem!
I use Ogre v1.9 and project OgreJNI with SurfaceView. My view display only Viewport background and I don't see no Entities.

Code: Select all

extern "C"
	JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
        JNIEnv *env;
        jclass k;
        jint r;

		gVM = vm;
        r = vm->GetEnv ((void **) &env, JNI_VERSION_1_4);
        k = env->FindClass ("org/ogre3d/android/OgreActivityJNI");
	return JNI_VERSION_1_4;

	JNIEXPORT void JNICALL 	Java_org_ogre3d_android_OgreActivityJNI_create(JNIEnv * env, jobject obj, jobject assetManager)
        if(gInit)	return;
        gRoot = new Ogre::Root();

        gGLESPlugin = OGRE_NEW GLESRS();

		gOctreePlugin = OGRE_NEW OctreePlugin();

		gParticleFXPlugin = OGRE_NEW ParticleFXPlugin();

		 const Ogre::RenderSystemList &renderSystemList = gRoot->getAvailableRenderers();
		    	__android_log_print(ANDROID_LOG_ERROR, OGRE_TAG,"+++ renderSystemList.empty()");



        mAssetMgr = AAssetManager_fromJava(env, assetManager);
		if (mAssetMgr == NULL) {
			__android_log_print(ANDROID_LOG_ERROR, OGRE_TAG,
					"Error loading asset   maanger");
		} else {
			__android_log_print(ANDROID_LOG_VERBOSE, OGRE_TAG,
					"Loaded Asset Manager!");


        gInit = true;

	JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_destroy(JNIEnv * env, jobject obj)

        gInit = false;

        OGRE_DELETE gRoot;
        gRoot = NULL;
        gRenderWnd = NULL;

		OGRE_DELETE gParticleFXPlugin;
		gParticleFXPlugin = NULL;

		OGRE_DELETE gOctreePlugin;
		gOctreePlugin = NULL;

		gGLESPlugin = NULL;



    JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_initWindow(JNIEnv * env, jobject obj,  jobject surface)
			ANativeWindow* nativeWnd = ANativeWindow_fromSurface(env, surface);
			if (nativeWnd && gRoot)

				Ogre::ArchiveManager::getSingleton().addArchiveFactory(new Ogre::APKFileSystemArchiveFactory(mAssetMgr) );
				Ogre::ArchiveManager::getSingleton().addArchiveFactory(new Ogre::APKZipArchiveFactory(mAssetMgr) );

				Ogre::DataStreamPtr stream;
				AAsset* asset = AAssetManager_open(mAssetMgr, mFSLayer->getConfigFilePath("resources.cfg").c_str(), AASSET_MODE_BUFFER);
				                off_t length = AAsset_getLength(asset);
				                void* membuf = OGRE_MALLOC(length, Ogre::MEMCATEGORY_GENERAL);
				                memcpy(membuf, AAsset_getBuffer(asset), length);

				                stream = Ogre::DataStreamPtr(new Ogre::MemoryDataStream(membuf, length, true, true));

				Ogre::ConfigFile cf;

				// Go through all sections & settings in the file
				Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

				Ogre::String secName, typeName, archName;
				while (seci.hasMoreElements()) {
					secName = seci.peekNextKey();
					Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
					Ogre::ConfigFile::SettingsMultiMap::iterator i;
					for (i = settings->begin(); i != settings->end(); ++i) {
						typeName = i->first;
						archName = i->second;
						Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);

				if (!gRenderWnd)
					Ogre::NameValuePairList opt;
					opt["externalWindowHandle"] = Ogre::StringConverter::toString((int)nativeWnd);
					gRenderWnd = Ogre::Root::getSingleton().createRenderWindow("OgreWindow", 200, 200, true, &opt);

					if(mSceneMgr == NULL)
						mSceneMgr = gRoot->createSceneManager(Ogre::ST_GENERIC);

						mCamera = mSceneMgr->createCamera("camera");
						  mViewport = gRenderWnd->addViewport(mCamera);
						  mCamera->setAspectRatio(Ogre::Real(mViewport->getActualWidth()) / Ogre::Real(mViewport->getActualHeight()));

						  // light
						  mLight = mSceneMgr->createLight("Light");
						  mLight->setPosition(Ogre::Vector3(50, 50, 50));

						  mSceneMgr->setAmbientLight(ColourValue(0.3, 0.3, 0.3));
						  mSceneMgr->createLight()->setPosition(20, 80, 50);

						  // mesh

						  Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
						  mEntity = mSceneMgr->createEntity("Head", "Sinbad.mesh");


					static_cast<Ogre::AndroidEGLWindow*>(gRenderWnd)->_createInternalResources(nativeWnd, NULL);

    JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_termWindow(JNIEnv * env, jobject obj)
		if(gRoot && gRenderWnd)

	JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_renderOneFrame(JNIEnv * env, jobject obj)
		if(gRenderWnd != NULL && gRenderWnd->isActive())
				if(gVM->AttachCurrentThread(&env, NULL) < 0)


			}catch(Ogre::RenderingAPIException ex) {}

In logger I have one error: Adreno200-ES20: <check_framebuffer_status:563>: GL_INVALID_OPERATION
Plz help me!!!!!! :D

Re: Ogre 1.8 displays no Entity on Android

Posted: Tue Mar 26, 2013 7:44 pm
by Orobu
I also like to add that I have the same problem as the two posters above me, using Ogre 1.9 with SurfaceView and OgreJNI. I can get the viewport to change color but that's it. My code looks pretty much the same as Artems and I get the same error in the log: "Adreno200-ES20: <check_framebuffer_status:563>: GL_INVALID_OPERATION". using a HTC Sensation XL. The sample browser built and works just fine when compiling Ogre for Android.

Re: Ogre 1.8 displays no Entity on Android

Posted: Sat Mar 30, 2013 5:48 pm
by Zergeny
I have the same trouble( I'm using Ogre1.9 with precompiled AndroidDependencies_17_12_2012 and Nexus 7.. Interesting that the samples from the browser works fine, but if I try to do a scene in the project OgreJNI editing OgreActivityJNI.cpp, as does Artem... then displays only the specified viewport background color(

Re: Ogre 1.8 displays no Entity on Android

Posted: Tue Apr 16, 2013 5:57 pm
by Zergeny
If you put this code into Java_org_ogre3d_android_OgreActivityJNI_initWindow after creating scene manager:

Code: Select all

gShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
	// Create and register the material manager listener if it doesn't exist yet.
if (gMaterialMgrListener == NULL)
	gMaterialMgrListener = new ShaderGeneratorTechniqueResolverListener(mShaderGenerator);
you will see your scene in OgreJNI... That is why the the SampleBrowser shows entities, and the OgreJNI shows only background colour...
ShaderGeneratorTechniqueResolverListener declaration you can get from the SampleBrowser.h
and don't forgot add static members in OgreActivityJNI.cpp

Code: Select all

static Ogre::RTShader::ShaderGenerator*			gShaderGenerator;			// The Shader generator instance.
static OgreBites::ShaderGeneratorTechniqueResolverListener*	gMaterialMgrListener;		// Shader generator material manager listener.	
Sorry for my English)

Re: Ogre 1.8 displays no Entity on Android

Posted: Tue Apr 16, 2013 8:01 pm
by Wolfmanfx
Checkout the precompiled sdk for android *hint* :)

Ogre 1.9 displays no Entity on Android

Posted: Wed Apr 17, 2013 2:08 pm
by Zergeny
Precompiled OgreSDK_Android_v1-9-0RC1.7z 2013-04-14
Asus Nexus 7 (Android 4.2.2):
- Sample GLES2 works good but without RTShaderSystem it shows only background.
- Sample GLES1 works but I get errors: "E/libEGL (14457): called unimplemented OpenGL ES API"
Asus TF300T (Android 4.2.1):
- Sample GLES2 always shows only background.
- Sample GLES1 also works but I still get errors: "E/libEGL (14457): called unimplemented OpenGL ES API"

Re: Ogre 1.8 displays no Entity on Android

Posted: Wed Apr 17, 2013 2:44 pm
by Wolfmanfx
without RTSS you have to provide all shaders thats why i have included it with gles2.
But you do not need to use RTSS write your own shaders and it will work on all devices. The GLES1 error did not happen on my test device i have to address this in the next release.

Also the package i provide use JNI and you do not need to compile any ogre sources you just use it as a lib.

Re: Ogre 1.8 displays no Entity on Android

Posted: Tue Apr 30, 2013 8:30 am
by McTwist
Zergeny wrote:If you put this code into Java_org_ogre3d_android_OgreActivityJNI_initWindow after creating scene manager:[...]
I am sorry, but first of all I had already added a listener that handled that. Secondly, I added it anyway but it did not work.
Wolfmanfx wrote:Checkout the precompiled sdk for android *hint* :)
I took everything from there. As you already can see, it did not help. There is also no library there, only dependencies packages. Please elaborate what you mean.
Wolfmanfx wrote:Also the package i provide use JNI and you do not need to compile any ogre sources you just use it as a lib.
I have not located where you provided a library that is already compiled.

Thank you for your support. You have been very helpful, but the problem still persists. I have long since put this project on the side and built my own renderer, which actually works. Therefor, I guess the problem would be that I haven't added a shader for the renderer, but I do know that Ogre uses a default shader if no other exists.

Re: Ogre 1.8 displays no Entity on Android

Posted: Tue Apr 30, 2013 8:32 am
by Wolfmanfx

Re: Ogre 1.8 displays no Entity on Android

Posted: Tue Oct 01, 2013 11:52 am
by sbsol

Code: Select all

static OgreBites::ShaderGeneratorTechniqueResolverListener*   gMaterialMgrListener;
sorry about the question, but which are the include for that? :P

Re: Ogre 1.8 displays no Entity on Android

Posted: Wed Oct 02, 2013 4:55 am
by c6burns
Check the sample browser in your ogre source, or the ogretiny example in this forum. Whatever you are using for development, you should have a way to pattern match within all your code. Otherwise you are going to rely on other people every time you need to find a missing class, etc. Search all your code for ShaderGeneratorTechniqueResolverListener and you will find what you are missing :)

Re: Ogre 1.9 displays no Entity on Android

Posted: Mon Feb 03, 2014 1:09 pm
by metatomato
Seems that RTSS mess-up with pre-build Android SDK (1.9 RC1) on device supporting GLES 3.0 (nexus 7 2013 edition in my case) throwing an error like : "#version 300 must include es suffix...".

Something related to this topic

Had to rebuild the Ogre 1.9 source and Android SDK samples work fine. :D