int startup(){
		 _root = new Ogre::Root("plugins_d.cfg");
		 if(!_root->showConfigDialog()){
			 return -1;
		 }

		 Ogre::RenderWindow* window = _root->initialise(true, "Ventana Ogre");

		 _sceneManager =  _root->createSceneManager(Ogre::ST_GENERIC);

		 Ogre::Camera* camera = _sceneManager->createCamera("Camera");
		 camera->setPosition(Ogre::Vector3(500,100,500));
		 camera->lookAt(Ogre::Vector3(0,0,0));
		 camera->setNearClipDistance(5);

		 Ogre::Viewport* viewport = window->addViewport(camera);
		 viewport->setBackgroundColour(Ogre::ColourValue(0.0,0.0,0.0));
		 camera->setAspectRatio(Ogre::Real(viewport->getActualWidth()/viewport->getActualHeight()));

		 _listener = new FrameListenerProyectos(window,camera);
		 _root->addFrameListener(_listener);

		 loadResources();
		 createScene();
		 _root->startRendering();

		 return 0;
	 }
Exemplo n.º 2
0
	void BaseManager::destroy()
	{
		destroyScene();

		destroyPointerManager();

		destroyInput();

		destroyGui();

		// очищаем сцену
		if (mSceneManager)
		{
			mSceneManager->clearScene();
			mSceneManager->destroyAllCameras();
			mSceneManager = nullptr;
			mCamera = nullptr;
		}

		if (mWindow)
		{
			mWindow->destroy();
			mWindow = nullptr;
		}

		if (mRoot)
		{
			Ogre::RenderWindow* window = mRoot->getAutoCreatedWindow();
			if (window)
				window->removeAllViewports();
			delete mRoot;
			mRoot = nullptr;
		}

	}
Exemplo n.º 3
0
ShaderManager::GraphicsLevel ShaderManager::setGraphicsLevel(ShaderManager::GraphicsLevel newLevel)
{
  if (newLevel > mBestGraphicsLevel) {
    S_LOG_FAILURE("Cannot set graphics level " << mGraphicSchemes[newLevel]);
    return mGraphicsLevel;
  }

  S_LOG_INFO("Using graphics level " << mGraphicSchemes[newLevel]);
  Ogre::MaterialManager::getSingleton().setActiveScheme(mGraphicSchemes[newLevel]);

  Ogre::RenderWindow* window = EmberOgre::getSingleton().getRenderWindow();
  for (int i = 0; i < window->getNumViewports(); ++i) {
    window->getViewport(i)->setMaterialScheme(mGraphicSchemes[newLevel]);
  }

  switch (newLevel) {
  case LEVEL_EXPERIMENTAL:
  case LEVEL_HIGH:
    setPSSMShadows();
    break;

  case LEVEL_MEDIUM:
  case LEVEL_LOW:
  case LEVEL_DEFAULT:
    setNoShadows();
    break;
  }
  mGraphicsLevel = newLevel;

  EventLevelChanged.emit();

  return mGraphicsLevel;
}
Exemplo n.º 4
0
void BasisManager::destroyBasisManager() // очищаем все параметры каркаса приложения
{

	destroyGui();

	// очищаем сцену
	if (mSceneMgr) {
		mSceneMgr->clearScene();
		mSceneMgr->destroyAllCameras();
		mSceneMgr = 0;
	}

	destroyInput(); // удаляем ввод

	if (mWindow) {
		mWindow->destroy();
		mWindow = 0;
	}

	if (mRoot) {
		Ogre::RenderWindow * mWindow = mRoot->getAutoCreatedWindow();
		if (mWindow) mWindow->removeAllViewports();
		delete mRoot;
		mRoot = 0;
	}

}
Exemplo n.º 5
0
void LogoState::exit()
{
    mLoadOverlay->hide();
    Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow();
    if(win) {
        win->removeAllViewports();
        OverlayManager *man = OverlayManager::getSingletonPtr();
        for (int i = 0; i < mNumOverlays; i++) {
            man->getByName(mNameOverlays[i])->clear();
        }
    }
    OverlayManager *man = OverlayManager::getSingletonPtr();
    if(man) {
        /*for (int i = 0; i < mNumOverlays; i++)
        {
        	man->getByName(mNameOverlays[i])->clear();
        }*/
        mOverlayGuys->clear();
        mOverlay4Guys->clear();
        mOverlay4G->clear();
        mOverlayGirl->clear();
        mOverlay1Girl->clear();
        mOverlay1G->clear();
        mOverlayGame->clear();
        mOverlay1Game->clear();
        mOverlay1Gsq->clear();
        mOverlaypresents->clear();
        mOverlayplugins->clear();
        mOverlayskip->clear();
    }
}
Exemplo n.º 6
0
int Hundir::start() {
    _root = new Ogre::Root();

    if(!_root->restoreConfig()) {
        _root->showConfigDialog();
        _root->saveConfig();
    }
    Ogre::RenderWindow* window = _root->initialise(true,"Hundir Example");
    _sceneManager = _root->createSceneManager(Ogre::ST_GENERIC);
    Ogre::Camera* cam = _sceneManager->createCamera("MainCamera");
    cam->setPosition(Ogre::Vector3(-10,30,35));
    cam->lookAt(Ogre::Vector3(0,0,0));
    cam->setNearClipDistance(5);
    cam->setFarClipDistance(10000);

    Ogre::Viewport* viewport = window->addViewport(cam);
    viewport->setBackgroundColour(Ogre::ColourValue(0.0,0.0,0.0));
    double width = viewport->getActualWidth();
    double height = viewport->getActualHeight();
    cam->setAspectRatio(width / height);

    loadResources();
    createScene();

    _framelistener = new MyFrameListener(window, cam, _sceneManager);
    _root->addFrameListener(_framelistener);
    _root->startRendering();
    return 0;
}
Exemplo n.º 7
0
void OgreRenderer::createWindow(const std::string &title, const WindowSettings& settings)
{
    assert(mRoot);
    mRoot->initialise(false);

    // create a hidden 1x1 background window to keep resources when recreating the secondary (real) window
    NameValuePairList params_;
    params_.insert(std::make_pair("title", title));
    params_.insert(std::make_pair("FSAA", "0"));
    params_.insert(std::make_pair("vsync", "false"));
    params_.insert(std::make_pair("hidden", "true"));
    Ogre::RenderWindow* hiddenWindow = mRoot->createRenderWindow("InactiveHidden", 1, 1, false, &params_);
    hiddenWindow->setActive(false);

    NameValuePairList params;
    params.insert(std::make_pair("title", title));
    params.insert(std::make_pair("FSAA", settings.fsaa));
    params.insert(std::make_pair("vsync", settings.vsync ? "true" : "false"));


    mWindow = mRoot->createRenderWindow(title, settings.window_x, settings.window_y, settings.fullscreen, &params);

    // create the semi-transparent black background texture used by the GUI.
    // has to be created in code with TU_DYNAMIC_WRITE_ONLY param
    // so that it can be modified at runtime.
    Ogre::TextureManager::getSingleton().createManual(
                    "transparent.png",
                    Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                    Ogre::TEX_TYPE_2D,
                    1, 1,
                    0,
                    Ogre::PF_A8R8G8B8,
                    Ogre::TU_WRITE_ONLY);
}
Exemplo n.º 8
0
OgreAppFrameListener::~OgreAppFrameListener()
{
	Ogre::RenderWindow *window = mApplication->getRenderWindow();

	WindowEventUtilities::removeWindowEventListener(window, this);
	if(!window->isClosed())
		windowClosed(window);
}
Exemplo n.º 9
0
int main(int argc, char* argv[]){
    cout << "Test Ogre Program blaha" << endl;

    //Relative to where its executed from, not binary location
    Ogre::Root *mRoot = new Ogre::Root("configs/plugins.cfg","configs/config.cfg","logs/main.log");
    if(!(mRoot->restoreConfig() || mRoot->showConfigDialog())){
        delete mRoot;
        return -1;
    }

    // setup resources
    // Only add the minimally required resource locations to load up the Ogre head mesh
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/programs", "FileSystem", "General");
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/programs/GLSL", "FileSystem", "General");
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/scripts", "FileSystem", "General");
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/textures", "FileSystem", "General");
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/models", "FileSystem", "General");

    
    //Create the window
    Ogre::RenderWindow *mWindow = mRoot->initialise(true, "initial Render Window");
    Ogre::SceneManager *sceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC);

    Ogre::Camera *camera = sceneManager->createCamera("PlayerCam");

    camera->setPosition(Ogre::Vector3(0,0,80));
    camera->lookAt(Ogre::Vector3(0,0,-300));
    camera->setNearClipDistance(5);
    
    Ogre::Viewport* vp = mWindow->addViewport(camera);
    vp->setBackgroundColour(Ogre::ColourValue(0,0,0,0));
    camera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));

    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    
    Ogre::Entity* ogreHead = sceneManager->createEntity("Head","ogreHead.mesh");
    Ogre::SceneNode* headNode = sceneManager->getRootSceneNode()->createChildSceneNode();
    headNode->attachObject(ogreHead);

    sceneManager->setAmbientLight(Ogre::ColourValue(0.5,0.5,0.5));
    
    
    
    
    //Run the system
    bool continueRunning = true;
    while(continueRunning){
        mRoot->renderOneFrame();
        headNode->rotate(Ogre::Vector3(0,1,0),Ogre::Radian(0.005));
        if(mWindow->isClosed()){
            continueRunning = false;
        }

    }
    
    
    delete mRoot;
}
Exemplo n.º 10
0
bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
{
    try
    {
        mEnvironment.setFrameDuration (evt.timeSinceLastFrame);

        // update input
        MWBase::Environment::get().getInputManager()->update(evt.timeSinceLastFrame, false);

        // sound
        if (mUseSound)
            MWBase::Environment::get().getSoundManager()->update (evt.timeSinceLastFrame);

        // global scripts
        MWBase::Environment::get().getScriptManager()->getGlobalScripts().run();

        bool changed = MWBase::Environment::get().getWorld()->hasCellChanged();

        // local scripts
        executeLocalScripts(); // This does not handle the case where a global script causes a cell
                               // change, followed by a cell change in a local script during the same
                               // frame.

        // passing of time
        if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
            MWBase::Environment::get().getWorld()->advanceTime (
                mEnvironment.getFrameDuration()*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600);


        if (changed) // keep change flag for another frame, if cell changed happend in local script
            MWBase::Environment::get().getWorld()->markCellAsUnchanged();

        // update actors
        std::vector<std::pair<std::string, Ogre::Vector3> > movement;
        MWBase::Environment::get().getMechanicsManager()->update (movement, mEnvironment.getFrameDuration(),
            MWBase::Environment::get().getWindowManager()->isGuiMode());

        if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
            MWBase::Environment::get().getWorld()->doPhysics (movement, mEnvironment.getFrameDuration());

        // update world
        MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame, MWBase::Environment::get().getWindowManager()->isGuiMode());

        // update GUI
        Ogre::RenderWindow* window = mOgre->getWindow();
        unsigned int tri, batch;
        MWBase::Environment::get().getWorld()->getTriangleBatchCount(tri, batch);
        MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), tri, batch);

        MWBase::Environment::get().getWindowManager()->onFrame(evt.timeSinceLastFrame);
    }
    catch (const std::exception& e)
    {
        std::cerr << "Error in framelistener: " << e.what() << std::endl;
    }

    return true;
}
void ApplicationContextAndroid::pollEvents()
{
    for(WindowList::iterator it = mWindows.begin(); it != mWindows.end(); ++it)
    {
        Ogre::RenderWindow* win = it->render;
        win->windowMovedOrResized();
        windowResized(win);
    }
}
Exemplo n.º 12
0
void OculusDisplay::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
{
  if ( !oculus_ )
  {
    return;
  }
  Ogre::RenderWindow *window = render_widget_->getRenderWindow();
  window->swapBuffers();
}
Exemplo n.º 13
0
	OgreWindow::OgreWindow(OgreModule& module, UiWindow& window, Ogre::RenderWindow& context)
		: RenderWindow(context.getWidth(), context.getHeight(), context.getName(), 0)
		, mModule(module)
		, mWindow(window)
		, mContext(context)
	{
		Ogre::WindowEventUtilities::addWindowEventListener(&mContext, this);

		mContext.getCustomAttribute("WINDOW", &mHandle);
	}
void ApplicationContextAndroid::_fireInputEventAndroid(AInputEvent* event, int wheel) {
    Event evt = {0};

    static TouchFingerEvent lastTouch = {0};

    if(wheel) {
        evt.type = MOUSEWHEEL;
        evt.wheel.y = wheel;
        _fireInputEvent(evt, 0);
        lastTouch.fingerId = -1; // prevent move-jump after pinch is over
        return;
    }

    if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) {
        int32_t action = AMOTION_EVENT_ACTION_MASK & AMotionEvent_getAction(event);

        switch (action) {
        case AMOTION_EVENT_ACTION_DOWN:
            evt.type = FINGERDOWN;
            break;
        case AMOTION_EVENT_ACTION_UP:
            evt.type = FINGERUP;
            break;
        case AMOTION_EVENT_ACTION_MOVE:
            evt.type = FINGERMOTION;
            break;
        default:
            return;
        }

        Ogre::RenderWindow* win = getRenderWindow();

        evt.tfinger.fingerId = AMotionEvent_getPointerId(event, 0);
        evt.tfinger.x = AMotionEvent_getRawX(event, 0) / win->getWidth();
        evt.tfinger.y = AMotionEvent_getRawY(event, 0) / win->getHeight();

        if(evt.type == FINGERMOTION) {
            if(evt.tfinger.fingerId != lastTouch.fingerId)
                return; // wrong finger

            evt.tfinger.dx = evt.tfinger.x - lastTouch.x;
            evt.tfinger.dy = evt.tfinger.y - lastTouch.y;
        }

        lastTouch = evt.tfinger;
    } else {
        if(AKeyEvent_getKeyCode(event) != AKEYCODE_BACK)
            return;

        evt.type = AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_DOWN ? KEYDOWN : KEYUP;
        evt.key.keysym.sym = SDLK_ESCAPE;
    }

    _fireInputEvent(evt, 0);
}
void SoundDetector::_generateEventOutgoingObject(Ogre::String objectName)
{
	if(debug)
	{
		Ogre::RenderWindow* win = ClassPack::getSingleton()->getRenderWindow();
		Ogre::String str = "Outgoing : ";
		str.append( objectName );
		win->setDebugText( str );
	}
	eventMng->createDetectionEvent("outgoingSound_" + mName, objectName);
}
VIEW_API void windowAttributes(size_t& handle, u32& width, u32& height)
{
	Ogre::Root* root = Ogre::Root::getSingletonPtr();
	
	if (! root)
		throw std::logic_error
			("View::windowAttributes: Ogre hasn't been initialized yet.");
	
	Ogre::RenderWindow* win = root->getAutoCreatedWindow();

	win->getCustomAttribute("WINDOW", &handle);
	height = win->getHeight();
	width = win->getWidth();
}
Exemplo n.º 17
0
//---------------------------------------------------------------------
unsigned long renderThreadApp(Ogre::ThreadHandle* threadHandle) {
	LeDernierMorkid::LeDernierMorkidThreadData* threadData     = reinterpret_cast<LeDernierMorkid::LeDernierMorkidThreadData*>(threadHandle->getUserParam());
	GraphicsSystem*                             graphicsSystem = threadData->graphicsSystem;
	Ogre::Barrier*                              barrier        = threadData->barrier;

	graphicsSystem->initialize("Le Dernier Morkid");
	graphicsSystem->getInputHandler()->setGrabMousePointer(true);
	graphicsSystem->getInputHandler()->setMouseVisible(false);
	barrier->sync();

	if (graphicsSystem->getQuit()) {
		graphicsSystem->deinitialize();
		return 0; // User cancelled config
	}

	graphicsSystem->createScene();
	barrier->sync();

	Ogre::RenderWindow* renderWindow = graphicsSystem->getRenderWindow();

	Ogre::Timer   timer;
	unsigned long startTime     = timer.getMicroseconds();
	double        timeSinceLast = 1.0 / 60.0;

	while (!graphicsSystem->getQuit()) {
		graphicsSystem->beginFrameParallel();
		graphicsSystem->update(timeSinceLast);
		graphicsSystem->finishFrameParallel();

		if (!renderWindow->isVisible()) {
			// Don't burn CPU cycles unnecessary when we're minimized.
			Ogre::Threads::Sleep(500);
		}

		unsigned long endTime = timer.getMicroseconds();
		timeSinceLast         = (endTime - startTime) / 1000000.0;
		timeSinceLast         = std::min(1.0, timeSinceLast); // Prevent from going haywire.
		startTime             = endTime;
	}

	barrier->sync();

	graphicsSystem->destroyScene();
	barrier->sync();

	graphicsSystem->deinitialize();
	barrier->sync();

	return 0;
}
Exemplo n.º 18
0
		OgreCameraWrapper::OgreCameraWrapper(const Glib::ustring& name) :
			CameraWrapper(name)
		{
			// Create the camera from the scenemanager
			// ---------------------------------------
			camera = GraphicModule::getInstancePtr()->getSceneManager()->createCamera(name);

			// Create one viewport, entire window
			// ----------------------------------
			Ogre::Root* ogreRoot       = Ogre::Root::getSingletonPtr();
			Ogre::RenderWindow* window = ogreRoot->getAutoCreatedWindow();
			Ogre::Viewport* vp         = window->addViewport(camera);
			vp->setBackgroundColour(Ogre::ColourValue(0.5,1,0));
		}
Exemplo n.º 19
0
void CameraComponent::createViewports(void)
{
	Ogre::RenderWindow* mWindow = Application::getInstance()->getWindow();
	
	// Create one viewport, entire window
	Ogre::Viewport* vp = mWindow->addViewport(mCamera);
	vp->setBackgroundColour(Ogre::ColourValue(0,0,0));

	// Alter the camera aspect ratio to match the viewport
	mCamera->setAspectRatio(
		Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
		
	StateManager::getInstance()->height = vp->getActualHeight();
	StateManager::getInstance()->width = vp->getActualWidth();
}
	void ClipboardManager::initialise()
	{
		MYGUI_ASSERT(false == mIsInitialise, INSTANCE_TYPE_NAME << " initialised twice");
		MYGUI_LOG(Info, "* Initialise: " << INSTANCE_TYPE_NAME);

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
		Ogre::RenderWindow * window = Gui::getInstance().getRenderWindow();
		if (window != nullptr) {
			window->getCustomAttribute("WINDOW", &mHwnd);
		}
#endif

		MYGUI_LOG(Info, INSTANCE_TYPE_NAME << " successfully initialized");
		mIsInitialise = true;
	}
Exemplo n.º 21
0
void OculusDisplay::onInitialize()
{
  fullscreen_property_ = new rviz::BoolProperty( "Render to Oculus", false,
    "If checked, will render fullscreen on your secondary screen. Otherwise, shows a window.",
    this, SLOT(onFullScreenChanged()));

  prediction_dt_property_ = new rviz::FloatProperty( "Motion prediction (ms)", 30.0,
    "Time in ms to predict head motion. Decreases overall latency and motion sickness.",
    this, SLOT(onPredictionDtChanged()) );

  near_clip_property_ = new rviz::FloatProperty( "Near Clip Distance", 0.02,
    "Minimum rendering distance for Oculus camera.",
    this );

  horizontal_property_ = new rviz::BoolProperty( "Fixed Horizon", true,
    "If checked, will ignore the pitch component of the RViz camera.", this);

  follow_cam_property_ = new rviz::BoolProperty( "Follow RViz Camera", true,
    "If checked, will set the Oculus camera to the same position as the main view camera.",
    this, SLOT( onFollowCamChanged() ) );

  tf_frame_property_ = new rviz::TfFrameProperty( "Target Frame", "<Fixed Frame>",
    "Tf frame that the Oculus camera should follow.", this, context_->getFrameManager(), true );

  offset_property_ = new rviz::VectorProperty( "Offset", Ogre::Vector3(0,0,0),
    "Additional offset of the Oculus camera from the followed RViz camera or target frame.", this );

  pub_tf_property_ = new rviz::BoolProperty( "Publish tf", true,
    "If checked, will publish the pose of the Oculus camera as a tf frame.",
    this, SLOT( onPubTfChanged() ) );

  pub_tf_frame_property_ = new rviz::StringProperty( "Tf Frame", "oculus",
    "Name of the published tf frame.", this );

  render_widget_ = new rviz::RenderWidget( rviz::RenderSystem::get() );
  render_widget_->setVisible(false);
  render_widget_->setWindowTitle( "Oculus View" );

  render_widget_->setParent( context_->getWindowManager()->getParentWindow() );
  render_widget_->setWindowFlags( Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMaximizeButtonHint );

  Ogre::RenderWindow *window = render_widget_->getRenderWindow();
  window->setVisible(false);
  window->setAutoUpdated(false);
  window->addListener(this);

  scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();
}
//----------------------------------------------------------------------------//
OIS::MultiTouchState& AndroidMultiTouch::getMultiTouchState (int i)
{
    while (i >= mStates.size())
    {
        Ogre::RenderWindow* pRenderWnd =
            static_cast<Ogre::RenderWindow*> (Ogre::Root::getSingleton().getRenderTarget ("OgreWindow"));
        if (pRenderWnd)
        {
            OIS::MultiTouchState state;
            state.width = pRenderWnd->getWidth();
            state.height = pRenderWnd->getHeight();
            mStates.push_back (state);
        }
    }
    return mStates[i];
}
void application::create_viewports()
{
    Ogre::Viewport* vp = wnd->addViewport(cam);
    vp->setBackgroundColour (Ogre::ColourValue {0, 0, 0});

    cam->setAspectRatio (Ogre::Real (vp->getActualWidth()) / Ogre::Real (vp->getActualHeight()));
}
Exemplo n.º 24
0
	bool frameStarted(const Ogre::FrameEvent& evt)
	{
		if (mExit)
			return false;
		if (mWindow->isClosed())
			return false;

		mKeyboard->capture();
		mMouse->capture();

		if (mKeyboard->isKeyDown(OIS::KC_A) || mKeyboard->isKeyDown(OIS::KC_LEFT))
			mCamera->moveRelative(Ogre::Vector3(-evt.timeSinceLastFrame*20, 0, 0));

		if (mKeyboard->isKeyDown(OIS::KC_D) || mKeyboard->isKeyDown(OIS::KC_RIGHT))
			mCamera->moveRelative(Ogre::Vector3(evt.timeSinceLastFrame*20, 0, 0));

		if (mKeyboard->isKeyDown(OIS::KC_W) || mKeyboard->isKeyDown(OIS::KC_UP))
			mCamera->moveRelative(Ogre::Vector3(0, 0, -evt.timeSinceLastFrame*20));

		if (mKeyboard->isKeyDown(OIS::KC_S) || mKeyboard->isKeyDown(OIS::KC_DOWN))
			mCamera->moveRelative(Ogre::Vector3(0, 0, evt.timeSinceLastFrame*20));

		mGUI->injectFrameEntered(evt.timeSinceLastFrame);

		return true;
	}
Exemplo n.º 25
0
void ApplicationContextSDL::pollEvents()
{
    if(mWindows.empty())
    {
        // SDL events not initialized
        return;
    }

    SDL_Event event;
    while (SDL_PollEvent(&event))
    {
        switch (event.type)
        {
        case SDL_QUIT:
            mRoot->queueEndRendering();
            break;
        case SDL_WINDOWEVENT:
            if(event.window.event != SDL_WINDOWEVENT_RESIZED)
                continue;

            for(WindowList::iterator it = mWindows.begin(); it != mWindows.end(); ++it)
            {
                if(event.window.windowID != SDL_GetWindowID(it->native))
                    continue;

                Ogre::RenderWindow* win = it->render;
                win->windowMovedOrResized();
                windowResized(win);
            }
            break;
        default:
            _fireInputEvent(convert(event), event.window.windowID);
            break;
        }
    }

#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    // hacky workaround for black window on OSX
    for(const auto& win : mWindows)
    {
        SDL_SetWindowSize(win.native, win.render->getWidth(), win.render->getHeight());
        win.render->windowMovedOrResized();
    }
#endif
}
Exemplo n.º 26
0
		//-----------------------------------------------------------------------------
		void Engine::OnRenderViewSize()
		{
				if(m_pRenderWnd)
						m_pRenderWnd->windowMovedOrResized();

				if(m_pCamera)
						m_pCamera->setAspectRatio(
						Ogre::Real(m_pViewport->getActualWidth()) / Ogre::Real(m_pViewport->getActualHeight()));
		}
Exemplo n.º 27
0
		//-----------------------------------------------------------------------------
		bool Engine::Update()
		{
				bool bContinue = !(m_pRenderWnd->isClosed());

				Ogre::WindowEventUtilities::messagePump();
		
				if(m_pRenderWnd->isActive())
				{
						float timeDelta = 0.033f;
						if(!m_pRoot->renderOneFrame(timeDelta))
								bContinue = false;
				}
				else
				{
						Sleep(1000);
				}

				return bContinue;
		}
Exemplo n.º 28
0
//---------------------------------------------------------------------------------------------
void TEditorMapLogic::HandleFromGraphicEngine_Key( nsGraphicEngine::TKeyEvent* pKeyGE )
{
  bool fast = bool( pKeyGE->modifier & OIS::Keyboard::Shift );
  mPtrControlCamera->SetFast( fast );

  switch( pKeyGE->key )
  {
    case OIS::KC_W:
      mPtrControlCamera->SetMoveForward( pKeyGE->pressed );
      break;
    case OIS::KC_S:
      mPtrControlCamera->SetMoveBackward( pKeyGE->pressed );
      break;
    case OIS::KC_A:
      mPtrControlCamera->SetMoveLeft( pKeyGE->pressed );
      break;
    case OIS::KC_D:
      mPtrControlCamera->SetMoveRight( pKeyGE->pressed );
      break;
    case OIS::KC_Q:
      mPtrControlCamera->SetMoveDown( pKeyGE->pressed );
      break;
    case OIS::KC_E:
      mPtrControlCamera->SetMoveUp( pKeyGE->pressed );
      break;
    case OIS::KC_ESCAPE:
      Exit();
      break;
    case OIS::KC_RETURN:// experimental
    {
      if( OIS::Keyboard::Alt & pKeyGE->modifier )
      {
        Ogre::RenderWindow* pRW = mComp.pGraphicEngine->GetGE()->GetWindow();
        int width = pRW->getWidth();
        int height = pRW->getHeight();
        bool isFullScreen = pRW->isFullScreen();
        pRW->setFullscreen( !isFullScreen, width, height );
      }
    }
    break;
  }
}
Exemplo n.º 29
0
int MyApp::start() {
  _root = new Ogre::Root();
  
  if(!_root->restoreConfig()) {
    _root->showConfigDialog();
    _root->saveConfig();
  }

  _pTrackManager = new TrackManager;
  _pSoundFXManager = new SoundFXManager;
  
  Ogre::RenderWindow* window = _root->initialise(true,"MyApp Example");
  _sceneManager = _root->createSceneManager(Ogre::ST_GENERIC);
  
  Ogre::Camera* cam = _sceneManager->createCamera("MainCamera");
  cam->setPosition(Ogre::Vector3(7,10.5,8));
  cam->lookAt(Ogre::Vector3(0,3.5,0));
  cam->setNearClipDistance(5);
  cam->setFarClipDistance(10000);
  
  Ogre::Viewport* viewport = window->addViewport(cam);
  viewport->setBackgroundColour(Ogre::ColourValue(0.0,0.0,0.0));
  double width = viewport->getActualWidth();
  double height = viewport->getActualHeight();
  cam->setAspectRatio(width / height);
  
  loadResources();
  createScene();
  createOverlay();

  Ogre::SceneNode *node = _sceneManager->getSceneNode("Neptuno");
  
  _framelistener = new MyFrameListener(this, window, cam, node, _overlayManager, 
				       _sceneManager);
  _root->addFrameListener(_framelistener);
  
  // Reproducción del track principal...
  this->_mainTrack->play();

  _root->startRendering();
  return 0;
}
Exemplo n.º 30
0
void BasisManager::destroyBasisManager() // очищаем все параметры каркаса приложения
{

	// раскручиваем все стейты
	while ( ! mStates.empty()) {
		mStates.back()->exit();
		mStates.pop_back();
	}

	if (mGUI) {
		mGUI->shutdown();
		delete mGUI;
		mGUI = nullptr;
	}

	// очищаем сцену
	if (mSceneMgr) {
		mSceneMgr->clearScene();
		mSceneMgr->destroyAllCameras();
		mSceneMgr = 0;
	}

	// удаляем ввод
	if (mInput) {
		mInput->destroyInput();
		delete mInput;
		mInput = 0;
	}

	if (mWindow) {
		mWindow->destroy();
		mWindow = 0;
	}

	if (mRoot) {
		Ogre::RenderWindow * mWindow = mRoot->getAutoCreatedWindow();
		if (mWindow) mWindow->removeAllViewports();
		delete mRoot;
		mRoot = 0;
	}

}