Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window::isClosed wrongly returns true in D3D11 #113

Closed
darksylinc opened this issue Jul 12, 2020 · 0 comments
Closed

Window::isClosed wrongly returns true in D3D11 #113

darksylinc opened this issue Jul 12, 2020 · 0 comments
Assignees
Labels
bug Something isn't working D3D11 Issue affects D3D11 specifically. Don't use this tag if all RenderSystems are affected

Comments

@darksylinc
Copy link
Member

darksylinc commented Jul 12, 2020

System Information

  • Ogre Version: 2.2.3
  • Operating System / Platform: Windows 10
  • RenderSystem: D3D11
  • GPU: N/A

Detailled description

It works correctly in OpenGl.

See https://forums.ogre3d.org/viewtopic.php?f=25&t=95906

#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();

	}
}
@darksylinc darksylinc added bug Something isn't working D3D11 Issue affects D3D11 specifically. Don't use this tag if all RenderSystems are affected labels Jul 12, 2020
@darksylinc darksylinc self-assigned this Jul 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working D3D11 Issue affects D3D11 specifically. Don't use this tag if all RenderSystems are affected
Projects
None yet
Development

No branches or pull requests

1 participant