Page 1 of 1

Odd Rendering Behaviour on OSX 10.9 (Mavericks)

Posted: Mon Sep 23, 2013 10:10 am
by chocoanzak
I am developing a 32-bit Mac application using Ogre 1.8 and am having an issue when trying to render the view. I have tried using the sample code from Tutorial 2 to build and run a simple application.

Using the following code under OSX 10.9 I get a scrambled results

Code: Select all

- (void)applicationDidFinishLaunching:(NSNotification *)notificationn {
     
    std::string mResourcePath = [[[NSBundle mainBundle] resourcePath] cStringUsingEncoding:NSUTF8StringEncoding];
    OGRE_NEW Ogre::LogManager();
    Ogre::Log * m_pLog = Ogre::LogManager::getSingleton().createLog("Ogre.log", true, true, false);
    m_pLog->setDebugOutputEnabled(true);
    mResourcePath = Ogre::macBundlePath() + "/Contents/Resources/";
    // Create a new root object with the correct paths
    Ogre::Root *mRoot = new Ogre::Root("", mResourcePath + "ogre.cfg");
    Ogre::StaticPluginLoader m_StaticPluginLoader;
    m_StaticPluginLoader.load();
    
    if(!mRoot->restoreConfig()){
        if(!mRoot->showConfigDialog()){
            return;
        }
    }
	
    Ogre::RenderWindow* mWindow = mRoot->initialise(true);
    OgreView* ogreView;
    OgreWindow* ogreWindow;
    mWindow->getCustomAttribute("VIEW", &ogreView);
    mWindow->getCustomAttribute("WINDOW", &ogreWindow);
    
    Ogre::SceneManager *mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC, "My scene manager");
    
	// Add resource locations
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(mResourcePath,std::string("FileSystem"), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
	
	// Create the camera, node & attach camera
    Ogre::Camera *mCamera = mSceneMgr->createCamera("My camera");
    Ogre::SceneNode *camNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
	camNode->attachObject(mCamera);
	mWindow->addViewport(mCamera);
    
    // Create a light
    mSceneMgr->setAmbientLight(Ogre::ColourValue(1, 1, 1));
    mSceneMgr->createLight("MainLight");
    
    // Add a object, give it it's own node
    Ogre::SceneNode *objectNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    Ogre::Entity *knot = mSceneMgr->createEntity("knot", "knot.mesh");
    objectNode->attachObject(knot);
    objectNode->setPosition(Ogre::Vector3(0, 0, -500));
    
    [window setContentView:ogreView];
    [window makeMainWindow];
}
scambled.png
Scambled Image
scambled.png (120.57 KiB) Viewed 1301 times
However if I change the code to automatically generate the window rather than create it myself it works correctly

Code: Select all

...
    mRoot->initialise(false);
    mRoot->saveConfig();
    
    Ogre::NameValuePairList misc;
    misc["FSAA"] = "0";
    misc["FSAAH"] = "Quality";
    misc["VSync"]="No";
    misc["contentScalingFactor"] = "1";
    misc["displayFrequency"] = "0";
    
    OgreView* view = [[OgreView alloc] initWithFrame:NSMakeRect(100,100,1024,768)];
    
    misc["macAPI"] = "cocoa";
    misc["externalWindowHandle"] = Ogre::StringConverter::toString((size_t)view);
    //misc["orientation"] = "Landscape Right";
    //m_pRenderWnd = m_pRoot->createRenderWindow("OgreWindow",1536,2048,true,&misc);
    //mRoot->createRenderWindow("OgreWindow",1024,768,false,&misc);
    mRoot->createRenderWindow("OgreWindow",1024,768,false,&misc);
    
    Ogre::RenderWindow* mWindow = [view ogreWindow];
...
working.png
Working Image
working.png (46.27 KiB) Viewed 1301 times
I originally thought it was one of the parameters I was passing in but I have double checked them by changing them in various combinations but I can not a working result. Does anyone know why this works when automatically generating the window but doesn't when it is created manually?

Re: Odd Rendering Behaviour on OSX 10.9 (Mavericks)

Posted: Tue Sep 24, 2013 4:50 pm
by masterfalcon
I would recommend trying out the 1.9 branch for support on Mavericks. Of course, Apple may break something, but it should work for now at least.