#include "Ogre.h" Ogre::Root *ogre; Ogre::RenderWindow *window; Ogre::SceneManager *sceneMgr; Ogre::Camera *camera; int dll_test( int hWnd ) { // New instance of Ogre with blank resource and plugin file parameters- ogre = new Ogre::Root("", ""); ogre->loadPlugin("RenderSystem_GL"); // Ogre wants to iterate through display plugins before choosing one, so we satisfy it here- Ogre::RenderSystemList *renderSystems = NULL; Ogre::RenderSystemList::iterator r_it; renderSystems = ogre->getAvailableRenderers(); r_it = renderSystems->begin(); ogre->setRenderSystem(*r_it); ogre->initialise(false); //Common plugins ogre->loadPlugin("Plugin_CgProgramManager"); ogre->loadPlugin("Plugin_OctreeSceneManager"); //Resource Locations Ogre::ResourceGroupManager::getSingleton().addResourceLocation( "resource", "FileSystem", "General" ); Ogre::ResourceGroupManager::getSingleton().addResourceLocation( "resource/gui.zip", "Zip", "GUI" ); // If windows, grab system fonts- #if defined(WIN32) Ogre::ResourceGroupManager::getSingleton().addResourceLocation("c:\\windows\\fonts", "FileSystem", "GUI"); #endif // Initialise defined resource groups- Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("General"); Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("GUI"); // Set up rendering properties- Ogre::NameValuePairList opts; opts["resolution"] = "1024x768"; opts["fullscreen"] = "false"; opts["vsync"] = "false"; #if defined(WIN32) opts["externalWindowHandle"]=Ogre::StringConverter::toString((size_t)hWnd); #endif // Set up the actual window- window = ogre->createRenderWindow("Thingy", 1024, 768, false, &opts ); // Set up the scene manager- sceneMgr = ogre->createSceneManager(Ogre::ST_GENERIC); // And Camera- camera = sceneMgr->createCamera("camera"); camera->setNearClipDistance(5); // Set up the rendering viewport in the window- Ogre::Viewport* vp = window->addViewport(camera); vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); // Set camera aspect to static 4:3 camera->setAspectRatio((Ogre::Real) 1.333333); return 0; } void dll_messagePump() { Ogre::PlatformManager::getSingleton().messagePump(window); ogre->renderOneFrame(); } void dll_setAmbientLight(int r, int g, int b) { sceneMgr->setAmbientLight( Ogre::ColourValue( r, g, b ) ); } void dll_spawnRobot() { Ogre::Entity *ent1 = sceneMgr->createEntity( "Robot", "robot.mesh" ); Ogre::SceneNode *node1 = sceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode" , Ogre::Vector3( 0, 0, -300 ) ); node1->attachObject ( ent1 ); } void dll_kill() { delete ogre; }