Explorar o código

Stripping down render systems of unneeded features #1

Marko Pintera %!s(int64=13) %!d(string=hai) anos
pai
achega
bf6922faca

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

+ 0 - 5
CamelotD3D9Renderer/Include/CmD3D9RenderSystem.h

@@ -205,9 +205,6 @@ namespace CamelotEngine
 		void setConfigOption( const String &name, const String &value );
 		void setConfigOption( const String &name, const String &value );
 		void reinitialise();
 		void reinitialise();
 		void shutdown();
 		void shutdown();
-		void setAmbientLight( float r, float g, float b );
-		void setShadingType( ShadeOptions so );
-		void setLightingEnabled( bool enabled );
 		void destroyRenderTarget(const String& name);
 		void destroyRenderTarget(const String& name);
 		VertexElementType getColourVertexElementType() const;
 		VertexElementType getColourVertexElementType() const;
 		void setStencilCheckEnabled(bool enabled);
 		void setStencilCheckEnabled(bool enabled);
@@ -239,8 +236,6 @@ namespace CamelotEngine
 		void _setAlphaRejectSettings( CompareFunction func, unsigned char value, bool alphaToCoverage );
 		void _setAlphaRejectSettings( CompareFunction func, unsigned char value, bool alphaToCoverage );
 		void _setViewport( Viewport *vp );		
 		void _setViewport( Viewport *vp );		
 		void _beginFrame();
 		void _beginFrame();
-		virtual RenderSystemContext* _pauseFrame(void);
-		virtual void _resumeFrame(RenderSystemContext* context);
 		void _endFrame();		
 		void _endFrame();		
 		void _setCullingMode( CullingMode mode );
 		void _setCullingMode( CullingMode mode );
 		void _setDepthBufferParams( bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL );
 		void _setDepthBufferParams( bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL );

+ 0 - 85
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -1552,27 +1552,6 @@ namespace CamelotEngine
 		}
 		}
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::setAmbientLight( float r, float g, float b )
-	{
-		HRESULT hr = __SetRenderState( D3DRS_AMBIENT, D3DCOLOR_COLORVALUE( r, g, b, 1.0f ) );
-		if( FAILED( hr ) )
-			CM_EXCEPT(RenderingAPIException, "Failed to set render stat D3DRS_AMBIENT");
-	}
-	//---------------------------------------------------------------------
-	void D3D9RenderSystem::setShadingType( ShadeOptions so )
-	{
-		HRESULT hr = __SetRenderState( D3DRS_SHADEMODE, D3D9Mappings::get(so) );
-		if( FAILED( hr ) )
-			CM_EXCEPT(RenderingAPIException, "Failed to set render stat D3DRS_SHADEMODE");
-	}
-	//---------------------------------------------------------------------
-	void D3D9RenderSystem::setLightingEnabled( bool enabled )
-	{
-		HRESULT hr;
-		if( FAILED( hr = __SetRenderState( D3DRS_LIGHTING, enabled ) ) )
-			CM_EXCEPT(RenderingAPIException, "Failed to set render state D3DRS_LIGHTING");
-	}
-	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setViewMatrix( const Matrix4 &m )
 	void D3D9RenderSystem::_setViewMatrix( const Matrix4 &m )
 	{
 	{
 		// save latest view matrix
 		// save latest view matrix
@@ -2410,11 +2389,6 @@ namespace CamelotEngine
 		mDeviceManager->destroyInactiveRenderDevices();
 		mDeviceManager->destroyInactiveRenderDevices();
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
-	struct D3D9RenderContext : public RenderSystem::RenderSystemContext
-	{
-		RenderTarget* target;
-	};
-	//---------------------------------------------------------------------
 	D3D9RenderSystem::ZBufferIdentifier D3D9RenderSystem::getZBufferIdentifier(RenderTarget* rt)
 	D3D9RenderSystem::ZBufferIdentifier D3D9RenderSystem::getZBufferIdentifier(RenderTarget* rt)
 	{
 	{
 		// Retrieve render surfaces (up to CM_MAX_MULTIPLE_RENDER_TARGETS)
 		// Retrieve render surfaces (up to CM_MAX_MULTIPLE_RENDER_TARGETS)
@@ -2439,65 +2413,6 @@ namespace CamelotEngine
 		return zBufferIdentifier;
 		return zBufferIdentifier;
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
-	RenderSystem::RenderSystemContext* D3D9RenderSystem::_pauseFrame(void)
-	{
-		//Stop rendering
-		_endFrame();
-
-		D3D9RenderContext* context = new D3D9RenderContext;
-		context->target = mActiveRenderTarget;
-
-		//Don't do this to backbuffers. Is there a more elegant way to check?
-		if (!dynamic_cast<D3D9RenderWindow*>(mActiveRenderTarget))
-		{
-			//Get the matching z buffer identifier and queue
-			ZBufferIdentifier zBufferIdentifier = getZBufferIdentifier(mActiveRenderTarget);
-			ZBufferRefQueue& zBuffers = mZBufferHash[zBufferIdentifier];
-			
-#ifdef CM_DEBUG_MODE
-			//Check that queue handling works as expected
-			IDirect3DSurface9* pDepth;
-			getActiveD3D9Device()->GetDepthStencilSurface(&pDepth);	
-			
-			// Release immediately -> each get increase the ref count.
-			if (pDepth != NULL)		
-				pDepth->Release();		
-
-			assert(zBuffers.front().surface == pDepth);
-#endif
-
-			//Store the depth buffer in the side and remove it from the queue
-			mCheckedOutTextures[mActiveRenderTarget] = zBuffers.front();
-			zBuffers.pop_front();
-		}
-		
-		
-		return context;
-	}
-	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_resumeFrame(RenderSystemContext* context)
-	{
-		//Resume rendering
-		_beginFrame();
-		D3D9RenderContext* d3dContext = static_cast<D3D9RenderContext*>(context);
-
-		//Don't do this to backbuffers. Is there a more elegant way to check?
-		if (!dynamic_cast<D3D9RenderWindow*>(d3dContext->target))
-		{
-			///Find the stored depth buffer
-			ZBufferIdentifier zBufferIdentifier = getZBufferIdentifier(d3dContext->target);
-			ZBufferRefQueue& zBuffers = mZBufferHash[zBufferIdentifier];
-			assert(mCheckedOutTextures.find(d3dContext->target) != mCheckedOutTextures.end());
-			
-			//Return it to the general queue
-			zBuffers.push_front(mCheckedOutTextures[d3dContext->target]);
-			mCheckedOutTextures.erase(d3dContext->target);
-		}
-		
-		
-		delete context;
-	}
-	//---------------------------------------------------------------------
 	void D3D9RenderSystem::setVertexDeclaration(VertexDeclarationPtr decl)
 	void D3D9RenderSystem::setVertexDeclaration(VertexDeclarationPtr decl)
 	{
 	{
 		HRESULT hr;
 		HRESULT hr;

+ 0 - 13
CamelotGLRenderer/Include/CmGLRenderSystem.h

@@ -167,19 +167,6 @@ namespace CamelotEngine {
           RenderSystem
           RenderSystem
          */
          */
         void shutdown(void);
         void shutdown(void);
-
-        /** See
-          RenderSystem
-         */
-        void setAmbientLight(float r, float g, float b);
-        /** See
-          RenderSystem
-         */
-        void setShadingType(ShadeOptions so);
-        /** See
-          RenderSystem
-         */
-        void setLightingEnabled(bool enabled);
         
         
 		/// @copydoc RenderSystem::_createRenderWindow
 		/// @copydoc RenderSystem::_createRenderWindow
 		RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, 
 		RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, 

+ 0 - 32
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -922,26 +922,6 @@ namespace CamelotEngine {
 		//  the whole state.
 		//  the whole state.
 		mGLInitialised = 0;
 		mGLInitialised = 0;
 	}
 	}
-
-	void GLRenderSystem::setAmbientLight(float r, float g, float b)
-	{
-		GLfloat lmodel_ambient[] = {r, g, b, 1.0};
-		glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
-	}
-
-	void GLRenderSystem::setShadingType(ShadeOptions so)
-	{
-		switch(so)
-		{
-		case SO_FLAT:
-			glShadeModel(GL_FLAT);
-			break;
-		default:
-			glShadeModel(GL_SMOOTH);
-			break;
-		}
-	}
-
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	bool GLRenderSystem::_createRenderWindows(const RenderWindowDescriptionList& renderWindowDescriptions, 
 	bool GLRenderSystem::_createRenderWindows(const RenderWindowDescriptionList& renderWindowDescriptions, 
 		RenderWindowList& createdWindows)
 		RenderWindowList& createdWindows)
@@ -1756,18 +1736,6 @@ namespace CamelotEngine {
 		return (errString != 0) ? String((const char*) errString) : StringUtil::BLANK;
 		return (errString != 0) ? String((const char*) errString) : StringUtil::BLANK;
     }
     }
     //-----------------------------------------------------------------------------
     //-----------------------------------------------------------------------------
-    void GLRenderSystem::setLightingEnabled(bool enabled)
-    {
-        if (enabled) 
-        {      
-            glEnable(GL_LIGHTING);
-        } 
-        else 
-        {
-            glDisable(GL_LIGHTING);
-        }
-    }
-    //-----------------------------------------------------------------------------
     void GLRenderSystem::_setFog(FogMode mode, const Color& colour, float density, float start, float end)
     void GLRenderSystem::_setFog(FogMode mode, const Color& colour, float density, float start, float end)
     {
     {
 
 

+ 1 - 38
CamelotRenderer/Include/CmRenderSystem.h

@@ -183,7 +183,7 @@ namespace CamelotEngine
 		@returns
 		@returns
 		A pointer to the automatically created window, if requested, otherwise null.
 		A pointer to the automatically created window, if requested, otherwise null.
 		*/
 		*/
-		virtual RenderWindow* _initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window");
+		virtual RenderWindow* _initialise(bool autoCreateWindow, const String& windowTitle = "Camelot Render Window");
 
 
 
 
 		/** Query the real capabilities of the GPU and driver in the RenderSystem*/
 		/** Query the real capabilities of the GPU and driver in the RenderSystem*/
@@ -205,22 +205,6 @@ namespace CamelotEngine
 		*/
 		*/
 		virtual void shutdown(void);
 		virtual void shutdown(void);
 
 
-
-		/** Sets the colour & strength of the ambient (global directionless) light in the world.
-		*/
-		virtual void setAmbientLight(float r, float g, float b) = 0;
-
-		/** Sets the type of light shading required (default = Gouraud).
-		*/
-		virtual void setShadingType(ShadeOptions so) = 0;
-
-		/** Sets whether or not dynamic lighting is enabled.
-		@param
-		enabled If true, dynamic lighting is performed on geometry with normals supplied, geometry without
-		normals will not be displayed. If false, no lighting is applied and all geometry will be full brightness.
-		*/
-		virtual void setLightingEnabled(bool enabled) = 0;
-
 		/** Sets whether or not W-buffers are enabled if they are available for this renderer.
 		/** Sets whether or not W-buffers are enabled if they are available for this renderer.
 		@param
 		@param
 		enabled If true and the renderer supports them W-buffers will be used.  If false 
 		enabled If true and the renderer supports them W-buffers will be used.  If false 
@@ -711,33 +695,12 @@ namespace CamelotEngine
 		*/
 		*/
 		virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value, bool alphaToCoverage) = 0;
 		virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value, bool alphaToCoverage) = 0;
 
 
-		/** Notify the rendersystem that it should adjust texture projection to be 
-			relative to a different origin.
-		*/
-		virtual void _setTextureProjectionRelativeTo(bool enabled, const Vector3& pos);
 		/**
 		/**
 		* Signifies the beginning of a frame, i.e. the start of rendering on a single viewport. Will occur
 		* Signifies the beginning of a frame, i.e. the start of rendering on a single viewport. Will occur
 		* several times per complete frame if multiple viewports exist.
 		* several times per complete frame if multiple viewports exist.
 		*/
 		*/
 		virtual void _beginFrame(void) = 0;
 		virtual void _beginFrame(void) = 0;
 		
 		
-		//Dummy structure for render system contexts - implementing RenderSystems can extend
-		//as needed
-		struct RenderSystemContext { };
-		/**
-		* Pause rendering for a frame. This has to be called after _beginFrame and before _endFrame.
-		* Will usually be called by the SceneManager, don't use this manually unless you know what
-		* you are doing.
-		*/
-		virtual RenderSystemContext* _pauseFrame(void);
-		/**
-		* Resume rendering for a frame. This has to be called after a _pauseFrame call
-		* Will usually be called by the SceneManager, don't use this manually unless you know what
-		* you are doing.
-		* @param context the render system context, as returned by _pauseFrame
-		*/
-		virtual void _resumeFrame(RenderSystemContext* context);
-
 		/**
 		/**
 		* Ends rendering of a frame to the current viewport.
 		* Ends rendering of a frame to the current viewport.
 		*/
 		*/

+ 0 - 2
CamelotRenderer/Source/CmApplication.cpp

@@ -56,8 +56,6 @@ namespace CamelotEngine
 		SceneManager::startUp(new SceneManager());
 		SceneManager::startUp(new SceneManager());
 		Resources::startUp(new Resources("D:\\CamelotResourceMetas"));
 		Resources::startUp(new Resources("D:\\CamelotResourceMetas"));
 
 
-		renderSystem->setLightingEnabled(false);
-
 		Importer::startUp(new Importer());
 		Importer::startUp(new Importer());
 		loadPlugin("CamelotFreeImgImporter"); // TODO - Load this automatically somehow
 		loadPlugin("CamelotFreeImgImporter"); // TODO - Load this automatically somehow
 		loadPlugin("CamelotFBXImporter"); // TODO - Load this automatically somehow
 		loadPlugin("CamelotFBXImporter"); // TODO - Load this automatically somehow

+ 0 - 20
CamelotRenderer/Source/CmRenderSystem.cpp

@@ -641,25 +641,5 @@ namespace CamelotEngine {
         // Make compiler happy
         // Make compiler happy
         return false;
         return false;
 	}
 	}
-	//---------------------------------------------------------------------
-	void RenderSystem::_setTextureProjectionRelativeTo(bool enabled, const Vector3& pos)
-	{
-		mTexProjRelative = enabled;
-		mTexProjRelativeOrigin = pos;
-
-	}
-	//---------------------------------------------------------------------
-	RenderSystem::RenderSystemContext* RenderSystem::_pauseFrame(void)
-	{
-		_endFrame();
-		return new RenderSystem::RenderSystemContext;
-	}
-	//---------------------------------------------------------------------
-	void RenderSystem::_resumeFrame(RenderSystemContext* context)
-	{
-		_beginFrame();
-		delete context;
-	}
-
 }
 }