Browse Source

Window loops now run on the render thread

Marko Pintera 13 years ago
parent
commit
289ddb78eb

+ 2 - 2
CamelotClient/CamelotClient.cpp

@@ -27,8 +27,8 @@ using namespace CamelotEngine;
 
 
 int _tmain(int argc, _TCHAR* argv[])
 int _tmain(int argc, _TCHAR* argv[])
 {
 {
-	//gApplication().startUp("CamelotGLRenderSystem", "CamelotForwardRenderer");
-	gApplication().startUp("CamelotD3D9RenderSystem", "CamelotForwardRenderer");
+	gApplication().startUp("CamelotGLRenderSystem", "CamelotForwardRenderer");
+	//gApplication().startUp("CamelotD3D9RenderSystem", "CamelotForwardRenderer");
 
 
 	RenderSystem* renderSystem = RenderSystemManager::getActive();
 	RenderSystem* renderSystem = RenderSystemManager::getActive();
 	RenderWindow* renderWindow = gApplication().getPrimaryRenderWindow();
 	RenderWindow* renderWindow = gApplication().getPrimaryRenderWindow();

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9RenderSystemFactory.cpp

@@ -7,7 +7,7 @@ namespace CamelotEngine
 	#ifdef CM_STATIC_LIB
 	#ifdef CM_STATIC_LIB
 		HINSTANCE hInst = GetModuleHandle( NULL );
 		HINSTANCE hInst = GetModuleHandle( NULL );
 	#else
 	#else
-		HINSTANCE hInst = GetModuleHandle( "CamelotEngine.dll" ); // TODO - Change name if I plan on using external dll
+		HINSTANCE hInst = GetModuleHandle( "CamelotD3D9RenderSystem.dll" );
 	#endif
 	#endif
 
 
 		return RenderSystemPtr(new D3D9RenderSystem(hInst));
 		return RenderSystemPtr(new D3D9RenderSystem(hInst));

+ 2 - 6
CamelotGLRenderer/Source/CmWin32Window.cpp

@@ -74,11 +74,7 @@ namespace CamelotEngine {
 #ifdef CM_STATIC_LIB
 #ifdef CM_STATIC_LIB
 		HINSTANCE hInst = GetModuleHandle( NULL );
 		HINSTANCE hInst = GetModuleHandle( NULL );
 #else
 #else
-#  if CM_DEBUG_MODE == 1
-		HINSTANCE hInst = GetModuleHandle("RenderSystem_GL_d.dll");
-#  else
-		HINSTANCE hInst = GetModuleHandle("RenderSystem_GL.dll");
-#  endif
+		HINSTANCE hInst = GetModuleHandle("CamelotGLRenderSystem.dll");
 #endif
 #endif
 
 
 		mHWnd = 0;
 		mHWnd = 0;
@@ -342,7 +338,7 @@ namespace CamelotEngine {
 			}
 			}
 
 
 			// Pass pointer to self as WM_CREATE parameter
 			// Pass pointer to self as WM_CREATE parameter
-			mHWnd = CreateWindowEx(dwStyleEx, "OgreGLWindow", title.c_str(),
+			mHWnd = CreateWindowEx(dwStyleEx, "GLWindow", title.c_str(),
 				dwStyle, mLeft, mTop, mWidth, mHeight, parent, 0, hInst, this);
 				dwStyle, mLeft, mTop, mWidth, mHeight, parent, 0, hInst, this);
 
 
 			WindowEventUtilities::_addRenderWindow(this);			
 			WindowEventUtilities::_addRenderWindow(this);			

+ 5 - 0
CamelotRenderer/Include/CmApplication.h

@@ -40,6 +40,11 @@ namespace CamelotEngine
 		 * @brief	Callback called from the render thread in order to initialize resources.
 		 * @brief	Callback called from the render thread in order to initialize resources.
 		 */
 		 */
 		void updateResourcesCallback();
 		void updateResourcesCallback();
+
+		/**
+		 * @brief	Runs the OS specific message pump.
+		 */
+		void updateMessagePump();
 	};
 	};
 
 
 	CM_EXPORT Application& gApplication();
 	CM_EXPORT Application& gApplication();

+ 6 - 2
CamelotRenderer/Source/CmApplication.cpp

@@ -62,6 +62,7 @@ namespace CamelotEngine
 
 
 		loadPlugin("CamelotOISInput"); // TODO - Load this automatically somehow
 		loadPlugin("CamelotOISInput"); // TODO - Load this automatically somehow
 
 
+		renderSystem->addPreRenderThreadUpdateCallback(boost::bind(&Application::updateMessagePump, this));
 		renderSystem->addPreRenderThreadUpdateCallback(boost::bind(&Application::updateResourcesCallback, this));
 		renderSystem->addPreRenderThreadUpdateCallback(boost::bind(&Application::updateResourcesCallback, this));
 	}
 	}
 
 
@@ -69,8 +70,6 @@ namespace CamelotEngine
 	{
 	{
 		while(true)
 		while(true)
 		{
 		{
-			WindowEventUtilities::messagePump();
-
 			gSceneManager().update();
 			gSceneManager().update();
 
 
 			RendererManager::getActive()->renderAll();
 			RendererManager::getActive()->renderAll();
@@ -83,6 +82,11 @@ namespace CamelotEngine
 		}
 		}
 	}
 	}
 
 
+	void Application::updateMessagePump()
+	{
+		WindowEventUtilities::messagePump();
+	}
+
 	void Application::updateResourcesCallback()
 	void Application::updateResourcesCallback()
 	{
 	{
 		gResources().update();
 		gResources().update();

+ 1 - 0
CamelotRenderer/TODO.txt

@@ -16,6 +16,7 @@ High-level TODO:
 
 
 
 
 Command buffer TODO:
 Command buffer TODO:
+ - Make sure window gets created on the main, and not the render thread
  - My current approach doesn't allow multiple threads to use the RenderSystem (contexts should be handled differently)
  - My current approach doesn't allow multiple threads to use the RenderSystem (contexts should be handled differently)
    - Instead of requiring the user to constantly call setActiveContext, make the call peristent per thread. 
    - Instead of requiring the user to constantly call setActiveContext, make the call peristent per thread. 
    - Store sequential thread idx in local thread storage, and then we can easily look up a context for a thread and
    - Store sequential thread idx in local thread storage, and then we can easily look up a context for a thread and