本文整理汇总了C++中ogre::Root::setRenderSystem方法的典型用法代码示例。如果您正苦于以下问题:C++ Root::setRenderSystem方法的具体用法?C++ Root::setRenderSystem怎么用?C++ Root::setRenderSystem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Root
的用法示例。
在下文中一共展示了Root::setRenderSystem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startEngine
Ogre::Root* OgreEngine::startEngine()
{
m_resources_cfg = "resources.cfg";
activateOgreContext();
Ogre::Root *ogreRoot = new Ogre::Root;
Ogre::RenderSystem *renderSystem = ogreRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
ogreRoot->setRenderSystem(renderSystem);
ogreRoot->initialise(false);
Ogre::NameValuePairList params;
params["externalGLControl"] = "true";
params["currentGLContext"] = "true";
//Finally create our window.
m_ogreWindow = ogreRoot->createRenderWindow("OgreWindow", 1, 1, false, ¶ms);
m_ogreWindow->setVisible(false);
m_ogreWindow->update(false);
doneOgreContext();
return ogreRoot;
}
示例2: InitOgreRenderSystem
void GraphicsManager::InitOgreRenderSystem()
{
if( !this->OgreBeenInitialized ) {
Ogre::Root* OgreCore = Ogre::Root::getSingletonPtr();
const Ogre::RenderSystemList& RSList = OgreCore->getAvailableRenderers();
if( RSList.size() == 1 ) {
//Ogre::RenderSystem* temp = OgreCore->getRenderSystemByName( this->GetRenderSystemName( this->RenderSystemTypes[0] ) );
OgreCore->setRenderSystem( RSList[0] );
}else{
//Ogre::RenderSystem* temp = OgreCore->getRenderSystemByName( this->GetRenderSystemName( this->CurrRenderSys ) );
OgreCore->setRenderSystem( OgreCore->getRenderSystemByName( this->GetRenderSystemName( this->CurrRenderSys ) ) );
}
OgreCore->initialise(false,"");
this->OgreBeenInitialized = true;
this->PrimaryGameWindow = new GameWindow("Primary",1,1,GameWindow::WF_Hidden);
}
}
示例3: init_render_sys
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);
}
示例4: startup
//Funcion que inicializa la aplicacion
int startup(){
_root = new Ogre::Root("plugins_d.cfg");
//Muestra la ventana inicial...
//if(!_root->showConfigDialog()){
// return -1;
//}
// Evitan cargar la ventana inicial...
Ogre::RenderSystem* _rs = _root->getRenderSystemByName("Direct3D9 Rendering Subsystem");
// or use "OpenGL Rendering Subsystem"
_root->setRenderSystem(_rs);
_rs->setConfigOption("Full Screen", "No");
_rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
_rs->setConfigOption("FSAA", "0");
_rs->setConfigOption("Floating-point mode", "Fastest");
_rs->setConfigOption("Use Multihead", "Auto");
_rs->setConfigOption("VSync", "No");
_rs->setConfigOption("VSync Interval", "1");
Ogre::RenderWindow* window = _root->initialise(true,"Ventana de Ogre3D");
_sceneManager = _root->createSceneManager(Ogre::ST_GENERIC);
loadResources();
createScene();
createCamera(window);
_listener = new AppFrameListener(window,camera,_sceneManager);
_root->addFrameListener(_listener);
//_root->startRendering();
return 0;
}
示例5: startup
int startup(){
_root = new Ogre::Root("plugins_d.cfg");
/*
if(!_root->showConfigDialog()){
return -1;
}
*/
Ogre::RenderSystem* _rs = _root->getRenderSystemByName("Direct3D9 Rendering Subsystem");
// or use "OpenGL Rendering Subsystem"
_root->setRenderSystem(_rs);
_rs->setConfigOption("Full Screen", "No");
_rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
_rs->setConfigOption("FSAA", "0");
_rs->setConfigOption("Floating-point mode", "Fastest");
_rs->setConfigOption("Use Multihead", "Auto");
_rs->setConfigOption("VSync", "No");
_rs->setConfigOption("VSync Interval", "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(0.0f,300.0f,-1000.0f));
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;
}
示例6: configure
bool GraphicsImpl::configure()
{
Dout <<"Setting Rendering Subsystem" ;
Ogre::RenderSystemList renderers = root->getAvailableRenderers();
if (renderers.empty()) {
Dout <<"No rendering system available" ;
return false;
}
root->setRenderSystem(renderers.front());
Dout <<"Init Root" ;
root->initialise(false);
Dout <<"Create window" ;
window = root->createRenderWindow("Manual Ogre Window", boost::any_cast<int>(SettingsManager::Instance().getSetting("x_res").data), boost::any_cast<int>(SettingsManager::Instance().getSetting("y_res").data), false, 0); // use defaults for all other values
return true;
}
示例7: Logger
int
main( int argc, char *argv[] )
{
Ogre::Root* root;
Ogre::RenderWindow* window;
root = new Ogre::Root( "", "" );
#ifndef _DEBUG
root->loadPlugin( "RenderSystem_GL.dll" );
#else
root->loadPlugin( "RenderSystem_GL_d.dll" );
#endif
root->setRenderSystem( root->getAvailableRenderers()[ 0 ] );
root->initialise( false );
Ogre::NameValuePairList misc;
misc[ "title" ] = "Xenogears SoundDumper";
window = root->createRenderWindow( "QGearsWindow", 800, 600, false, &misc );
LOGGER = new Logger( "game.log" );
state = GAME;
DisplayFrameListener* frame_listener = new DisplayFrameListener( window );
root->addFrameListener( frame_listener );
Ogre::SceneManager* scene_manager = root->createSceneManager( Ogre::ST_GENERIC, "Scene" );
scene_manager->setAmbientLight( Ogre::ColourValue( 1.0, 1.0, 1.0 ) );
Ogre::Camera* camera = scene_manager->createCamera( "Camera" );
camera->setNearClipDistance( 5 );
Ogre::Viewport* viewport = window->addViewport( camera );
viewport->setBackgroundColour( Ogre::ColourValue( 0, 0, 0 ) );
camera->setAspectRatio( Ogre::Real( viewport->getActualWidth()) / Ogre::Real( viewport->getActualHeight() ) );
SOUNDMAN = new SoundManager();
SOUND_PARSER = new SoundParser();
Ogre::Root::getSingleton().startRendering();
delete SOUND_PARSER;
delete SOUNDMAN;
delete root;
delete frame_listener;
delete LOGGER;
return 0;
}
示例8: main
int main(int argc, char **argv)
#endif
{
try
{
//Iniciem el nostre carregador de classes
ClassLoader::init();
//Iniciem OGRE
#ifdef NO_LOGS
Ogre::Root *lRoot = new Ogre::Root("", "", "");
#else
Ogre::Root *lRoot = new Ogre::Root("", "", "skbl.log");
#endif
lRoot->loadPlugin("Plugin_OctreeSceneManager");
//provem de carregar els plugins de DirectX o OpenGL
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
try
{
lRoot->loadPlugin("RenderSystem_Direct3D9");
}catch (Ogre::Exception &e)
{
MessageBox( NULL, "Get it in our web page",
"Couldn't find shared library \"RenderSystem_Direct3D9\"\n",
MB_OK | MB_ICONERROR | MB_TASKMODAL);
}
#else //Win32
try
{
lRoot->loadPlugin("RenderSystem_GL");
}catch (Ogre::Exception &ee)
{
std::cerr << "Couldn't find shared library \"RenderSystem_GL\". Get it in our web page\n" << std::endl;
}
#endif //Win32
//ara seleccionem un render system d'entre els disponibles
const Ogre::RenderSystemList& lRenderSystemList = lRoot->getAvailableRenderers();
for(unsigned int i=0; i<lRenderSystemList.size(); i++)
{
Ogre::String rsysnm = lRenderSystemList[i]->getName();
//l'ordre d'ifs es el de preferencia
if(rsysnm=="Direct3D9 Rendering Subsystem")
{
lRoot->setRenderSystem(lRenderSystemList[i]);
break;
}
if(rsysnm=="OpenGL Rendering Subsystem")
{
lRoot->setRenderSystem(lRenderSystemList[i]);
break;
}
}
//Inicialitzem Root sense crear finestra
lRoot->initialise(false);
//TODO: Llegir fitxer de configuracio
Ogre::RenderWindow *lWindow;
Ogre::NameValuePairList lParams;
lParams["vsync"] = "true";
lWindow = lRoot->createRenderWindow("De-geso~~~", 1280, 720, false, &lParams);
// Load resource paths from config file
Ogre::ConfigFile cf;
cf.load("configScripts/resources.cfg");
// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
// OS X does not set the working directory relative to the app,
// In order to make things portable on OS X we need to provide
// the loading with it's own bundle path location
if (!Ogre::StringUtil::startsWith(archName, "/", false)) // only adjust relative dirs
archName = Ogre::String(Ogre::macBundlePath() + archName);
#endif
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
//Creem un GameSetup --provisional
GameSetup *lGameSetup = ClassLoader::makeGameSetupLocalProva(lRoot, lWindow, "pl_Boxejador", "lv_Prova");
delete lGameSetup;
ClassLoader::unloadGameSetupLocalProva();
//.........这里部分代码省略.........
示例9: font
int
main( int argc, char *argv[] )
{
Ogre::Root* root;
Ogre::RenderWindow* window;
root = new Ogre::Root( "", "" );
#ifndef _DEBUG
root->loadPlugin( "RenderSystem_GL.dll" );
#else
root->loadPlugin( "RenderSystem_GL_d.dll" );
#endif
root->setRenderSystem( root->getAvailableRenderers()[ 0 ] );
root->initialise( false );
Ogre::NameValuePairList misc;
misc[ "title" ] = "FFVII Exporter";
window = root->createRenderWindow( "QGearsWindow", 800, 600, false, &misc );
FILESYSTEM = new FileSystem();
LOGGER = new Logger( "game.log" );
state = GAME;
{
BinGZipFile* file = new BinGZipFile( "data/en/WINDOW.BIN" );
File* font_graf = file->ExtractGZip( 1 );
File* font_padding = file->ExtractGZip( 2 );
FontFile font( font_padding );
font.Export( "export_en/ui/fonts/ffvii_en.xml", true );
//font_graf->WriteFile( "font.tim" );
Vram* vram = new Vram();
LoadTimFileToVram( font_graf, 0, vram );
//vram->Save( "text" );
Ogre::TexturePtr ptex;
Ogre::HardwarePixelBufferSharedPtr buffer;
ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, 256, 256, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC );
buffer = ptex->getBuffer( 0, 0 );
buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD );
const Ogre::PixelBox& pb = buffer->getCurrentLock();
CreateTextureFromVram( pb, vram, 0, 0, 0x80, 0x1f7, 0x380, 0x100, BPP_4 , false );
Ogre::Image image;
image.loadDynamicImage( ( Ogre::uchar* )pb.data, 256, 256, Ogre::PF_R8G8B8A8 );
image.save( "export_en/ui/fonts/ffvii_en.png" );
buffer->unlock();
delete vram;
delete file;
}
{
BinGZipFile* file = new BinGZipFile( "data/jp/WINDOW.BIN" );
File* font_graf = file->ExtractGZip( 1 );
File* font_graf2 = file->ExtractGZip( 2 );
File* font_padding = file->ExtractGZip( 3 );
font_padding->WriteFile( "font_padding.dat" );
FontFile font( font_padding );
font.Export( "export_jp/ui/fonts/ffvii_jp.xml", false );
font_graf->WriteFile( "font.tim" );
font_graf2->WriteFile( "font2.tim" );
Vram* vram = new Vram();
LoadTimFileToVram( font_graf, 0, vram );
LoadTimFileToVram( font_graf2, 0, vram );
//vram->Save( "text" );
Ogre::TexturePtr ptex;
Ogre::HardwarePixelBufferSharedPtr buffer;
ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, 512, 256, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC );
buffer = ptex->getBuffer( 0, 0 );
buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD );
const Ogre::PixelBox& pb = buffer->getCurrentLock();
CreateTextureFromVram( pb, vram, 0, 0, 0x80, 0x1f7, 0x380, 0x100, BPP_4 , false );
CreateTextureFromVram( pb, vram, 256, 0, 0x90, 0x1f7, 0x380, 0x100, BPP_4 , false );
Ogre::Image image;
image.loadDynamicImage( ( Ogre::uchar* )pb.data, 512, 256, Ogre::PF_R8G8B8A8 );
image.save( "export_jp/ui/fonts/ffvii_jp.png" );
buffer->unlock();
delete vram;
delete file;
}
{
File sword( "sword.tim" );
Vram* vram = new Vram();
LoadTimFileToVram( &sword, 0, vram );
//vram->Save( "sword" );
Ogre::TexturePtr ptex;
Ogre::HardwarePixelBufferSharedPtr buffer;
ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, 256, 256, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC );
buffer = ptex->getBuffer( 0, 0 );
buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD );
//.........这里部分代码省略.........
示例10: Shutdown
bool
COgreWindowContext::Initialize( const GUI::CString& title ,
const GUI::CVideoSettings& videoSettings ,
const GUI::CString& ogreRenderSystem )
{GUCEF_TRACE;
// Do not initialize twice
Shutdown();
// First create a regular O/S window
if ( m_osWindow->WindowCreate( title ,
0 ,
0 ,
videoSettings.GetResolutionWidthInPixels() ,
videoSettings.GetResolutionHeightInPixels() ) )
{
// Display the new window
m_osWindow->Show();
m_osWindow->SendToForegound();
m_osWindow->GrabFocus();
// Now proceed with setting up the Ogre specifics
// We grab the O/S window identifier 'the handle'
// This is passed to Ogre to tie things together
CORE::Int64 windowRef = 0;
CORE::CString windowIntStr = m_osWindow->GetProperty( "WINDOWINT" );
if ( !windowIntStr.IsNULLOrEmpty() )
{
windowRef = CORE::StringToInt64( windowIntStr );
}
Ogre::NameValuePairList options;
options[ "externalWindowHandle" ] = Ogre::StringConverter::toString( (size_t) windowRef );
Ogre::Root* ogreRoot = Ogre::Root::getSingletonPtr();
if ( ogreRoot == nullptr )
{
ogreRoot = OGRE_NEW Ogre::Root( "", "", "" );
}
if ( !ogreRoot->isInitialised() )
{
// Load any Ogre plugins not loaded yet from the bootstrap group
CORE::CCoreGlobal::Instance()->GetPluginControl().LoadPluginGroup( "Ogre" );
const Ogre::RenderSystemList& rsList = ogreRoot->getAvailableRenderers();
if ( rsList.size() == 0 )
{
GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "OgreWindowContext: No Ogre render systems are available, cannot initialize" );
return false;
}
Ogre::RenderSystem* renderSystem = nullptr;
Ogre::RenderSystemList::const_iterator i = rsList.begin();
while ( i != rsList.end() )
{
GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "OgreWindowContext: Available Ogre render system: " + (*i)->getFriendlyName() );
if ( ogreRenderSystem == (*i)->getName() )
{
GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "OgreWindowContext: Found desired/preferred Ogre render system: " + (*i)->getFriendlyName() );
renderSystem = (*i);
}
++i;
}
if ( renderSystem == nullptr )
{
GUCEF_WARNING_LOG( CORE::LOGLEVEL_IMPORTANT, "OgreWindowContext: Preferred Ogre render systems not available, using first available alternative: " + (*rsList.begin())->getFriendlyName() );
renderSystem = *rsList.begin();
}
ogreRoot->setRenderSystem( renderSystem );
m_sceneManager = ogreRoot->createSceneManager( Ogre::ST_GENERIC );
m_renderWindow = ogreRoot->initialise( false, title );
}
m_renderWindow = ogreRoot->createRenderWindow( title,
videoSettings.GetResolutionWidthInPixels(),
videoSettings.GetResolutionHeightInPixels(),
videoSettings.GetFullscreenState(),
&options );
// Grab the main app pulse generator and set the update interval for the context to the desired refresh rate
CORE::CPulseGenerator& pulseGenerator = CORE::CCoreGlobal::Instance()->GetPulseGenerator();
pulseGenerator.RequestPeriodicPulses( this, 1000 / videoSettings.GetFrequency() );
SubscribeTo( &pulseGenerator );
GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "OgreWindowContext: Succesfully created Ogre rendering context" );
m_initialized = true;
return true;
}
return false;
}
示例11: test
void test()
{
Ogre::Root* pOgre = new Ogre::Root("", "");
pOgre->loadPlugin(RENDER_SYSTEM);
pOgre->setRenderSystem(pOgre->getAvailableRenderers().front());
pOgre->initialise(false);
Ogre::NameValuePairList lArgs;
//lArgs["externalWindowHandle"] = bk::format("%d", (bk::uint)l_window.get_handle()).astr;
Ogre::RenderWindow* pWindow = pOgre->createRenderWindow("Heart|Dockyard", 1024, 768, false, &lArgs);
Ogre::SceneManager* pSceneManager = pOgre->createSceneManager(Ogre::ST_GENERIC,"SceneManager");
pSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
pSceneManager->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(new Ogre::FocusedShadowCameraSetup()));
pSceneManager->setAmbientLight(Ogre::ColourValue(0.1f, 0.1f, 0.1f));
Ogre::Camera* pCamera = pSceneManager->createCamera("Camera");
pCamera->setFixedYawAxis(true, Ogre::Vector3::UNIT_Z);
pCamera->setPosition(Ogre::Vector3(0.0f, 50.0f, 20.0f));
pCamera->lookAt(Ogre::Vector3(0.0f, 0.0f, 0.0f));
pCamera->setNearClipDistance(0.1f);
pCamera->setFarClipDistance(100.0f);
Ogre::Viewport* pViewport = pWindow->addViewport(pCamera);
pViewport->setBackgroundColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f));
pCamera->setAspectRatio(Ogre::Real(pViewport->getActualWidth()) / Ogre::Real(pViewport->getActualHeight()));
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../data/dockyard.zip", "Zip", "Dockyard", true);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
Ogre::MeshManager::getSingleton().createPlane("GroundPlane", "Dockyard", Ogre::Plane(0.0f, 0.0f, 1.0f, 0.0f), 100.0f, 100.0f, 100, 100, true, 1, 3.0f, 3.0f);
Ogre::Entity* pGroundEntity = pSceneManager->createEntity("GroundPlane");
pGroundEntity->setMaterialName("Examples/Rockwall");
pGroundEntity->setCastShadows(false);
pGroundEntity->getSubEntity(0)->getMaterial()->setShadingMode(Ogre::SO_PHONG);
Ogre::SceneNode* pGroundNode = pSceneManager->getRootSceneNode()->createChildSceneNode();
pGroundNode->attachObject(pGroundEntity);
Ogre::Entity* pCubeEntity = pSceneManager->createEntity("Cube", Ogre::SceneManager::PT_CUBE);
pCubeEntity->setMaterialName("Examples/10PointBlock");
pCubeEntity->setCastShadows(true);
Ogre::SceneNode* pCubeNode = pSceneManager->getRootSceneNode()->createChildSceneNode();
pCubeNode->attachObject(pCubeEntity);
pCubeNode->setPosition(0.0f, 0.0f, 5.f);
pCubeNode->setScale(0.1f, 0.1f, 0.1f);
Ogre::ColourValue lColour1(1.0f, 1.0f, 1.0f);
Ogre::ColourValue lColour2(1.0f, 1.0f, 1.0f);
Ogre::ColourValue lColour3(1.0f, 1.0f, 1.0f);
Ogre::Light* pLight1 = pSceneManager->createLight();
pLight1->setType(Ogre::Light::LT_SPOTLIGHT);
pLight1->setPosition(30.0f, 30.0f, 30.0f);
pLight1->setDirection(-1.0f, -1.0f, -1.0f);
pLight1->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
pLight1->setDiffuseColour(lColour1 * 0.5f);
Ogre::Light* pLight2 = pSceneManager->createLight();
pLight2->setType(Ogre::Light::LT_SPOTLIGHT);
pLight2->setPosition(-30.0f, 30.0f, 30.0f);
pLight2->setDirection(1.0f, -1.0f, -1.0f);
pLight2->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
pLight2->setDiffuseColour(lColour2 * 0.5f);
Ogre::Light* pLight3 = pSceneManager->createLight();
pLight3->setType(Ogre::Light::LT_SPOTLIGHT);
pLight3->setPosition(30.0f, -30.0f, 30.0f);
pLight3->setDirection(-1.0f, 1.0f, -1.0f);
pLight3->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
pLight3->setDiffuseColour(lColour3 * 0.5f);
Ogre::Overlay* pMenuOverlay = Ogre::OverlayManager::getSingleton().create("Menu");
Ogre::OverlayElement* pMenu = Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "Menu");
pMenu->setMetricsMode(Ogre::GMM_PIXELS);
pMenu->setWidth(200);
pMenu->setHeight(200);
pMenu->setTop(30);
pMenu->setLeft(30);
pMenu->setMaterialName("Examples/BumpyMetal");
if (pMenu->isContainer()) pMenuOverlay->add2D(static_cast<Ogre::OverlayContainer*>(pMenu));
pMenuOverlay->show();
pOgre->startRendering();
}
示例12: WinMain
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
#else
int main (int argc, char *argv[]) {
#endif
Ogre::Root *ogre;
Ogre::RenderWindow *window;
Ogre::SceneManager *sceneMgr;
Ogre::SceneManager *guiSceneMgr;
Ogre::Camera *camera;
Ogre::Camera *guiCamera;
// fire up an Ogre rendering window. Clearing the first two (of three) params will let us
// specify plugins and resources in code instead of via text file
ogre = new Ogre::Root("", "");
#if defined(_DEBUG)
ogre->loadPlugin("RenderSystem_GL_d");
#else
ogre->loadPlugin("RenderSystem_GL");
#endif
Ogre::RenderSystemList *renderSystems = NULL;
Ogre::RenderSystemList::iterator r_it;
renderSystems = ogre->getAvailableRenderers();
r_it = renderSystems->begin();
ogre->setRenderSystem(*r_it);
ogre->initialise(false);
// load common plugins
#if defined(_DEBUG)
//ogre->loadPlugin("Plugin_CgProgramManager_d");
ogre->loadPlugin("Plugin_OctreeSceneManager_d");
#else
//ogre->loadPlugin("Plugin_CgProgramManager");
ogre->loadPlugin("Plugin_OctreeSceneManager");
#endif
// load the basic resource location(s)
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("resource", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("resource/gui.zip", "Zip", "GUI");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("meshes", "FileSystem", "Meshes");
#if defined(WIN32)
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("c:\\windows\\fonts", "FileSystem", "GUI");
#endif
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("GUI");
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Meshes");
// setup main window; hardcode some defaults for the sake of presentation
Ogre::NameValuePairList opts;
opts["resolution"] = "1024x768";
opts["fullscreen"] = "false";
opts["vsync"] = "false";
// create a rendering window with the title "CDK"
window = ogre->createRenderWindow("Bouwgame Client v0.1", 1024, 768, false, &opts);
// since this is basically a CEGUI app, we can use the ST_GENERIC scene manager for now; in a later article
// we'll see how to change this
sceneMgr = ogre->createSceneManager(Ogre::ST_GENERIC);
guiSceneMgr = ogre->createSceneManager(Ogre::ST_GENERIC);
guiCamera = guiSceneMgr->createCamera("GUICamera");
guiCamera->setNearClipDistance(5);
camera = sceneMgr->createCamera("camera");
camera->setNearClipDistance(5);
Ogre::Viewport* vp = window->addViewport(guiCamera);
vp->setBackgroundColour(Ogre::ColourValue(0.2f,0.2f,0.8f));
/* ambient light */
sceneMgr->setAmbientLight(Ogre::ColourValue(0.8, 0.8, 0.8));
sceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
/* meshes */
Ogre::Entity* ent = sceneMgr->createEntity( "BouwPlaatsEntity", "world.mesh" );
Ogre::SceneNode* node = sceneMgr->getRootSceneNode()->createChildSceneNode("BouwNode", Ogre::Vector3(0, 0, 0));
node->attachObject(ent);
//node->setScale(Ogre::Vector3(0.7,0.7,0.7));
ent = sceneMgr->createEntity("plaats", "bouwplaats_step_00.mesh");
Ogre::Vector3 size = ent->getBoundingBox().getSize();
Ogre::LogManager::getSingletonPtr()->getDefaultLog()->logMessage(Ogre::String("Bouwplaats size: ") + Ogre::StringConverter::toString(size));
size = ent->getBoundingBox().getMaximum();
Ogre::LogManager::getSingletonPtr()->getDefaultLog()->logMessage(Ogre::String("Bouwplaats max: ") + Ogre::StringConverter::toString(size));
size = ent->getBoundingBox().getMinimum();
Ogre::LogManager::getSingletonPtr()->getDefaultLog()->logMessage(Ogre::String("Bouwplaats min: ") + Ogre::StringConverter::toString(size));
Ogre::Entity* ent1 = sceneMgr->createEntity( "KeetEntity", "keet.mesh" );
Ogre::SceneNode* scenenode = sceneMgr->getRootSceneNode()->createChildSceneNode("KeetNode", Ogre::Vector3(0, 0, 0));
scenenode->attachObject(ent1);
Ogre::Entity* ent2 = sceneMgr->createEntity( "HekjeEntity", "hekje.mesh" );
Ogre::SceneNode* scenenode2 = sceneMgr->getRootSceneNode()->createChildSceneNode("HekjeNode", Ogre::Vector3(0, -100, 0));
scenenode2->attachObject(ent2);
scenenode2->setScale(Ogre::Vector3(400,0,100));
// most examples get the viewport size to calculate this; for now, we'll just
//.........这里部分代码省略.........
示例13: mainSetupAndRunOgre
int mainSetupAndRunOgre()
{
Ogre::LogManager* log_manager = 0;
Ogre::Root* root = 0;
#ifdef FREEORION_MACOSX
OISInput* ois_input_plugin = 0;
#elif defined(OGRE_STATIC_LIB)
OISInput* ois_input_plugin = 0;
Ogre::OctreePlugin* octree_plugin = 0;
Ogre::ParticleFXPlugin* particle_fx_plugin = 0;
Ogre::GLPlugin* gl_plugin = 0;
#endif
try {
using namespace Ogre;
log_manager = new LogManager();
log_manager->createLog((GetUserDir() / "ogre.log").string(), true, false);
root = new Root((GetRootDataDir() / "ogre_plugins.cfg").string());
// this line is needed on some Linux systems which otherwise will crash with
// errors about GLX_icon.png being missing.
Ogre::ResourceGroupManager::getSingleton().addResourceLocation((ClientUI::ArtDir() / ".").string(),
"FileSystem", "General");
#if defined(OGRE_STATIC_LIB)
octree_plugin = new Ogre::OctreePlugin;
particle_fx_plugin = new Ogre::ParticleFXPlugin;
gl_plugin = new Ogre::GLPlugin;
root->installPlugin(octree_plugin);
root->installPlugin(particle_fx_plugin);
root->installPlugin(gl_plugin);
#endif
RenderSystem* selected_render_system = root->getRenderSystemByName("OpenGL Rendering Subsystem");
if (selected_render_system == 0)
throw std::runtime_error("Failed to find an Ogre GL render system.");
root->setRenderSystem(selected_render_system);
int colour_depth = GetOptionsDB().Get<int>("color-depth");
bool fullscreen = GetOptionsDB().Get<bool>("fullscreen");
std::pair<int, int> width_height = HumanClientApp::GetWindowWidthHeight(selected_render_system);
int width(width_height.first), height(width_height.second);
selected_render_system->setConfigOption("Full Screen", fullscreen ? "Yes" : "No");
std::string video_mode_str =
boost::io::str(boost::format("%1% x %2% @ %3%-bit colour") %
width %
height %
colour_depth);
selected_render_system->setConfigOption("Video Mode", video_mode_str);
RenderWindow* window = root->initialise(true, "FreeOrion " + FreeOrionVersionString());
#ifdef FREEORION_WIN32
# ifdef IDI_ICON1
// set window icon to embedded application icon
HWND hwnd;
window->getCustomAttribute("WINDOW", &hwnd);
HINSTANCE hInst = (HINSTANCE)GetModuleHandle(NULL);
SetClassLong (hwnd, GCL_HICON,
(LONG)LoadIcon (hInst, MAKEINTRESOURCE (IDI_ICON1)));
# endif
#endif
SceneManager* scene_manager = root->createSceneManager("OctreeSceneManager", "SceneMgr");
Camera* camera = scene_manager->createCamera("Camera");
camera->setPosition(Vector3(0, 0, 500)); // Position it at 500 in Z direction
camera->lookAt(Vector3(0, 0, -300)); // Look back along -Z
camera->setNearClipDistance(5);
Viewport* viewport = window->addViewport(camera);
viewport->setBackgroundColour(ColourValue(0, 0, 0));
//EntityRenderer entity_renderer(scene_manager);
parse::init();
HumanClientApp app(root, window, scene_manager, camera, viewport, (GetRootDataDir() / "OISInput.cfg").string());
#ifdef FREEORION_MACOSX
ois_input_plugin = new OISInput;
root->installPlugin(ois_input_plugin);
#elif defined(OGRE_STATIC_LIB)
ois_input_plugin = new OISInput;
root->installPlugin(ois_input_plugin);
#else
root->loadPlugin(OGRE_INPUT_PLUGIN_NAME);
#endif
if (GetOptionsDB().Get<bool>("quickstart")) {
// immediately start the server, establish network connections, and
// go into a single player game, using default universe options (a
// standard quickstart, without requiring the user to click the
// quickstart button).
app.NewSinglePlayerGame(true); // acceptable to call before app()
//.........这里部分代码省略.........
示例14: initialize
void gkEngine::initialize()
{
if (m_initialized) return;
gkUserDefs& defs = getUserDefs();
gkLogger::enable(defs.log, defs.verbose);
if (defs.rendersystem == OGRE_RS_UNKNOWN)
{
gkPrintf("Unknown rendersystem!\n");
return;
}
Ogre::Root* root = new Ogre::Root("", "");
m_private->root = root;
m_private->plugin_factory->createRenderSystem(root, defs.rendersystem);
m_private->plugin_factory->createParticleSystem(root);
m_private->archive_factory->addArchiveFactory();
const Ogre::RenderSystemList& renderers = root->getAvailableRenderers();
if (renderers.empty())
{
gkPrintf("No rendersystems present\n");
return;
}
root->setRenderSystem(renderers[0]);
#if defined(_MSC_VER) && defined(OGRE_BUILD_RENDERSYSTEM_GLES2)
renderers[0]->setConfigOption("RTT Preferred Mode", "Copy"); //angleproject gles2
#endif
root->initialise(false);
m_private->windowsystem = new gkWindowSystem();
// gk Managers
new gkResourceGroupManager();
new gkSceneManager();
#ifdef OGREKIT_USE_NNODE
new gkNodeManager();
#endif
new gkBlendLoader();
new gkTextManager();
new gkMessageManager();
new gkMeshManager();
new gkSkeletonManager();
#ifdef OGREKIT_USE_PARTICLE
new gkParticleManager();
#endif
new gkHUDManager();
new gkGroupManager();
new gkGameObjectManager();
new gkAnimationManager();
#ifdef OGREKIT_USE_LUA
new gkLuaManager();
#endif
#if defined(OGREKIT_COMPILE_OGRE_SCRIPTS) || defined(OGREKIT_COMPILE_LIBROCKET)
new gkFontManager();
#endif
#ifdef OGREKIT_COMPILE_LIBROCKET
new gkGUIManager();
#endif
#ifdef OGREKIT_OPENAL_SOUND
new gkSoundManager();
#endif
#ifdef OGREKIT_USE_COMPOSITOR
new gkCompositorManager();
#endif
initializeWindow();
if (!defs.resources.empty())
loadResources(defs.resources);
#ifdef OGREKIT_USE_RTSHADER_SYSTEM
defs.hasFixedCapability = renderers[0]->getCapabilities()->hasCapability(Ogre::RSC_FIXED_FUNCTION);
gkResourceGroupManager::getSingleton().initRTShaderSystem(
m_private->plugin_factory->getShaderLanguage(), defs.shaderCachePath, defs.hasFixedCapability);
#endif
// create the builtin resource group
gkResourceGroupManager::getSingleton().createResourceGroup(GK_BUILTIN_GROUP);
gkResourceGroupManager::getSingleton().initialiseAllResourceGroups();
#ifdef OGREKIT_USE_PARTICLE
gkParticleManager::getSingleton().initialize();
#endif
#ifdef OGREKIT_USE_COMPOSITOR
gkCompositorManager::getSingleton().initialize();
#endif
// debug info
//.........这里部分代码省略.........
示例15: mainSetupAndRunOgre
int mainSetupAndRunOgre() {
Ogre::LogManager* log_manager = 0;
Ogre::Root* root = 0;
OISInput* ois_input_plugin = 0;
#ifdef OGRE_STATIC_LIB
Ogre::OctreePlugin* octree_plugin = 0;
Ogre::ParticleFXPlugin* particle_fx_plugin = 0;
Ogre::GLPlugin* gl_plugin = 0;
#endif
try {
using namespace Ogre;
log_manager = new LogManager();
#ifndef FREEORION_WIN32
log_manager->createLog((GetUserDir() / "ogre.log").string(), true, false);
root = new Root((GetRootDataDir() / "ogre_plugins.cfg").string());
// this line is needed on some Linux systems which otherwise will crash with
// errors about GLX_icon.png being missing.
Ogre::ResourceGroupManager::getSingleton().addResourceLocation((ClientUI::ArtDir() / ".").string(),
"FileSystem", "General");
#else
boost::filesystem::path::string_type file_native = (GetUserDir() / "ogre.log").native();
std::string ogre_log_file;
utf8::utf16to8(file_native.begin(), file_native.end(), std::back_inserter(ogre_log_file));
log_manager->createLog(ogre_log_file, true, false);
// for some reason, for this file, the built-in path conversion seems to work properly
std::string plugins_cfg_file = (GetRootDataDir() / "ogre_plugins.cfg").string();
root = new Root(plugins_cfg_file);
#endif
#if defined(OGRE_STATIC_LIB)
octree_plugin = new Ogre::OctreePlugin;
particle_fx_plugin = new Ogre::ParticleFXPlugin;
gl_plugin = new Ogre::GLPlugin;
root->installPlugin(octree_plugin);
root->installPlugin(particle_fx_plugin);
root->installPlugin(gl_plugin);
#endif
RenderSystem* selected_render_system = root->getRenderSystemByName("OpenGL Rendering Subsystem");
if (!selected_render_system)
throw std::runtime_error("Failed to find an Ogre GL render system.");
root->setRenderSystem(selected_render_system);
int colour_depth = GetOptionsDB().Get<int>("color-depth");
bool fullscreen = GetOptionsDB().Get<bool>("fullscreen");
std::pair<int, int> width_height = HumanClientApp::GetWindowWidthHeight(selected_render_system);
int width(width_height.first), height(width_height.second);
std::pair<int, int> left_top = HumanClientApp::GetWindowLeftTop();
int left(left_top.first), top(left_top.second);
root->initialise(false);
Ogre::NameValuePairList misc_window_params;
misc_window_params["title"] = "FreeOrion " + FreeOrionVersionString();
misc_window_params["colourDepth"] = boost::lexical_cast<std::string>(colour_depth);
misc_window_params["left"] = boost::lexical_cast<std::string>(left);
misc_window_params["top"] = boost::lexical_cast<std::string>(top);
misc_window_params["macAPI"] = "carbon";
misc_window_params["border"] = "resize";
if (fullscreen)
misc_window_params["monitorIndex"] = boost::lexical_cast<std::string>(
GetOptionsDB().Get<int>("fullscreen-monitor-id"));
RenderWindow* window = root->createRenderWindow("FreeOrion " + FreeOrionVersionString(),
width, height, fullscreen, &misc_window_params);
#ifdef FREEORION_WIN32
# ifdef IDI_ICON1
// set window icon to embedded application icon
HWND hwnd;
window->getCustomAttribute("WINDOW", &hwnd);
HINSTANCE hInst = (HINSTANCE)GetModuleHandle(NULL);
SetClassLong (hwnd, GCL_HICON,
(LONG)LoadIcon (hInst, MAKEINTRESOURCE (IDI_ICON1)));
# endif
#endif
SceneManager* scene_manager = root->createSceneManager("OctreeSceneManager", "SceneMgr");
Camera* camera = scene_manager->createCamera("Camera");
camera->setPosition(Vector3(0, 0, 500)); // Position it at 500 in Z direction
camera->lookAt(Vector3(0, 0, -300)); // Look back along -Z
camera->setNearClipDistance(5);
Viewport* viewport = window->addViewport(camera);
viewport->setBackgroundColour(ColourValue(0, 0, 0));
//EntityRenderer entity_renderer(scene_manager);
parse::init();
HumanClientApp app(root, window, scene_manager, camera, viewport, GetRootDataDir() / "OISInput.cfg");
ois_input_plugin = new OISInput;
//.........这里部分代码省略.........