Here is the reproduction code:
Code: Select all
#include <iostream>
#include "OgreWindowEventUtilities.h"
#include "Vao/OgreVaoManager.h"
#include "OgreRoot.h"
#include "OgreRenderSystem.h"
#include "OgreWindow.h"
#include "OgreCamera.h"
#include "Compositor/OgreCompositorManager2.h"
int main()
{
//static Ogre::VaoManager* vaoManager;
Ogre::Root* myRoot = OGRE_NEW Ogre::Root();
//myRoot = OGRE_NEW Ogre::Root(pluginsPath,
// mWriteAccessFolder + "ogre.cfg",
// mWriteAccessFolder + "Ogre.log");
//Ogre::Root *root = new Ogre::Root("", "", "ogre.log");
#if defined(_DEBUG)
myRoot->loadPlugin("RenderSystem_Direct3D11_d.dll");
myRoot->loadPlugin("RenderSystem_GL3Plus_d.dll");
/*myRoot->loadPlugin("/usr/lib/OGRE/Plugin_ParticleFX_d.dll");
myRoot->loadPlugin("/usr/lib/OGRE/Plugin_CgProgramManager_d.dll");
myRoot->loadPlugin("/usr/lib/OGRE/Plugin_OctreeSceneManager_d.dll");
myRoot->loadPlugin("/usr/lib/OGRE/Plugin_PCZSceneManager_d.dll");
myRoot->loadPlugin("/usr/lib/OGRE/Plugin_OctreeZone_d.dll");
myRoot->loadPlugin("/usr/lib/OGRE/Plugin_BSPSceneManager_d.dll");*/
//Linux
//root->loadPlugin("/usr/local/lib/OGRE/RenderSystem_GL_d");
#else
myRoot->loadPlugin("RenderSystem_GL3Plus.dll");
myRoot->loadPlugin("RenderSystem_Direct3D11.dll");
//Linux
//root->loadPlugin("/usr/local/lib/OGRE/RenderSystem_GL");
#endif
Ogre::RenderSystemList::const_iterator renderers = myRoot->getAvailableRenderers().begin();
while (renderers != myRoot->getAvailableRenderers().end())
{
Ogre::String rName = (*renderers)->getName();
//std::cout << "vertex " << rName << std::endl;
if (rName == "Direct3D11 Rendering Subsystem")//Direct3D11 Rendering Subsystem, OpenGL 3+ Rendering Subsystem
break;
renderers++;
}
Ogre::RenderSystem* renderSystem = *renderers;
/*Ogre::ConfigOptionMap ConfigOptions = renderSystem->getConfigOptions();
for (Ogre::ConfigOptionMap::iterator itr = ConfigOptions.begin(); itr != ConfigOptions.end(); ++itr)
{
std::cout << "Config option: " << itr->first << std::endl;
for (int i = 0; i < itr->second.possibleValues.size(); i++)
{
std::cout << "possibleValues: " << itr->second.possibleValues[i] << std::endl;
}
}//*/
renderSystem->setConfigOption("Full Screen", "No");
renderSystem->setConfigOption("Video Mode", "1920 x 1080 @ 32-bit colour"); //1920
//renderSystem->setConfigOption("Display Frequency", "60 Hz");
renderSystem->setConfigOption("FSAA", "8"); //stutters at 16
//renderSystem->setConfigOption("Fixed Pipeline Enabled", "Yes");
//renderSystem->setConfigOption("RTT Preferred Mode", "FBO");
//renderSystem->setConfigOption("VSync", "Yes");
renderSystem->setConfigOption("sRGB Gamma Conversion", "Yes");
myRoot->setRenderSystem(renderSystem);
//Ogre::NameValuePairList params;
//params.insert(std::make_pair("gamma", "true"));
//#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT
// params.insert(std::make_pair("externalWindowHandle", winHandle));
//#else
// params.insert(std::make_pair("parentWindowHandle", winHandle));
//#endif
// params.insert(std::make_pair("title", windowTitle));
// params.insert(std::make_pair("gamma", cfgOpts["sRGB Gamma Conversion"].currentValue));
// params.insert(std::make_pair("FSAA", cfgOpts["FSAA"].currentValue));
// params.insert(std::make_pair("vsync", cfgOpts["VSync"].currentValue));
// params.insert(std::make_pair("reverse_depth", "Yes"));
Ogre::Window* myWindow = myRoot->initialise(true, "Ogre Window");
// myWindow = myRoot->createRenderWindow("Ogre Window", 1920, 1080, false, params);
float aspectRat = (float(myWindow->getWidth())) / (float(myWindow->getHeight()));
Ogre::SceneManager* mySceneManager = myRoot->createSceneManager(Ogre::ST_GENERIC, 1, "InstanceName");
Ogre::SceneNode* myRootSceneNode = mySceneManager->getRootSceneNode();
//vaoManager = renderSystem->getVaoManager();
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/models", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/materials/textures", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/materials/textures/Cubemaps", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/packs/OgreCore.zip", "Zip");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/2.0/scripts/materials/TutorialSky_Postprocess", "FileSystem");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/2.0/scripts/materials", "FileSystem");
// Load all resources except compositor
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(false);
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/2.0/scripts/Compositors", "FileSystem", "Compositors");
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Compositors", false);
myRoot->clearEventTimes();
Ogre::Camera* myCamera = mySceneManager->createCamera("cameraName");
myCamera->setPosition(0, 0, 0);
myCamera->lookAt(50, 0, 0);
myCamera->setNearClipDistance(0.12f); //1.0f
myCamera->setFarClipDistance(3000.0f);
myCamera->setAspectRatio(aspectRat);
Ogre::CompositorManager2* compositorManager = myRoot->getCompositorManager2();
const Ogre::String workspaceName("MyOwnWorkspace");
if (!compositorManager->hasWorkspaceDefinition(workspaceName))
compositorManager->createBasicWorkspaceDef(workspaceName, Ogre::ColourValue(Ogre::Real(127) / Ogre::Real(255), Ogre::Real(188) / Ogre::Real(255), Ogre::Real(255) / Ogre::Real(255)) * 0.9);
compositorManager->addWorkspace(mySceneManager, myWindow->getTexture(), myCamera, "MyOwnWorkspace", true);
std::cout << "myWindow->isClosed(): " << myWindow->isClosed() << std::endl;
while (!myWindow->isClosed())
{
std::cout << "myWindow->isClosed(): " << myWindow->isClosed() << std::endl;
myRoot->renderOneFrame();
Ogre::WindowEventUtilities::messagePump();
}
}