1. rride_a
  2. Ogre NULL RenderSystem

Commits

rride_a  committed b40cb89

initial implementation of NULLPixelBuffer

  • Participants
  • Parent commits 8729ae7
  • Branches default

Comments (0)

Files changed (9)

File CMakeLists.txt

View file
  • Ignore whitespace
 	NullHardwareIndexBuffer.h
 	NullHardwareVertexBuffer.cpp
 	NullHardwareVertexBuffer.h
+	NullHardwarePixelBuffer.cpp
+	NullHardwarePixelBuffer.h
 	NullHlslProgramFactory.cpp	
 	NullHlslProgramFactory.h
 	NullRendererDll.cpp
 	NullRenderSystem.h
 	NullRenderWindow.cpp
 	NullRenderWindow.h
+    NullTexture.cpp
 	NullTexture.h
 	NullTextureManager.cpp
 	NullTextureManager.h

File NullGpuProgramManager.cpp

View file
  • Ignore whitespace
 }
 //-----------------------------------------------------------------------------
 GpuProgramParametersSharedPtr NULLGpuProgramManager::createParameters(void) {
-	return GpuProgramParametersSharedPtr(new GpuProgramParameters());
+	GpuProgramParameters * gp = new GpuProgramParameters();
+	gp->setIgnoreMissingParams(true);
+	return GpuProgramParametersSharedPtr(gp);
 }
 //-----------------------------------------------------------------------------
 Resource* NULLGpuProgramManager::createImpl(const String& name,

File NullHardwarePixelBuffer.cpp

View file
  • Ignore whitespace
+#include "NULLHardwarePixelBuffer.h"
+
+void NULLHardwarePixelBuffer::updateRenderTexture( bool writeGamma, uint fsaa, const String& srcName )
+{
+	if (mRenderTexture == NULL)
+	{
+		String name;
+		name = "rtt/" +Ogre::StringConverter::toString((size_t)this) + "/" + srcName;
+
+		mRenderTexture = new D3D9RenderTexture(name, this, writeGamma, fsaa);		
+		Root::getSingleton().getRenderSystem()->attachRenderTarget(*mRenderTexture);
+	}
+}
+
+Ogre::PixelBox NULLHardwarePixelBuffer::lockImpl( const Image::Box lockBox, LockOptions options )
+{
+
+}
+
+void NULLHardwarePixelBuffer::unlockImpl( void )
+{
+
+}

File NullHardwarePixelBuffer.h

View file
  • Ignore whitespace
+#pragma once
+/******************************************************************************
+ *
+ *    This file is based on a work of 
+ *      * Aliaksandr Ivaniuk aka Rride (c) 2011
+ *      * openDarkEngine team (C) 2009: http://opde.svn.sourceforge.net/viewvc/opde/trunk/thirdparty/NullRenderer/
+ *      * xyzzy @ ogre3d.org forum.
+ *
+ *    This program is free software; you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation; either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    This program is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with this program; if not, write to the Free Software
+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *
+ *	  $Id: NullTexture.h 1182 2009-04-17 15:56:42Z volca $
+ *
+ *****************************************************************************/
+
+#include "stdafx.h"
+
+using namespace Ogre;
+
+class NULLHardwarePixelBuffer: public HardwarePixelBuffer
+{
+protected: 
+    /// Internal implementation of lock(), must be overridden in subclasses
+    virtual PixelBox lockImpl(const Image::Box lockBox,  LockOptions options);
+
+    virtual void unlockImpl(void);
+	friend class RenderTexture;
+public:
+    /// Should be called by HardwareBufferManager
+    NULLHardwarePixelBuffer(size_t mWidth, size_t mHeight, size_t mDepth, PixelFormat mFormat,
+            HardwareBuffer::Usage usage, bool useSystemMemory, bool useShadowBuffer);
+    ~NULLHardwarePixelBuffer();
+        
+    virtual RenderTexture *getRenderTarget(size_t slice);
+    void updateRenderTexture(bool writeGamma, uint fsaa, const String& srcName);
+
+};

File NullRenderSystem.cpp

View file
  • Ignore whitespace
 	
 	//---------------------------------------------------------------------
 	RenderSystemCapabilities* NULLRenderSystem::createRenderSystemCapabilities() const {
+		return mRealCapabilities;
+	}
+	
+	//---------------------------------------------------------------------
+	void NULLRenderSystem::initialiseFromRenderSystemCapabilities(RenderSystemCapabilities* caps, RenderTarget* primary) {
+		mRealCapabilities = caps;
+	}
+	
+	RenderWindow* NULLRenderSystem::_initialise(bool autoCreateWindow, const String& windowTitle) {
+		RenderWindow* autoWindow = NULL;
+	
+		// Init using current settings
+		if (autoCreateWindow) 
+			autoWindow = this->_createRenderWindow(windowTitle, 640, 480, false, NULL);
+		
+		_updateRSCapabilities();
+
+		// call superclass method
+		RenderSystem::_initialise(autoCreateWindow);
+	
+		return autoWindow;
+	}
+
+	void NULLRenderSystem::_setRenderTarget( RenderTarget *target )
+	{
+
+	}
+
+	unsigned int NULLRenderSystem::getDisplayMonitorCount() const
+	{
+		return 1;
+	}
+
+	void NULLRenderSystem::_updateRSCapabilities()
+	{
+		if (!mRealCapabilities)
+			mRealCapabilities = new RenderSystemCapabilities();
+
 		mRealCapabilities->setCapability(RSC_HWSTENCIL);
 		mRealCapabilities->setStencilBufferBitDepth(8);
 		mRealCapabilities->setNumTextureUnits(16);
         mRealCapabilities->addShaderProfile( "gpu_gp" );
     	mRealCapabilities->addShaderProfile( "gp4_gp" );
 
-
-		return mRealCapabilities;
-	}
-	
-	//---------------------------------------------------------------------
-	void NULLRenderSystem::initialiseFromRenderSystemCapabilities(RenderSystemCapabilities* caps, RenderTarget* primary) {
-		mRealCapabilities = caps;
-	}
-	
-	RenderWindow* NULLRenderSystem::_initialise(bool autoCreateWindow,
-			const String& windowTitle) {
-		RenderWindow* autoWindow = NULL;
-	
-		// Init using current settings
-		if (autoCreateWindow) {
-			autoWindow = this->_createRenderWindow(windowTitle, 640, 480, false,
-					NULL);
-		}
-	
-		// call superclass method
-		RenderSystem::_initialise(autoCreateWindow);
-	
-		return autoWindow;
-	}
-
-	void NULLRenderSystem::_setRenderTarget( RenderTarget *target )
-	{
-
-	}
-
-	unsigned int NULLRenderSystem::getDisplayMonitorCount() const
-	{
-		return 1;
+		if (!mCurrentCapabilities)
+			mCurrentCapabilities = mRealCapabilities;
 	}
 
 }

File NullRenderSystem.h

View file
  • Ignore whitespace
 			const NameValuePairList *miscParams = 0);
 	
     virtual unsigned int getDisplayMonitorCount() const;
+private:
+	void _updateRSCapabilities();
 	NULLHardwareBufferManager * m_pHardwareBufferManager;
 	NULLGpuProgramManager* mGpuProgramManager;
 };

File NullRendererDll.cpp

View file
  • Ignore whitespace
 
 	NULLRenderSystem* nullRendPlugin;
 	NULLHLSLProgramFactory* hlslProgramFactory;
-	NULLGpuProgramManager*  manager;
 
 	extern "C" void _OgreNULLRSExport dllStartPlugin(void) throw()
 	{
         hlslProgramFactory = new NULLHLSLProgramFactory();
 		Ogre::HighLevelGpuProgramManager::getSingleton().addFactory(hlslProgramFactory);
 
-		manager = new NULLGpuProgramManager();
 	}
 
 	extern "C" void _OgreNULLRSExport dllStopPlugin(void)
 	{
-		delete manager;
 		delete nullRendPlugin;
 		delete hlslProgramFactory;
 	}

File NullTexture.cpp

View file
  • Ignore whitespace
+/******************************************************************************
+ *
+ *    This file is based on a work of 
+ *      * Aliaksandr Ivaniuk aka Rride (c) 2011
+ *      * openDarkEngine team (C) 2009: http://opde.svn.sourceforge.net/viewvc/opde/trunk/thirdparty/NullRenderer/
+ *      * xyzzy @ ogre3d.org forum.
+ *
+ *    This program is free software; you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation; either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    This program is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with this program; if not, write to the Free Software
+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *
+ *	  $Id: NullTexture.h 1182 2009-04-17 15:56:42Z volca $
+ *
+ *****************************************************************************/
+
+#include "NullTexture.h"
+#include "NULLHardwarePixelBuffer.h"
+
+NULLTexture::NULLTexture(ResourceManager* creator, const String& name, ResourceHandle handle, const String& group, bool isManual, ManualResourceLoader* loader) 
+	:	Texture(creator, name, handle, group, isManual, loader) 
+{ 
+	
+}
+
+NULLTexture::~NULLTexture()
+{
+}
+
+void NULLTexture::loadImpl( void )
+{
+
+}
+
+void NULLTexture::loadImage( const Ogre::Image & )
+{
+
+}
+
+void NULLTexture::createInternalResources( void )
+{
+	if( _pixBuf.isNull() )
+	{
+    	_pixBuf.bind( new NULLHardwarePixelBuffer( mWidth, mHeight, 1, getFormat(), getUsage(), false, false ) );
+	}
+}
+
+void NULLTexture::freeInternalResources( void )
+{
+	_pixBuf.setNull();
+}

File NullTexture.h

View file
  • Ignore whitespace
 
 using namespace Ogre;
 
+class NULLHardwarePixelBuffer;
+
 class NULLTexture : public Texture
 {
 public:
 	NULLTexture(ResourceManager* creator, const String& name, ResourceHandle handle,
-		const String& group, bool isManual = false, ManualResourceLoader* loader = 0) : Texture(creator, name, handle, group, isManual, loader) { }
-	~NULLTexture() {}
-	void loadImpl(void) {}
-	void loadImage (const Ogre::Image &) {}
-	HardwarePixelBufferSharedPtr getBuffer(size_t face=0, size_t mipmap=0) { return HardwarePixelBufferSharedPtr(NULL); }
-	void createInternalResourcesImpl() {}
-	void freeInternalResourcesImpl() {}
+		const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
+	~NULLTexture();
+
+	void loadImpl(void);
+	void loadImage (const Ogre::Image &);
+	HardwarePixelBufferSharedPtr getBuffer(size_t face=0, size_t mipmap=0) { return _pixBuf; }
+
+    void createInternalResources(void);
+    void freeInternalResources(void);
+
+private:
+
+	HardwarePixelBufferSharedPtr	_pixBuf;
 };
 
 #endif