Hi, So having had no confirmation one way or the other I decided to go ahead and try it anyway.
Piecing together bits of information from here and there I settled on creating a view hierarchy where the view controller was a sub class of EAGL2ViewController and the sub view for the Ogre window is a sub class of EAGL2View.
The initialisation code looks like this...
Code: Select all
m_pRoot = new Ogre::Root(pluginsPath, Ogre::macBundlePath() + "/ogre.cfg");
// initialise ogre window with external view handle provided
parameters["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned int)window);
parameters["externalViewHandle"] = Ogre::StringConverter::toString((unsigned int)view);
parameters["externalViewControllerHandle"] = Ogre::StringConverter::toString((unsigned int)viewController);
parameters["contentScalingFactor"] = Ogre::StringConverter::toString((unsigned long)1.0);
CGRect rect = [view frame];
m_pRenderWnd = m_pRoot->createRenderWindow("OgreWindow", rect.size.width, rect.size.height, false, ¶meters);
m_pSceneMgr = m_pRoot->createSceneManager(Ogre::ST_GENERIC, "SceneManager");
m_pSceneMgr->setAmbientLight(Ogre::ColourValue(0.7f, 0.7f, 0.7f));
m_pCamera = m_pSceneMgr->createCamera("Camera");
m_pCamera->setPosition(Ogre::Vector3(0, 0, 150));
m_pCamera->lookAt(Ogre::Vector3(0, 0, 0));
m_pViewport = m_pRenderWnd->addViewport(m_pCamera);
m_pViewport->setBackgroundColour(Ogre::ColourValue(0.8f, 0.0f, 0.0f, 1.0f));
m_pCamera->setAspectRatio(Ogre::Real(m_pViewport->getActualWidth()) / Ogre::Real(m_pViewport->getActualHeight()));
I then proceed to load the Ogre head mesh and add the the scene. The camera is positioned so that it is in front of the head looking directly at it but what I actually see is this...
The UIView I am trying to get Ogre to render into is in the centre of the screen so the red rectangle is the Ogre output as expected but seems clipped somehow. I have tried the same set up in a full screen example and the Ogre's head appears correctly so I'm confident the camera/scene setup is correct.
The log output contains the following slightly confusing message...
Code: Select all
GLES2RenderSystem::_createRenderWindow "OgreWindow", 533x300 windowed miscParams: contentScalingFactor=1 externalViewControllerHandle=257332176 externalViewHandle=257328160 externalWindowHandle=257333648
iOS: Using an external window handle
iOS: Using an external view handle
iOS: Using an external view controller handle
iOS: Window created 768 x 1024 with backing store size 533 x 300 using content scaling factor 2.0
So, is the window size or the content scaling factor causing the incorrect render.
I feel like I am so close with this one, I would be grateful for any suggestions.