コード例 #1
0
ファイル: renderer.cpp プロジェクト: dougmencken/openmw
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);
}
コード例 #2
0
ファイル: renderer.cpp プロジェクト: Adrian-Revk/openmw
void OgreRenderer::createWindow(const std::string &title, const WindowSettings& settings)
{
    assert(mRoot);
    mRoot->initialise(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"));

    int pos_x = SDL_WINDOWPOS_CENTERED_DISPLAY(settings.screen),
        pos_y = SDL_WINDOWPOS_CENTERED_DISPLAY(settings.screen);

    if(settings.fullscreen)
    {
        pos_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(settings.screen);
        pos_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(settings.screen);
    }


    // Create an application window with the following settings:
    mSDLWindow = SDL_CreateWindow(
      "OpenMW",          // window title
      pos_x,             // initial x position
      pos_y,             // initial y position
      settings.window_x, // width, in pixels
      settings.window_y, // height, in pixels
      SDL_WINDOW_SHOWN
        | (settings.fullscreen ? SDL_WINDOW_FULLSCREEN : 0) | SDL_WINDOW_RESIZABLE
    );

    SFO::SDLWindowHelper helper(mSDLWindow, settings.window_x, settings.window_y, title, settings.fullscreen, params);
    if (settings.icon != "")
        helper.setWindowIcon(settings.icon);
    mWindow = helper.getWindow();


    // 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);

    mScene = mRoot->createSceneManager(ST_GENERIC);

    mFader = new Fader(mScene);

    mCamera = mScene->createCamera("cam");

    // Create one viewport, entire window
    mView = mWindow->addViewport(mCamera);
    // Alter the camera aspect ratio to match the viewport
    mCamera->setAspectRatio(Real(mView->getActualWidth()) / Real(mView->getActualHeight()));
}
コード例 #3
0
ファイル: renderer.cpp プロジェクト: dougmencken/openmw
void OgreRenderer::recreateWindow(const std::string &title, const WindowSettings &settings)
{
    Ogre::ColourValue viewportBG = mView->getBackgroundColour();

    mRoot->destroyRenderTarget(mWindow);
    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 one viewport, entire window
    mView = mWindow->addViewport(mCamera);
    mView->setBackgroundColour(viewportBG);

    adjustViewport();
}
コード例 #4
0
void Window::create()
{
	if (mWidth == 0 || mHeight == 0)
	{
		// use highest resolution (last in supported resolutions)
		std::pair<size_t, size_t> res = mSupportedFullscreenResolutions.back();
		mWidth = res.first; mHeight = res.second;
	}
	
	NameValuePairList settings;
	settings.insert(std::make_pair("title", mWindowTitle));
	settings.insert(std::make_pair("FSAA", StringConverter::toString(mFSAA)));
	settings.insert(std::make_pair("vsync", mVSync ? "true" : "false"));

	mRenderWindow = Root::getSingleton().createRenderWindow(mWindowTitle, mWidth, mHeight, mFullscreen, &settings);
	WindowEventUtilities::addWindowEventListener(mRenderWindow, mListener);
	
	size_t windowID; mRenderWindow->getCustomAttribute("WINDOW", &windowID);
	//mInputManager->create(windowID);
}
コード例 #5
0
ファイル: wxOgrePanel.cpp プロジェクト: EnsonRedShirt/Segs
	void init_render_sys()
	{
		m_root = new Ogre::Root();
		m_root->setRenderSystem(m_root->getRenderSystemByName("OpenGL Rendering Subsystem"));
		m_root->initialise(false);
		m_frm = new wxFrame(0,-1,wxT(""));
		NameValuePairList a;
		a.insert(std::pair<String,String>("externalWindowHandle",StringConverter::toString( (size_t) m_frm->GetHandle() )));
		RenderSystem *sys = m_root->getRenderSystem();
		RenderWindow *m_ren = sys->_createRenderWindow(String("OgreRenderWindow_00"),1,1,false,&a);
		MaterialManager::getSingleton().initialise();
		m_frm->Show(false);
	}
コード例 #6
0
void BaseApplication::run()
{
    // Construct Ogre::Root
    // We handle our stuff manually, so don't want to use any of the files
    mRoot = new Root(
        /* plugins.cfg file*/	"",
        /* config file */ 		"",
        /* log file */ 			""
    );

    PathManager::init ();

    // Set render system
    //!todo do not hardcode render system

#ifdef _DEBUG
    mRoot->loadPlugin(PathManager::ogre_plugin_dir + "/RenderSystem_GL");
    RenderSystem* rs = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
#else
    mRoot->loadPlugin(PathManager::ogre_plugin_dir + "/RenderSystem_Direct3D9");
    RenderSystem* rs = mRoot->getRenderSystemByName("Direct3D9 Rendering Subsystem");
#endif
    mRoot->setRenderSystem(rs);

    // Fire up Ogre::Root
    mRoot->initialise(false);

    // Create a hidden background window to keep resources
    NameValuePairList params;
    params.insert(std::make_pair("hidden", "true"));
    RenderWindow *wnd = mRoot->createRenderWindow("InactiveHidden", 1, 1, false, &params);
    wnd->setActive(false);

    Ogre::ResourceGroupManager::getSingleton ().addResourceLocation ("./", "FileSystem");
    Ogre::ResourceGroupManager::getSingleton ().initialiseAllResourceGroups ();

    // Create input system
    //mInputManager = new InputManager();

    // Create the application window
    mWindow = new Window();
    mWindow->mListener = static_cast<WindowEventListener*>(this);
    //mWindow->mInputManager = mInputManager;
    mWindow->mWidth = 800;
    mWindow->mHeight = 600;
    mWindow->mFullscreen = false;
    mWindow->create();

    createScene();
    mRoot->addFrameListener(this);
}
コード例 #7
0
ファイル: wxOgrePanel.cpp プロジェクト: EnsonRedShirt/Segs
void wxOgrePanel::createOgreRenderWindow()
{
	int width;
	int height;
	RenderSystem *sys = OgreInitializer::root()->getRenderSystem();
	NameValuePairList a;

	a.insert(std::pair<String,String>("externalWindowHandle",StringConverter::toString( (size_t) this->GetHandle() )));
	GetSize(&width, &height);
	m_unique_name = StringConverter::toString((size_t) GetId());
	m_RenderWindow = sys->_createRenderWindow(String("OgreRenderWindow")+m_unique_name,width,height,false,&a);
	m_Root = OgreInitializer::root();
	createSceneManager();
	createCamera();
	m_ViewPort = m_RenderWindow->addViewport(m_Camera); 
	m_ViewPort->setBackgroundColour(Ogre::ColourValue(1.0f, ((GetId()*23)&0xFF)/255.0f, 0.0f, 1.0f));
	update();
}
コード例 #8
0
void BaseApplication::run()
{	
	// Construct Ogre::Root
	// We handle our stuff manually, so don't want to use any of the files
	mRoot = new Root(
		/* plugins.cfg file*/	"",
		/* config file */ 		"", 
		/* log file */ 			""
	);
	
	// Set render system
    mRoot->loadPlugin(OGRE_PLUGIN_DIR_REL + std::string("/RenderSystem_GL"));
	RenderSystem* rs = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
	mRoot->setRenderSystem(rs);
	
	// Fire up Ogre::Root
	mRoot->initialise(false);

	// Create the application window
	NameValuePairList settings;
	settings.insert(std::make_pair("title", "OGRE Application"));
	settings.insert(std::make_pair("FSAA", "0"));
    settings.insert(std::make_pair("vsync", "false"));

	mWindow = Root::getSingleton().createRenderWindow("OGRE Application", 800, 600, false, &settings);
	WindowEventUtilities::addWindowEventListener(mWindow, this);
	
	size_t windowID;
	mWindow->getCustomAttribute("WINDOW", &windowID);

	// Create input system
	OIS::ParamList pl;
	std::ostringstream windowHndStr;
	windowHndStr << windowID;
	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    #ifdef OIS_LINUX_PLATFORM
	pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
	pl.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
	pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
    pl.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
    #endif
	mOIS = OIS::InputManager::createInputSystem( pl );
	// Create devices
	if (mOIS->getNumberOfDevices(OIS::OISKeyboard) > 0)
	{
		mOISKeyboard = static_cast<OIS::Keyboard*>(mOIS->createInputObject(OIS::OISKeyboard, true));
		mOISKeyboard->setEventCallback(this);
	}
	if (mOIS->getNumberOfDevices(OIS::OISMouse) > 0)
	{
		mOISMouse = static_cast<OIS::Mouse*>(mOIS->createInputObject(OIS::OISMouse, true));
		mOISMouse->setEventCallback(this);
	}
		
	// Start the rendering loop
	createScene();
	mRoot->addFrameListener(this);
	mRoot->startRendering();
	
	// Shutdown
	if (mOISMouse)
		mOIS->destroyInputObject(mOISMouse);
	if (mOISKeyboard)
		mOIS->destroyInputObject(mOISKeyboard);
	mOIS->destroyInputSystem(mOIS);
	mRoot->removeFrameListener(this);
	delete mRoot;
}