Example #1
0
  void _makeOgre()
  {
   srand(time(0));
   
   mRoot = new Ogre::Root("","");
   mRoot->addFrameListener(this);
#if 1
#ifdef _DEBUG
   mRoot->loadPlugin("RenderSystem_Direct3D9_d");
#else
   mRoot->loadPlugin("RenderSystem_Direct3D9");
#endif
#else
#ifdef _DEBUG
   mRoot->loadPlugin("RenderSystem_GL_d.dll");
#else
   mRoot->loadPlugin("RenderSystem_GL.dll");
#endif
#endif
   
   mRoot->setRenderSystem(mRoot->getAvailableRenderers()[0]);
    
   Ogre::ResourceGroupManager* rgm = Ogre::ResourceGroupManager::getSingletonPtr();
   rgm->addResourceLocation(".", "FileSystem");
   
   mRoot->initialise(false);
   
   mWindow = mRoot->createRenderWindow("Monkey", 1024, 768, false);
   mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
   mCamera = mSceneMgr->createCamera("Camera");
   mViewport = mWindow->addViewport(mCamera);
   mViewport->setBackgroundColour(Gorilla::rgb(128, 70, 27));
   
   rgm->initialiseAllResourceGroups();
  }
Example #2
0
  void  _makeOgre()
  {
   srand(time(0));
   
   mRoot = new Ogre::Root("","");
   mRoot->addFrameListener(this);
   
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
   mRoot->loadPlugin(OGRE_RENDERER);
#else
#if 1
  #ifdef _DEBUG
   mRoot->loadPlugin("RenderSystem_Direct3D9_d");
  #else
   mRoot->loadPlugin("RenderSystem_Direct3D9");
  #endif
#else
  #ifdef _DEBUG
   mRoot->loadPlugin("RenderSystem_GL_d.dll");
  #else
   mRoot->loadPlugin("RenderSystem_GL.dll");
  #endif
#endif
#endif
   
   mRoot->setRenderSystem(mRoot->getAvailableRenderers()[0]);
   
   Ogre::ResourceGroupManager* rgm = Ogre::ResourceGroupManager::getSingletonPtr();
  	rgm->addResourceLocation(".", "FileSystem");
   
   mRoot->initialise(false);
   
   mWindow = mRoot->createRenderWindow("Gorilla - Press 0 to 9 for unit tests. C to Clear.", 1024, 768, false);
   mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
   mCamera = mSceneMgr->createCamera("Camera");
   mViewport = mWindow->addViewport(mCamera);
   mViewport->setBackgroundColour(Ogre::ColourValue::Black);
   
   rgm->initialiseAllResourceGroups();
  }
  void  _makeOgre()
  {
   srand(time(0));
   
   mRoot = new Ogre::Root("","");
   mRoot->addFrameListener(this);

  #ifdef _DEBUG
    #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
   // Change this to where ever you've squirrelled away your RenderSystem debug library
   mRoot->loadPlugin("/usr/local/lib/OGRE/RenderSystem_GL_d");
    #else
   mRoot->loadPlugin("RenderSystem_Direct3D9_d");
    #endif
  #else
    #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
   // Change this to where ever you've squirrelled away your RenderSystem release library
   mRoot->loadPlugin("/usr/local/lib/OGRE/RenderSystem_GL");
    #else
   mRoot->loadPlugin("RenderSystem_Direct3D9");
   #endif
#endif
   
   mRoot->setRenderSystem(mRoot->getAvailableRenderers()[0]);
   
   Ogre::ResourceGroupManager* rgm = Ogre::ResourceGroupManager::getSingletonPtr();
  	rgm->addResourceLocation(".", "FileSystem");
   
   mRoot->initialise(false);
   
   mWindow = mRoot->createRenderWindow("Gorilla", 1024, 768, false);
   mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
   mCamera = mSceneMgr->createCamera("Camera");
   mViewport = mWindow->addViewport(mCamera);
   mViewport->setBackgroundColour(Gorilla::rgb(13, 13, 13));
   
   rgm->initialiseAllResourceGroups();
  }
Example #4
0
bool Game::init()
{
  try
  {
    // Read config first
    config.read("./config.cfg");

    // Init SDL
    SDL_Init(SDL_INIT_VIDEO);
    SDL_putenv((char*)"SDL_VIDEO_CENTERED=true");
    int flags = SDL_OPENGL;
    if (config.getFullscreen())
      flags |= SDL_FULLSCREEN;
    SDL_SetVideoMode(config.getCanvasWidth(), config.getCanvasHeight(), config.getBits(), flags);
    SDL_WM_SetCaption("Yet Another Rubik's Cube", NULL);

    // Ogre
    root = new Ogre::Root();
    #ifdef _WINDOWS
      root->loadPlugin("./RenderSystem_GL.dll");
    #else
      root->loadPlugin("./RenderSystem_GL.so");
    #endif
    Ogre::RenderSystem *rs = root->getRenderSystemByName("OpenGL Rendering Subsystem");
    root->setRenderSystem(rs);
    rs->setConfigOption("Full Screen", config.getFullscreenStr());
    rs->setConfigOption("Video Mode", config.getVideoModeStr());
    root->initialise(false);

    // Window
    Ogre::NameValuePairList params;
    #ifdef _WINDOWS
      SDL_SysWMinfo info;
      SDL_VERSION(&info.version);
      SDL_GetWMInfo(&info);
      params["externalWindowHandle"] = Ogre::StringConverter::toString(reinterpret_cast<size_t>(info.window));
      params["externalGLContent"] = Ogre::StringConverter::toString(reinterpret_cast<size_t>(info.hglrc));
      params["externalGLControl"] = Ogre::String("True");
    #else
      params["currentGLContext"] = Ogre::String("True");
    #endif
    wnd = root->createRenderWindow("Main window", config.getCanvasWidth(), config.getCanvasHeight(),
        config.getFullscreen(), &params);
    wnd->setVisible(true);

    // Input
    imgr = new InputManager();

    // Hard-code res location
    Ogre::ResourceGroupManager *rgm = Ogre::ResourceGroupManager::getSingletonPtr();
    rgm->addResourceLocation("res.gdat", "Zip", "General");
    rgm->initialiseAllResourceGroups();

    // Window and rendering events listener
    root->addFrameListener(this);
    imgr->regEventListener(this);
    imgr->regKeyboardListener(this);
  }
  catch (std::exception &e)
  {
    #ifdef _WINDOWS
      MessageBoxA(NULL, e.what(), "Exception occured", MB_OK | MB_ICONERROR);
    #else
      std::cout << e.what();
    #endif
    return false;
  }
  return true;
}
bool CsBaseApplication::Init() {
	Ogre::String pluginsCfg;
#ifdef _DEBUG
    pluginsCfg = "plugins_d.cfg";
#else
    pluginsCfg = "plugins.cfg";
#endif

    //create ogre root
    mRoot = new Ogre::Root(pluginsCfg);

	SetupResources();
    Ogre::ResourceGroupManager *rgm = Ogre::ResourceGroupManager::getSingletonPtr();

    // set a render system
    Ogre::RenderSystem* rSys;
    rSys = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
    mRoot->setRenderSystem(rSys);
    // end gracelessly if the preferred renderer is not available
    if (mRoot->getRenderSystem() == NULL) {
        delete mRoot;
        return false;
    }

    // create a window
    mRoot->initialise(false);
    mWindow = mRoot->createRenderWindow(
        "CsWindow",   // window name
        1366,                    // window width, in pixels
        768,                    // window height, in pixels
        false,                  // fullscreen or not
        0);                     // use defaults for all other values
    Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

    // extra init
    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);

	// Startup the GUI section *******************************************************
	try {
		mRenderer = &CEGUI::OgreRenderer::bootstrapSystem(*mRoot->getRenderTarget("CsWindow"));
	} catch ( CEGUI::Exception& e) {
		MessageBoxA( NULL, e.getMessage().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
		return false;
	}
	//CEGUI::OgreRenderer::bootstrapSystem();

	CEGUI::Imageset::setDefaultResourceGroup("Imagesets");
	CEGUI::Font::setDefaultResourceGroup("Fonts");
	CEGUI::Scheme::setDefaultResourceGroup("Schemes");
	CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel");
	CEGUI::WindowManager::setDefaultResourceGroup("Layouts");
	
	CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme");
	CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
	// *******************************************************************************

	rgm->initialiseAllResourceGroups(); 
	// SceneManager and viewports created in the GameInterface component

	CsAudioManager::Create();
	mAudioManager = CsAudioManager::GetSingletonPtr();
	mAudioManager->Init();

    return true;
}
Example #6
0
	void OgreSubsystem::_init()
	{
		if(!mInitialized)
		{
			Logger::getPtr()->logMessage("Ogre Subsystem starting up...");

			mRoot = new Ogre::Root("","");

			// suppress log output (TODO allow this to be redirected and enabled)
			//Ogre::LogManager::getSingleton().getDefaultLog()->setDebugOutputEnabled(false);
			//Ogre::LogManager::getSingleton().getDefaultLog()->setLogDetail(Ogre::LL_LOW);

			//#if (ORYX_PLATFORM == ORYX_PLATFORM_WIN32)
			//mRoot->loadPlugin("OgrePlugins/RenderSystem_GL.dll");
			//mRoot->loadPlugin("OgrePlugins/Plugin_CgProgramManager.dll");
			//mRoot->loadPlugin("OgrePlugins/Plugin_ParticleFX.dll");
			//#else
			mRoot->loadPlugin("OgrePlugins/RenderSystem_GL");
			//mRoot->loadPlugin("OgrePlugins/Plugin_CgProgramManager");
			mRoot->loadPlugin("OgrePlugins/Plugin_ParticleFX");
			//#endif

			Ogre::RenderSystem* rs = mRoot->getRenderSystemByName(
				"OpenGL Rendering Subsystem");
			mRoot->setRenderSystem(rs);

			mRoot->initialise(false);

			Ogre::NameValuePairList miscP;

			miscP["vsync"] = "false";
			miscP["FSAA"] = "0";
			miscP["gamma"] = "false";
			miscP["border"] = "fixed";
			miscP["colourDepth"] = "32";
			miscP["monitorIndex"] = "0";

      for (std::map<String, String>::iterator it = mParams.begin();
        it != mParams.end(); ++it) {
        miscP[it->first] = it->second;
      }

      mCurrentParams = mParams;

      mWindow = mRoot->createRenderWindow((getGfxParameter("window_name") != "")
        ? getGfxParameter("window_name") : "OryxEngine Application",
        mResolutionX,mResolutionY,mFullscreen,&miscP);

			mWindow->setActive(true);

			mSceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC,"mSceneManager");
			Ogre::SceneNode* defaultCamNode = mSceneManager->createSceneNode("DefaultCameraNode");
			mDefaultCamera = new Camera("DefaultCamera",defaultCamNode,mSceneManager
				->createCamera("DefaultCamera"));
			defaultCamNode->attachObject(mDefaultCamera->getCamera());
			mDefaultCamera->setPosition(Vector3(0,0,0));
			mDefaultCamera->getCamera()->setDirection(0,0,-1);
			mDefaultCamera->setFarClip(60);
			mDefaultCamera->setNearClip(0.1f);
			mDefaultCamera->setFOV(60.f);

			mViewport = mWindow->addViewport(mDefaultCamera->getCamera());
			mViewport->setBackgroundColour(Ogre::ColourValue(1.0f,0.5f,0.2f));

			mDefaultCamera->getCamera()->setAspectRatio(Ogre::Real(mViewport->getActualWidth())
									/ Ogre::Real(mViewport->getActualHeight()));

			Ogre::ResourceGroupManager* resourceMgr = Ogre::ResourceGroupManager::getSingletonPtr();
			resourceMgr->addResourceLocation("../media","FileSystem","General");
			resourceMgr->addResourceLocation("../media/models","FileSystem","General");
			resourceMgr->addResourceLocation("../media/materials","FileSystem","General");
			resourceMgr->addResourceLocation("../media/textures","FileSystem","General");
			resourceMgr->addResourceLocation("../media/audio","FileSystem","General");
			resourceMgr->addResourceLocation("../media/gui","FileSystem","General");
			resourceMgr->addResourceLocation("../media/scripts","FileSystem","General");
			resourceMgr->addResourceLocation("../media/fonts","FileSystem","General");
			resourceMgr->initialiseAllResourceGroups();

			mRootSceneNode = new SceneNode(mSceneManager->getRootSceneNode()->getName(),
				mSceneManager->getRootSceneNode());

			Logger::getPtr()->logMessage("Ogre Subsystem started up.");
			mInitialized = true;
      /*mSceneManager->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(new Ogre::LiSPSMShadowCameraSetup()));
      mSceneManager->setShadowTexturePixelFormat(Ogre::PF_FLOAT16_R);
      mSceneManager->setShadowTextureCasterMaterial("depthcaster");
      mSceneManager->setShadowTextureSelfShadow(true);	
      mSceneManager->setShadowTextureSize(512);	
      mSceneManager->setShadowTextureCount(3);
      mSceneManager->setShadowCasterRenderBackFaces(false);
      mSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);;
      mSceneManager->setShadowFarDistance(1000000.f);*/
		}
	}
Example #7
0
  void  _makeOgre()
  {
   srand(time(0));
   
   mRoot = new Ogre::Root("","");
   mRoot->addFrameListener(this);
   
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
   mRoot->loadPlugin(OGRE_RENDERER);
#else
#if 1
  #ifdef _DEBUG
   mRoot->loadPlugin("RenderSystem_Direct3D9_d");
  #else
   mRoot->loadPlugin("RenderSystem_Direct3D9");
  #endif
#else
  #ifdef _DEBUG
   mRoot->loadPlugin("RenderSystem_GL_d.dll");
  #else
   mRoot->loadPlugin("RenderSystem_GL.dll");
  #endif
#endif
#endif
   
   mRoot->setRenderSystem(mRoot->getAvailableRenderers()[0]);
   
   Ogre::ResourceGroupManager* rgm = Ogre::ResourceGroupManager::getSingletonPtr();
  	rgm->addResourceLocation(".", "FileSystem");
   
   mRoot->initialise(false);
   
   mWindow = mRoot->createRenderWindow("Gorilla", 1024, 768, false);
   mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
   mCamera = mSceneMgr->createCamera("Camera");
   mViewport = mWindow->addViewport(mCamera);

   Ogre::ColourValue BackgroundColour = Ogre::ColourValue(0.1337f, 0.1337f, 0.1337f, 1.0f);
   Ogre::ColourValue GridColour = Ogre::ColourValue(0.2000f, 0.2000f, 0.2000f, 1.0f);

   mViewport->setBackgroundColour(BackgroundColour);
   
   rgm->initialiseAllResourceGroups();
   
   mCamera->setPosition(10,2,10);
   mCamera->lookAt(0,2,0);
   mCamera->setNearClipDistance(0.05f);
   mCamera->setFarClipDistance(1000);
   
   mReferenceObject = new Ogre::ManualObject("ReferenceGrid");

   mReferenceObject->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
   
   Ogre::Real step = 1.0f;
   unsigned int count = 200;
   unsigned int halfCount = count / 2;
   Ogre::Real full = (step * count);
   Ogre::Real half = full / 2;
   Ogre::Real y = 0;
   Ogre::ColourValue c;
   for (unsigned i=0;i < count+1;i++)
   {
    
    if (i == halfCount)
     c = Ogre::ColourValue(0.5f,0.3f,0.3f,1.0f);
    else
     c = GridColour;
    
    mReferenceObject->position(-half,y,-half+(step*i));
    mReferenceObject->colour(BackgroundColour);
    mReferenceObject->position(0,y,-half+(step*i));
    mReferenceObject->colour(c);
    mReferenceObject->position(0,y,-half+(step*i));
    mReferenceObject->colour(c);
    mReferenceObject->position(half,y,-half+(step*i));
    mReferenceObject->colour(BackgroundColour);

    if (i == halfCount)
     c = Ogre::ColourValue(0.3f,0.3f,0.5f,1.0f);
    else
     c = GridColour;
    
    mReferenceObject->position(-half+(step*i),y,-half);
    mReferenceObject->colour(BackgroundColour);
    mReferenceObject->position(-half+(step*i),y,0);
    mReferenceObject->colour(c);
    mReferenceObject->position(-half+(step*i),y,0);
    mReferenceObject->colour(c);
    mReferenceObject->position(-half+(step*i),y, half);
    mReferenceObject->colour(BackgroundColour);

   }
   
   mReferenceObject->end();
   mSceneMgr->getRootSceneNode()->attachObject(mReferenceObject);
    
    
    
  }