Преглед изворни кода

Fixed x64 issue with window handles

Marko Pintera пре 13 година
родитељ
комит
47f4d31dda
26 измењених фајлова са 46 додато и 40 уклоњено
  1. 1 1
      CamelotD3D9Renderer/Include/CmD3D9MultiRenderTarget.h
  2. 1 1
      CamelotD3D9Renderer/Include/CmD3D9RenderWindow.h
  3. 1 1
      CamelotD3D9Renderer/Include/CmD3D9Texture.h
  4. 2 2
      CamelotD3D9Renderer/Source/CmD3D9MultiRenderTarget.cpp
  5. 5 5
      CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp
  6. 1 1
      CamelotD3D9Renderer/Source/CmD3D9RenderWindow.cpp
  7. 1 1
      CamelotD3D9Renderer/Source/CmD3D9Texture.cpp
  8. 1 1
      CamelotGLRenderer/Include/CmGLFBOMultiRenderTarget.h
  9. 1 1
      CamelotGLRenderer/Include/CmGLFBORenderTexture.h
  10. 1 1
      CamelotGLRenderer/Include/CmGLPBRenderTexture.h
  11. 1 1
      CamelotGLRenderer/Include/CmGLRenderTexture.h
  12. 1 1
      CamelotGLRenderer/Include/CmWin32Window.h
  13. 2 2
      CamelotGLRenderer/Source/CmGLFBOMultiRenderTarget.cpp
  14. 2 2
      CamelotGLRenderer/Source/CmGLFBORenderTexture.cpp
  15. 3 3
      CamelotGLRenderer/Source/CmGLPBRenderTexture.cpp
  16. 2 2
      CamelotGLRenderer/Source/CmGLRenderSystem.cpp
  17. 2 2
      CamelotGLRenderer/Source/CmGLRenderTexture.cpp
  18. 1 1
      CamelotGLRenderer/Source/CmWin32Window.cpp
  19. 4 1
      CamelotOISInput/Source/CmOISPlugin.cpp
  20. 1 1
      CamelotRenderer/Include/CmApplication.h
  21. 1 1
      CamelotRenderer/Include/CmRenderTarget.h
  22. 5 3
      CamelotRenderer/Source/CmApplication.cpp
  23. 1 1
      CamelotRenderer/Source/CmRenderTarget.cpp
  24. 1 1
      CamelotRenderer/Source/CmWindowEventUtilities.cpp
  25. 3 3
      CamelotRenderer/Source/Win32/CmOSCursorImpl.cpp
  26. 1 0
      CamelotRenderer/TODO.txt

+ 1 - 1
CamelotD3D9Renderer/Include/CmD3D9MultiRenderTarget.h

@@ -43,7 +43,7 @@ namespace CamelotEngine {
 
         virtual void update(bool swapBuffers);
 
-		virtual void getCustomAttribute( const String& name, void *pData );
+		virtual void getCustomAttribute_internal( const String& name, void *pData );
 
 		bool requiresTextureFlipping() const { return false; }
 	private:

+ 1 - 1
CamelotD3D9Renderer/Include/CmD3D9RenderWindow.h

@@ -63,7 +63,7 @@ namespace CamelotEngine
 		D3D9Device*			getDevice			();
 		void				setDevice			(D3D9Device* device);
 
-		void				getCustomAttribute	(const String& name, void* pData);
+		void				getCustomAttribute_internal	(const String& name, void* pData);
 		
 		/** Overridden - see RenderTarget.
 		*/

+ 1 - 1
CamelotD3D9Renderer/Include/CmD3D9Texture.h

@@ -189,7 +189,7 @@ namespace CamelotEngine {
 
 		virtual void update(bool swap);
 
-		virtual void getCustomAttribute( const String& name, void *pData );
+		virtual void getCustomAttribute_internal( const String& name, void *pData );
 
 		bool requiresTextureFlipping() const { return false; }
 

+ 2 - 2
CamelotD3D9Renderer/Source/CmD3D9MultiRenderTarget.cpp

@@ -54,7 +54,7 @@ namespace CamelotEngine
 		assert(attachment<CM_MAX_MULTIPLE_RENDER_TARGETS);
 		/// Get buffer and surface to bind to
 		D3D9HardwarePixelBuffer *buffer = 0;
-		target->getCustomAttribute("BUFFER", &buffer);
+		target->getCustomAttribute_internal("BUFFER", &buffer);
 		assert(buffer);
 
 		/// Find first non-null target
@@ -115,7 +115,7 @@ namespace CamelotEngine
 		}		
     }
 
-	void D3D9MultiRenderTarget::getCustomAttribute(const String& name, void *pData)
+	void D3D9MultiRenderTarget::getCustomAttribute_internal(const String& name, void *pData)
     {
 		if(name == "DDBACKBUFFER")
         {

+ 5 - 5
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -1045,7 +1045,7 @@ namespace CamelotEngine
 		// Retrieve render surfaces (up to CM_MAX_MULTIPLE_RENDER_TARGETS)
 		IDirect3DSurface9* pBack[CM_MAX_MULTIPLE_RENDER_TARGETS];
 		memset(pBack, 0, sizeof(pBack));
-		target->getCustomAttribute( "DDBACKBUFFER", &pBack );
+		target->getCustomAttribute_internal( "DDBACKBUFFER", &pBack );
 		if (!pBack[0])
 			return;
 
@@ -1059,7 +1059,7 @@ namespace CamelotEngine
 		}
 
 		if (!pDepth)
-			target->getCustomAttribute( "D3DZBUFFER", &pDepth );
+			target->getCustomAttribute_internal( "D3DZBUFFER", &pDepth );
 		if (!pDepth)
 		{
 			/// No depth buffer provided, use our own
@@ -2033,7 +2033,7 @@ namespace CamelotEngine
 			D3DFMT_A16B16G16R16F, D3DFMT_R32F, D3DFMT_G32R32F, 
 			D3DFMT_A32B32G32R32F};
 		IDirect3DSurface9* bbSurf;
-		renderWindow->getCustomAttribute("DDBACKBUFFER", &bbSurf);
+		renderWindow->getCustomAttribute_internal("DDBACKBUFFER", &bbSurf);
 		D3DSURFACE_DESC bbSurfDesc;
 		bbSurf->GetDesc(&bbSurfDesc);
 
@@ -2368,7 +2368,7 @@ namespace CamelotEngine
 		bool anySupported = false;
 
 		IDirect3DSurface9* bbSurf;
-		renderWindow->getCustomAttribute("DDBACKBUFFER", &bbSurf);
+		renderWindow->getCustomAttribute_internal("DDBACKBUFFER", &bbSurf);
 		D3DSURFACE_DESC bbSurfDesc;
 		bbSurf->GetDesc(&bbSurfDesc);
 
@@ -2832,7 +2832,7 @@ namespace CamelotEngine
 		// Retrieve render surfaces (up to CM_MAX_MULTIPLE_RENDER_TARGETS)
 		IDirect3DSurface9* pBack[CM_MAX_MULTIPLE_RENDER_TARGETS];
 		memset(pBack, 0, sizeof(pBack));
-		rt->getCustomAttribute( "DDBACKBUFFER", &pBack );
+		rt->getCustomAttribute_internal( "DDBACKBUFFER", &pBack );
 		assert(pBack[0]);
 
 		/// Request a depth stencil that is compatible with the format, multisample type and

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9RenderWindow.cpp

@@ -689,7 +689,7 @@ namespace CamelotEngine
 			mDevice->present(this);		
 	}
 
-	void D3D9RenderWindow::getCustomAttribute( const String& name, void* pData )
+	void D3D9RenderWindow::getCustomAttribute_internal( const String& name, void* pData )
 	{
 		// Valid attributes and their equvalent native functions:
 		// D3DDEVICE			: getD3DDevice

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9Texture.cpp

@@ -1226,7 +1226,7 @@ namespace CamelotEngine
 		}
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderTexture::getCustomAttribute( const String& name, void *pData )
+	void D3D9RenderTexture::getCustomAttribute_internal( const String& name, void *pData )
 	{
 		if(name == "DDBACKBUFFER")
 		{

+ 1 - 1
CamelotGLRenderer/Include/CmGLFBOMultiRenderTarget.h

@@ -40,7 +40,7 @@ namespace CamelotEngine {
 		GLFBOMultiRenderTarget(GLFBOManager *manager, const String &name);
 		~GLFBOMultiRenderTarget();
 
-		virtual void getCustomAttribute( const String& name, void *pData );
+		virtual void getCustomAttribute_internal( const String& name, void *pData );
 
 		bool requiresTextureFlipping() const { return true; }
 	private:

+ 1 - 1
CamelotGLRenderer/Include/CmGLFBORenderTexture.h

@@ -46,7 +46,7 @@ namespace CamelotEngine {
     public:
         GLFBORenderTexture(GLFBOManager *manager, const String &name, const GLSurfaceDesc &target, bool writeGamma, UINT32 fsaa);
 
-        virtual void getCustomAttribute(const String& name, void* pData);
+        virtual void getCustomAttribute_internal(const String& name, void* pData);
 
 		/// Override needed to deal with multisample buffers
 		virtual void swapBuffers(bool waitForVSync = true);

+ 1 - 1
CamelotGLRenderer/Include/CmGLPBRenderTexture.h

@@ -42,7 +42,7 @@ namespace CamelotEngine {
         GLPBRenderTexture(GLPBRTTManager *manager, const String &name, const GLSurfaceDesc &target, bool writeGamma, UINT32 fsaa);
         virtual ~GLPBRenderTexture();
         
-        virtual void getCustomAttribute(const String& name, void* pData);
+        virtual void getCustomAttribute_internal(const String& name, void* pData);
     protected:
         GLPBRTTManager *mManager;
         PixelComponentType mPBFormat;

+ 1 - 1
CamelotGLRenderer/Include/CmGLRenderTexture.h

@@ -99,7 +99,7 @@ namespace CamelotEngine {
         GLCopyingRenderTexture(GLCopyingRTTManager *manager, const String &name, const GLSurfaceDesc &target, 
 			bool writeGamma, UINT32 fsaa);
         
-        virtual void getCustomAttribute(const String& name, void* pData);
+        virtual void getCustomAttribute_internal(const String& name, void* pData);
     };
     
     /** Simple, copying manager/factory for RenderTextures. This is only used as the last fallback if

+ 1 - 1
CamelotGLRenderer/Include/CmWin32Window.h

@@ -61,7 +61,7 @@ namespace CamelotEngine {
 		// Method for dealing with resize / move & 3d library
 		virtual void windowMovedOrResized(void);
 
-		void getCustomAttribute( const String& name, void* pData );
+		void getCustomAttribute_internal( const String& name, void* pData );
 
         /** Used to set the active state of the render target.
         */

+ 2 - 2
CamelotGLRenderer/Source/CmGLFBOMultiRenderTarget.cpp

@@ -48,7 +48,7 @@ namespace CamelotEngine {
 
 		/// Check if the render target is in the rendertarget->FBO map
         GLFrameBufferObject *fbobj = 0;
-        target->getCustomAttribute("FBO", &fbobj);
+        target->getCustomAttribute_internal("FBO", &fbobj);
 		assert(fbobj);
 		fbo.bindSurface(attachment, fbobj->getSurface(0));
 
@@ -79,7 +79,7 @@ namespace CamelotEngine {
 		mHeight = fbo.getHeight();
 	}
 
-	void GLFBOMultiRenderTarget::getCustomAttribute( const String& name, void *pData )
+	void GLFBOMultiRenderTarget::getCustomAttribute_internal( const String& name, void *pData )
 	{
 		if(name=="FBO")
         {

+ 2 - 2
CamelotGLRenderer/Source/CmGLFBORenderTexture.cpp

@@ -46,7 +46,7 @@ namespace CamelotEngine {
         mHeight = mFB.getHeight();
     }
 
-    void GLFBORenderTexture::getCustomAttribute(const String& name, void* pData)
+    void GLFBORenderTexture::getCustomAttribute_internal(const String& name, void* pData)
     {
         if(name=="FBO")
         {
@@ -428,7 +428,7 @@ static const UINT32 depthBits[] =
     {
         /// Check if the render target is in the rendertarget->FBO map
         GLFrameBufferObject *fbo = 0;
-        target->getCustomAttribute("FBO", &fbo);
+        target->getCustomAttribute_internal("FBO", &fbo);
         if(fbo)
             fbo->bind();
         else

+ 3 - 3
CamelotGLRenderer/Source/CmGLPBRenderTexture.cpp

@@ -57,7 +57,7 @@ namespace CamelotEngine {
         // Release PBuffer
         mManager->releasePBuffer(mPBFormat);
     }
-    void GLPBRenderTexture::getCustomAttribute(const String& name, void* pData)
+    void GLPBRenderTexture::getCustomAttribute_internal(const String& name, void* pData)
     {
         if(name=="TARGET")
         {
@@ -77,7 +77,7 @@ namespace CamelotEngine {
 		mMainWindow(mainwindow),
 		mMainContext(0)
     {
-		mMainWindow->getCustomAttribute("GLCONTEXT", &mMainContext);
+		mMainWindow->getCustomAttribute_internal("GLCONTEXT", &mMainContext);
     }  
     GLPBRTTManager::~GLPBRTTManager()
     {
@@ -110,7 +110,7 @@ namespace CamelotEngine {
 		// Copy on unbind
         GLSurfaceDesc surface;
 		surface.buffer = 0;
-        target->getCustomAttribute("TARGET", &surface);
+        target->getCustomAttribute_internal("TARGET", &surface);
         if(surface.buffer)
             static_cast<GLTextureBuffer*>(surface.buffer)->copyFromFramebuffer(surface.zoffset);
     }

+ 2 - 2
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -731,7 +731,7 @@ namespace CamelotEngine {
 
 		// Switch context if different from current one
 		GLContext *newContext = 0;
-		target->getCustomAttribute("GLCONTEXT", &newContext);
+		target->getCustomAttribute_internal("GLCONTEXT", &newContext);
 		if(newContext && mCurrentContext != newContext) 
 		{
 			switchContext(newContext);
@@ -1822,7 +1822,7 @@ namespace CamelotEngine {
 	{
 		// Set main and current context
 		mMainContext = 0;
-		primary->getCustomAttribute("GLCONTEXT", &mMainContext);
+		primary->getCustomAttribute_internal("GLCONTEXT", &mMainContext);
 		mCurrentContext = mMainContext;
 
 		// Set primary context as active

+ 2 - 2
CamelotGLRenderer/Source/CmGLRenderTexture.cpp

@@ -77,7 +77,7 @@ namespace CamelotEngine {
         GLRenderTexture(name, target, writeGamma, fsaa)
     {
     }
-    void GLCopyingRenderTexture::getCustomAttribute(const String& name, void* pData)
+    void GLCopyingRenderTexture::getCustomAttribute_internal(const String& name, void* pData)
     {
         if(name=="TARGET")
         {
@@ -115,7 +115,7 @@ namespace CamelotEngine {
         // Copy on unbind
         GLSurfaceDesc surface;
 		surface.buffer = 0;
-        target->getCustomAttribute("TARGET", &surface);
+        target->getCustomAttribute_internal("TARGET", &surface);
         if(surface.buffer)
             static_cast<GLTextureBuffer*>(surface.buffer)->copyFromFramebuffer(surface.zoffset);
     }

+ 1 - 1
CamelotGLRenderer/Source/CmWin32Window.cpp

@@ -749,7 +749,7 @@ namespace CamelotEngine {
 		}
 	}
 
-	void Win32Window::getCustomAttribute( const String& name, void* pData )
+	void Win32Window::getCustomAttribute_internal( const String& name, void* pData )
 	{
 		if( name == "GLCONTEXT" ) {
 			*static_cast<GLContext**>(pData) = mContext;

+ 4 - 1
CamelotOISInput/Source/CmOISPlugin.cpp

@@ -13,7 +13,10 @@ namespace CamelotEngine
 
 	extern "C" CM_OIS_EXPORT void loadPlugin()
 	{
-		InputHandlerOIS* inputHandler = new InputHandlerOIS(gApplication().getAppWindowId());
+		// TODO - Window handles in Windows are 64 bits when compiled as x64, but OIS only accepts a 32bit value. Is this okay?
+		UINT32 windowId = (UINT32)gApplication().getAppWindowId();
+
+		InputHandlerOIS* inputHandler = new InputHandlerOIS(windowId);
 		gInput().registerInputHandler(inputHandler);
 	}
 }

+ 1 - 1
CamelotRenderer/Include/CmApplication.h

@@ -22,7 +22,7 @@ namespace CamelotEngine
 			void runMainLoop();
 			void shutDown();
 
-			UINT32 getAppWindowId();
+			UINT64 getAppWindowId();
 
 			RenderWindow* getPrimaryRenderWindow() const { return mPrimaryRenderWindow; }
 

+ 1 - 1
CamelotRenderer/Include/CmRenderTarget.h

@@ -138,7 +138,7 @@ namespace CamelotEngine {
             @param
                 pData Pointer to memory of the right kind of structure to receive the info.
         */
-        virtual void getCustomAttribute(const String& name, void* pData);
+        virtual void getCustomAttribute_internal(const String& name, void* pData);
 
 		/** Sets the priority of this render target in relation to the others. 
         @remarks

+ 5 - 3
CamelotRenderer/Source/CmApplication.cpp

@@ -53,6 +53,8 @@ namespace CamelotEngine
 
 		mPrimaryRenderWindow = renderSystem->createRenderWindow("Camelot Renderer", 1280, 720, false);
 
+		UINT32 winId = gApplication().getAppWindowId();
+
 		SceneManager::startUp(new SceneManager());
 		Resources::startUp(new Resources("D:\\CamelotResourceMetas"));
 
@@ -135,15 +137,15 @@ namespace CamelotEngine
 		}
 	}
 
-	UINT32 Application::getAppWindowId()
+	UINT64 Application::getAppWindowId()
 	{
 		if(!mPrimaryRenderWindow)
 		{
 			CM_EXCEPT(InternalErrorException, "Unable to get window handle. No active window is set!");
 		}
 
-		UINT32 windowId;
-		mPrimaryRenderWindow->getCustomAttribute("WINDOW", &windowId);
+		UINT64 windowId = 0;
+		mPrimaryRenderWindow->getCustomAttribute_internal("WINDOW", &windowId);
 
 		return windowId;
 	}

+ 1 - 1
CamelotRenderer/Source/CmRenderTarget.cpp

@@ -87,7 +87,7 @@ namespace CamelotEngine {
 	{
 	}
 
-	void RenderTarget::getCustomAttribute(const String& name, void* pData)
+	void RenderTarget::getCustomAttribute_internal(const String& name, void* pData)
     {
         CM_EXCEPT(InvalidParametersException, "Attribute not found.");
     }

+ 1 - 1
CamelotRenderer/Source/CmWindowEventUtilities.cpp

@@ -262,7 +262,7 @@ void GLXProc( RenderWindow *win, const XEvent &event )
 	case ClientMessage:
 	{
 		::Atom atom;
-		win->getCustomAttribute("ATOM", &atom);
+		win->getCustomAttribute_internal("ATOM", &atom);
 		if(event.xclient.format == 32 && event.xclient.data.l[0] == (long)atom)
 		{	//Window closed by window manager
 			//Send message first, to allow app chance to unregister things that need done before

+ 3 - 3
CamelotRenderer/Source/Win32/CmOSCursorImpl.cpp

@@ -11,7 +11,7 @@ namespace CamelotEngine
 
 		RenderWindow* primaryWindow = gApplication().getPrimaryRenderWindow();
 		HWND hwnd;
-		primaryWindow->getCustomAttribute("WINDOW", &hwnd);
+		primaryWindow->getCustomAttribute_internal("WINDOW", &hwnd);
 
 		ScreenToClient(hwnd, &screenPos);
 
@@ -28,7 +28,7 @@ namespace CamelotEngine
 
 		RenderWindow* primaryWindow = gApplication().getPrimaryRenderWindow();
 		HWND hwnd;
-		primaryWindow->getCustomAttribute("WINDOW", &hwnd);
+		primaryWindow->getCustomAttribute_internal("WINDOW", &hwnd);
 
 		ClientToScreen(hwnd, &screenPos);
 
@@ -43,7 +43,7 @@ namespace CamelotEngine
 
 		RenderWindow* primaryWindow = gApplication().getPrimaryRenderWindow();
 		HWND hwnd;
-		primaryWindow->getCustomAttribute("WINDOW", &hwnd);
+		primaryWindow->getCustomAttribute_internal("WINDOW", &hwnd);
 
 		// Clip cursor to the window
 		if( GetWindowRect(hwnd, &clipWindowRect))

+ 1 - 0
CamelotRenderer/TODO.txt

@@ -58,6 +58,7 @@ HIGH PRIORITY TODO:
  - HLSL & Cg don't handle include files yet
 
 Mid priority TODO:
+ - Add multithreaded version of RenderTarget::getCustomAttribute_internal
  - Compiler2Pass in GL renderer doesn't seem to be 64bit ready. I hacked it together but it will likely cause problems.
  - Resource handle should store a unique integer ID, which just points to a table of GUIDs. Keeping GUID string everywhere in not efficient.
  - Add a field that tracks % of resource deserialization in BinarySerializer