Compiling irrlicht ogl-es branch for iphone (progress)

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
grafikrobot
Posts: 44
Joined: Wed Dec 26, 2007 11:42 pm

Post by grafikrobot »

Well I'm really glad FuzzySpoon finally got the code to Hybrid. I was getting worried that I would be the only one *very* slowly trying to update the iPhone port :-(

Zenja, I get the impression you have a limited view as to what can/should be part of Irrlicht. And I suspect that if you search the forums for your features you'll find people asking for and providing much of the features you mention. But I'll go down your list and mention my thoughts...
Zenja wrote:FuzzySpoon, thanks for the template code (very well documented, thank you). Worked like a charm after a complete rebuilt, and I can now run Irrlicht on the simulator and on the device.
- Freetype fonts via FTGL, modified for GLES.

I've seen an extension for FT fonts floating around the forums. And I would personally like to have it. And it's been on my TODO list for a lonf time now.

- PVRTextureCompression via Oolong

It's been mentioned various times, and there are plans to have it. But it requires some extensive changes to Irrlicht in regards to handling hardware optimized textures.

- Alpha sorted branch in scene graph which works well with tile based renderer.

I implement something like that in my Irrlicht based framework for HUD like things. So there's at least one use case :-)

- iPhone platform support (touches/accelerator/rendering thread (20% speed boost), cross platform locks, message ports, etc)

Touches/accelerator: Definitely people want this. I personally don't as I prefer my own event system for this. But anything that makes it easier for people to use the input system is good.

Rendering thread: That's what I currently do with Irrlicht. There's some extra functionality in the port that helps one switch the GLES rendering context from one thread to another which is the basic feature required.

- Landscape orientation (90 rotation) - quite a number of changes to camera, skydomes, input processing etc. are needed for Landscape orientation.

Not sure how much is in there and working at the moment.

- All 2D elements use percentage based positions, so it looks the same at 1680x1050 and 320x480 or 480x320.

I do that on top of the Irrlicht layer. So not sure people want this in Irrlicht.

- OpenAL and OggVorbis stream support.

There's a few solutions for OpenAL, and other, audio with Irrlicht. But I suspect that it has to stay "separate" to keep the modularity of the rendering engine.

- cross platform, so all development done under Visual Studio, while final testing done on device.

Yep.

- tuned for OpenGL ES1.1

Always looking for better frame rates ;-)

- custom physics engine

Lots of extensions for this one :-)
noster
Posts: 6
Joined: Tue Jun 16, 2009 10:04 am
Location: Poland

Post by noster »

thanks a lot for your code. now I have iphone version working.

one question still remains for me - is GUI subsystem operational? I couldn't launch it properly.
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

There are some known issues with the port obviously, i havent tested any GUI stuff but i read someone saying it didnt work properly.i had 2d stuff and text working fine on my end and didnt test GUI yet.

@ the alpha sorting :

The iphone GL apparently has some sorting internally already. So i wouldnt worry about that yet. Getting more important things like a good input system, and other features "disabled" like the material renderers etc.

Im glad some people are getting somewhere, i am still working to get it to build out of the box. If the current attempt fails again (thanks to frameworks and bad linking) i will then make the irrlicht lib itself into a framework that you link instead. It seems more logical but its a lot more tedious to maintain it seems.

The other note is that im currently embedding the creation/window stuff code side to remove dependancies, and give the control to the user for the views. Things like the auto rotate and the other interesting things the iphone OS offers (the keyboard for example) can be used by grabbing handles to the UIApplication, and the UIView stuff manuall (you already can but im abstracting it first). I have made good progress on the input side of things and when its got a stable enough to use setup, ill send it over to hybrid again (with newer project files if i can)
Rockfish
Posts: 6
Joined: Sat Jul 04, 2009 12:07 am

Thanks!

Post by Rockfish »

I got it running on the device. Yeah! Thanks to everyone's notes and the sample project from FuzzYspo0N.

I setup a new iPhone library project and added the Irrlicht include and sources. After a little fiddling I got it building an Irrlicht library.

Earlier I had ported Mat Buckland's Fish Shoal example from his AI book to OpenGL on iPhone. I merged it into FuzzYspoON's iPhoneTemplateApp to see if it would to work together Irrlicht. Which it does. :D

I had to add a light to the SceneManager in the initGame method. And glEnable(GL_LIGHTING) and glDisable(GL_TEXTURE_2D) before and glDisable(GL_LIGHTING) after the Fish gl code.

Nothing fancy in the fish rendering code. Just lots of little blue triangles chasing each other another. Fun though. :)

Here's the change I made the iPhoneTemplate to make the Fish code draw in blue.

Code: Select all

void Game::initGame(IrrlichtDevice* dev)
{
	mDevice = dev;
	
	scene::ISceneManager* sceneMgr = mDevice->getSceneManager();
	ILightSceneNode* light = sceneMgr->addLightSceneNode();

	light->setRadius(300);
	light->setPosition(core::vector3df(150,200, -10));
	
	video::SLight& lightData = light->getLightData(); 
	lightData.AmbientColor = SColor(255,0,0,255);
	
	initApp();
}
iw6
Posts: 2
Joined: Sat Jul 04, 2009 8:23 pm

Post by iw6 »

hello

has anyone else encountered this error in CIrrDeviceIPhone.cpp when compiling under Xcode.
error: cannot allocate an object of abstract type 'irr::CIrrDeviceIPhone'
even when placing extern "C" around the code?
Rockfish
Posts: 6
Joined: Sat Jul 04, 2009 12:07 am

Post by Rockfish »

Yeah, forgot about that. It's because of two small errors in the CIrrDeviceIPhone class. First in CIrrDeviceIPhone.h the method setResizeAble should be spelled setResizable and same in the .cpp file.
Then add a stub minimizeWindow() method to the .cpp file.

Code: Select all

//! Sets if the window should be resizeable in windowed mode.
void CIrrDeviceIPhone::setResizable(bool resize)
{
}

//! Minimizes the window.
void CIrrDeviceIPhone::minimizeWindow()
{
}
Without them the class is abstract and can't be instantiated.
Rockfish
Posts: 6
Joined: Sat Jul 04, 2009 12:07 am

Post by Rockfish »

I was working on getting the Quake3Map example working in the simulator and I found another thing that should be changed.

In COGLESExtensionHandler.cpp it sets the MaxTextureUnits base on value returned by GL_MAX_TEXTURE_UNITS without comparing it to the value of MATERIAL_MAX_TEXTURES in SMaterial.h. That cause an exception later in COctTreeSceneNode.cpp when it calls setMaterial().

I changed it to match the check in COpenGLExtensionHandler.cpp. From:

Code: Select all

MaxTextureUnits = static_cast<u8>(val);
to:

Code: Select all

MaxTextureUnits = core::min_(static_cast<u8>(val),static_cast<u8>(MATERIAL_MAX_TEXTURES));
iw6
Posts: 2
Joined: Sat Jul 04, 2009 8:23 pm

Post by iw6 »

Rockfish wrote:Yeah, forgot about that. It's because of two small errors in the CIrrDeviceIPhone class. First in CIrrDeviceIPhone.h the method setResizeAble should be spelled setResizable and same in the .cpp file.
Then add a stub minimizeWindow() method to the .cpp file.

Code: Select all

//! Sets if the window should be resizeable in windowed mode.
void CIrrDeviceIPhone::setResizable(bool resize)
{
}

//! Minimizes the window.
void CIrrDeviceIPhone::minimizeWindow()
{
}
Without them the class is abstract and can't be instantiated.
thank you. with these modifications, the library now compiles.

i altered the libpng, libjpeg, and zlib folders, taking out platform specific files, test files, and all other files that were not .c or .h source files. this way i could add those libraries directly into the Xcode project.

fuzzy spoon's template was helpful in getting a working demo.
Rockfish
Posts: 6
Joined: Sat Jul 04, 2009 12:07 am

Post by Rockfish »

FYI- To hide the status bar for a full screen window either add the following line anywhere after the window is created, such as in applicationDidFinishLaunching.

Code: Select all

// Hide status bar
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
Or add the key UIStatusBarHidden to the info.plist file of the project. It might also be called "Status bar is initially hidden". The flag works best.
wildrj
Posts: 301
Joined: Thu Mar 23, 2006 12:49 am
Location: Texas/ Cyberspace
Contact:

Post by wildrj »

Jesus.. someone throw me some instructions step by step.. i still haven't been able to get this working. Can someone put together a quick step by step on how to get it compiling?
http://wild.deathtouchstudios.com << My gamedev blog
<Programming is a way of life>
If at first you don't succeed press the delete key till you do :)
Rockfish
Posts: 6
Joined: Sat Jul 04, 2009 12:07 am

Post by Rockfish »

FYI - hybrid checked in some of these changes already. So you may want to update your sources.

Roughly the steps I used where:

1. Created a new XCode iPhone Static Library project. Added include and source group folders.

2. Add existing files from Irrlicht ogl-es include and source tree.
Then cleaned it up by removing any files that are not in the MacOSX project.

4. Added the following lines to IrrCompileConfig.h around line 81 after the #if defined(__APPLE__) bit.

#undef _IRR_USE_OSX_DEVICE_
#define _IRR_IPHONE_PLATFORM_
#define _IRR_USE_IPHONE_DEVICE_

5. In CIrrDeviceIPhone.cpp and .h
a. Rename setResizeAble to setResizable
b. Added the 'void CIrrDeviceIPhone::minimizeWindow(){}' method to the .cpp
c. Added extern "C" in front 'IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(...' in the .cpp
d. Removed the enclosing 'namespace base { }'

6. Changed the line in COpenGLExtensionHandler.cpp where it sets MaxTextureUnits to
MaxTextureUnits = core::min_(static_cast<u8>(val),static_cast<u8>(MATERIAL_MAX_TEXTURES));

I think at this point the library should build. For the app:

1. Created an iPhone OpenGL project. Copied the files from FuzzYspoON's iPhoneTemplateApp project.
Added them as existing files. The .xib file goes in the NIB Files group.

2. Added the GraphicsServices and CoreGraphics framework to the Frameworks folder.

3. Added the library from the Irrlicht library project to the Frameworks folder.

4. In the .plist file added the 'Status bar is initially hidden' key and checked it.

If I haven't missed anything it should then build and run at this point.

For the device build I was turn off Thumb code and used -O3 for the release version. It makes the library bit bigger but helps it run fast.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, 5 and 6 have been resolved in the latest SVN version, also some other patches have been merged from trunk in the last days.
Last edited by hybrid on Wed Jul 08, 2009 7:54 am, edited 1 time in total.
wildrj
Posts: 301
Joined: Thu Mar 23, 2006 12:49 am
Location: Texas/ Cyberspace
Contact:

Post by wildrj »

Yeah..couldnt get it to work lol.. Few questions..

1. how do i go about creating a iphone static library project in xcode.
2. What frameworks do i include and from were *exact plz* i seem to get stuck at the frameworks part alot.
3. WHY IS THIS SO DIFFICULT!
http://wild.deathtouchstudios.com << My gamedev blog
<Programming is a way of life>
If at first you don't succeed press the delete key till you do :)
Rockfish
Posts: 6
Joined: Sat Jul 04, 2009 12:07 am

Post by Rockfish »

I just completed some changes that add IPhone Touch Events to Irrlicht. I modeled it after the mouse events.

This solves a problem with the way Touch events work on IPhone. The events go to the view created in CIrrDeviceIPhone.m and not to the view created in the user's application. Also the IPhone methods are in ObjectiveC. With these changes the touches are posted like the other events making it easy to receive them in C++ classes anywhere in the application.

You can find the files at http://www.rockfishnw.com/media/files/TouchEvents.zip

I have also included a test class called ISceneNodeAnimatorCameraTouch. It is modeled after the FPS animator. It moves a camera through a scene when the user touches the screen.

These changes are based off the current revision in the ogl-es branch.
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

Cool additions Rockfish thanks for those.

I should have some new stuff for the port soon too.
Post Reply