Popping Irrlicht and getting it to release window on iPhone

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!
Post Reply
patrickoshaughnessey
Posts: 4
Joined: Tue Sep 14, 2010 5:40 pm
Location: New York, NY
Contact:

Popping Irrlicht and getting it to release window on iPhone

Post by patrickoshaughnessey »

Hello,

I've integrated Garfinkle's template app into my applicaton, but am having an issue trying to pop the view statck once Irrlicht is initialized. Irrlicht does not seem to want to relinquish control of the window, even if I call device->drop().

Here's my setup:

1) AppDelegate: has the main window, which is the window I am using for Irrlicht.
2) A custom UIViewController main menu as the root controller of a NavigationController
3) Another custom UIViewController that contains a difficulty seletion screen. This gets pushed by the main menu controller (i.e. self.navigationController pushViewController:controller animated:NO];)
4) A custom UIViewController that is the game itself. This controller creates my custom UIView class.
5) A custom UIView class where I initialize Irrlicht.

My issue is when I try to pop the UIViewController pushed in step 3, Irrlicht remains visible. I've tried calling driver->drop() just before the pop, but it has no effect.

Anybody else have any insight into this one

Thanks!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

try deviceClose and device->run before device->drop. At least for Windows, this helps. Since device close and release is a pretty complex thing, and the OSX support is always way behind the other systems, it might even be that this was never properly tested and implemented at all. In case you find out some things just post them here, we'll happily integrate them into the engine.
patrickoshaughnessey
Posts: 4
Joined: Tue Sep 14, 2010 5:40 pm
Location: New York, NY
Contact:

Post by patrickoshaughnessey »

Thanks for the prompt reply, hybrid. calling closeDevice() causes the device to hang. It looks like the culprit is the following code, which never returns, since it seems to assume that Irrlicht is running in its own thread:

Code: Select all

191 //! notifies the device that it should close itself
192 void CIrrDeviceIPhone::closeDevice()
193 {
194     WindowActive = false;
195     Close = true;
196     CFRunLoopStop(CFRunLoopGetMain());
197     while (!Closed) yield();
198 }
I'm presently using the template provided by Garfinkle. Is there an XCode project that anyone has created for iPhone compilation that would allow me to compile the source and attempt to fix this?
patrickoshaughnessey
Posts: 4
Joined: Tue Sep 14, 2010 5:40 pm
Location: New York, NY
Contact:

Post by patrickoshaughnessey »

I looked at the way the iPhone integration was coded, and found a workaround to the issue I was having. Its a bit of a hack. I had to essentially remove Irrlicht from the UIWindow, and add it into my view hierarchy at a more appropriate place:

Code: Select all

bool IrrlichtApplication::InitApplication(UIView *parentView)
{
        // ... Create the Irrlicht device, etc, then ... //
	UIView *irrIPhoneView = (UIView *)[appDelegate.window.subviews objectAtIndex:1];
	[parentView addSubview:irrIPhoneView];

        // ...
Not sure what the best way to implement it given the current Irrlicht API, but it seems like it would be friendlier on the iPhone for Irrlicht to assume it was a subview of another view instead of a direct subview of the main UIWindow...
Post Reply