浏览代码

Removed singleton

Marko Pintera 13 年之前
父节点
当前提交
c39c84f059
共有 34 个文件被更改,包括 103 次插入382 次删除
  1. 0 2
      CamelotD3D9Renderer/Include/CmD3D9RenderSystem.h
  2. 1 1
      CamelotD3D9Renderer/Source/CmD3D9HLSLProgram.cpp
  3. 7 10
      CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp
  4. 0 9
      CamelotGLRenderer/Include/CmGLRenderSystem.h
  5. 2 1
      CamelotGLRenderer/Include/CmGLRenderTexture.h
  6. 2 2
      CamelotGLRenderer/Source/CmGLHardwareIndexBuffer.cpp
  7. 2 2
      CamelotGLRenderer/Source/CmGLHardwarePixelBuffer.cpp
  8. 2 2
      CamelotGLRenderer/Source/CmGLHardwareVertexBuffer.cpp
  9. 31 41
      CamelotGLRenderer/Source/CmGLRenderSystem.cpp
  10. 0 1
      CamelotGLRenderer/Source/CmGLRenderTexture.cpp
  11. 1 1
      CamelotGLRenderer/Source/CmGLTextureManager.cpp
  12. 2 6
      CamelotGLRenderer/Source/GLSL/include/CmGLSLLinkProgramManager.h
  13. 0 4
      CamelotGLRenderer/Source/GLSL/include/CmGLSLProgramFactory.h
  14. 10 10
      CamelotGLRenderer/Source/GLSL/src/CmGLSLGpuProgram.cpp
  15. 1 1
      CamelotGLRenderer/Source/GLSL/src/CmGLSLLinkProgram.cpp
  16. 0 15
      CamelotGLRenderer/Source/GLSL/src/CmGLSLLinkProgramManager.cpp
  17. 2 2
      CamelotGLRenderer/Source/GLSL/src/CmGLSLProgram.cpp
  18. 2 3
      CamelotGLRenderer/Source/GLSL/src/CmGLSLProgramFactory.cpp
  19. 0 2
      CamelotRenderer/Include/CmApplication.h
  20. 2 38
      CamelotRenderer/Include/CmGpuProgramManager.h
  21. 3 38
      CamelotRenderer/Include/CmHardwareBufferManager.h
  22. 2 37
      CamelotRenderer/Include/CmHighLevelGpuProgramManager.h
  23. 7 9
      CamelotRenderer/Source/CmApplication.cpp
  24. 1 1
      CamelotRenderer/Source/CmFrustum.cpp
  25. 0 10
      CamelotRenderer/Source/CmGpuProgramManager.cpp
  26. 0 11
      CamelotRenderer/Source/CmHardwareBufferManager.cpp
  27. 1 1
      CamelotRenderer/Source/CmHardwareVertexBuffer.cpp
  28. 0 11
      CamelotRenderer/Source/CmHighLevelGpuProgramManager.cpp
  29. 3 3
      CamelotRenderer/Source/CmVertexIndexData.cpp
  30. 0 1
      CamelotUtility/CamelotUtility.vcxproj
  31. 0 3
      CamelotUtility/CamelotUtility.vcxproj.filters
  32. 17 0
      CamelotUtility/Include/CmModule.h
  33. 0 102
      CamelotUtility/Include/CmSingleton.h
  34. 2 2
      Dependencies.txt

+ 0 - 2
CamelotD3D9Renderer/Include/CmD3D9RenderSystem.h

@@ -111,8 +111,6 @@ namespace CamelotEngine
 		/// check if a FSAA is supported
 		/// check if a FSAA is supported
 		bool _checkMultiSampleQuality(D3DMULTISAMPLE_TYPE type, DWORD *outQuality, D3DFORMAT format, UINT adapterNum, D3DDEVTYPE deviceType, BOOL fullScreen);
 		bool _checkMultiSampleQuality(D3DMULTISAMPLE_TYPE type, DWORD *outQuality, D3DFORMAT format, UINT adapterNum, D3DDEVTYPE deviceType, BOOL fullScreen);
 		
 		
-		D3D9HardwareBufferManager* mHardwareBufferManager;
-		D3D9GpuProgramManager* mGpuProgramManager;
         D3D9HLSLProgramFactory* mHLSLProgramFactory;
         D3D9HLSLProgramFactory* mHLSLProgramFactory;
 		D3D9ResourceManager* mResourceManager;
 		D3D9ResourceManager* mResourceManager;
 		D3D9DeviceManager* mDeviceManager;
 		D3D9DeviceManager* mDeviceManager;

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9HLSLProgram.cpp

@@ -272,7 +272,7 @@ namespace CamelotEngine {
 
 
 			// Create a low-level program, give it the same name as us
 			// Create a low-level program, give it the same name as us
 			mAssemblerProgram = 
 			mAssemblerProgram = 
-				GpuProgramManager::getSingleton().createProgram(
+				GpuProgramManager::instance().createProgram(
 					"",// dummy source, since we'll be using microcode
 					"",// dummy source, since we'll be using microcode
 					mType, 
 					mType, 
 					hlslProfile);
 					hlslProfile);

+ 7 - 10
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -67,9 +67,7 @@ namespace CamelotEngine
 		// set pointers to NULL
 		// set pointers to NULL
 		mpD3D = NULL;		
 		mpD3D = NULL;		
 		mDriverList = NULL;
 		mDriverList = NULL;
-		mActiveD3DDriver = NULL;
-		mHardwareBufferManager = NULL;
-		mGpuProgramManager = NULL;			
+		mActiveD3DDriver = NULL;	
 		mUseNVPerfHUD = false;
 		mUseNVPerfHUD = false;
 		mHLSLProgramFactory = NULL;		
 		mHLSLProgramFactory = NULL;		
 		mDeviceManager = NULL;	
 		mDeviceManager = NULL;	
@@ -114,8 +112,7 @@ namespace CamelotEngine
 		// Deleting the HLSL program factory
 		// Deleting the HLSL program factory
 		if (mHLSLProgramFactory)
 		if (mHLSLProgramFactory)
 		{
 		{
-			if (HighLevelGpuProgramManager::getSingletonPtr())
-				HighLevelGpuProgramManager::getSingleton().removeFactory(mHLSLProgramFactory);
+			HighLevelGpuProgramManager::instance().removeFactory(mHLSLProgramFactory);
 			delete mHLSLProgramFactory;
 			delete mHLSLProgramFactory;
 			mHLSLProgramFactory = 0;
 			mHLSLProgramFactory = 0;
 		}
 		}
@@ -514,10 +511,10 @@ namespace CamelotEngine
 		TextureManager::startUp(new D3D9TextureManager());
 		TextureManager::startUp(new D3D9TextureManager());
 
 
 		// Also create hardware buffer manager		
 		// Also create hardware buffer manager		
-		mHardwareBufferManager = new D3D9HardwareBufferManager();
+		HardwareBufferManager::startUp(new D3D9HardwareBufferManager());
 
 
 		// Create the GPU program manager		
 		// Create the GPU program manager		
-		mGpuProgramManager = new D3D9GpuProgramManager();
+		GpuProgramManager::startUp(new D3D9GpuProgramManager());
 
 
 		// Create & register HLSL factory		
 		// Create & register HLSL factory		
 		mHLSLProgramFactory = new D3D9HLSLProgramFactory();
 		mHLSLProgramFactory = new D3D9HLSLProgramFactory();
@@ -623,8 +620,8 @@ namespace CamelotEngine
 		mActiveD3DDriver = NULL;	
 		mActiveD3DDriver = NULL;	
 						
 						
 		TextureManager::shutDown();
 		TextureManager::shutDown();
-		SAFE_DELETE( mHardwareBufferManager );
-		SAFE_DELETE( mGpuProgramManager );			
+		HardwareBufferManager::shutDown();
+		GpuProgramManager::shutDown();		
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	RenderWindow* D3D9RenderSystem::_createRenderWindow(const String &name, 
 	RenderWindow* D3D9RenderSystem::_createRenderWindow(const String &name, 
@@ -1310,7 +1307,7 @@ namespace CamelotEngine
 		}
 		}
 
 
 		if (caps->isShaderProfileSupported("hlsl"))
 		if (caps->isShaderProfileSupported("hlsl"))
-			HighLevelGpuProgramManager::getSingleton().addFactory(mHLSLProgramFactory);
+			HighLevelGpuProgramManager::instance().addFactory(mHLSLProgramFactory);
 	}
 	}
 
 
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------

+ 0 - 9
CamelotGLRenderer/Include/CmGLRenderSystem.h

@@ -98,8 +98,6 @@ namespace CamelotEngine {
         /// Check if the GL system has already been initialised
         /// Check if the GL system has already been initialised
         bool mGLInitialised;
         bool mGLInitialised;
 
 
-        HardwareBufferManager* mHardwareBufferManager;
-        GLGpuProgramManager* mGpuProgramManager;
 		GLSLProgramFactory* mGLSLProgramFactory;
 		GLSLProgramFactory* mGLSLProgramFactory;
 
 
         unsigned short mCurrentLights;
         unsigned short mCurrentLights;
@@ -118,13 +116,6 @@ namespace CamelotEngine {
 		/// List of background thread contexts
 		/// List of background thread contexts
 		GLContextList mBackgroundContextList;
 		GLContextList mBackgroundContextList;
 
 
-        /** Manager object for creating render textures.
-            Direct render to texture via GL_EXT_framebuffer_object is preferable 
-			to pbuffers, which depend on the GL support used and are generally 
-			unwieldy and slow. However, FBO support for stencil buffers is poor.
-        */
-        GLRTTManager *mRTTManager;
-
 		UINT16 mActiveTextureUnit;
 		UINT16 mActiveTextureUnit;
 
 
 	protected:
 	protected:

+ 2 - 1
CamelotGLRenderer/Include/CmGLRenderTexture.h

@@ -30,6 +30,7 @@ THE SOFTWARE.
 #define __GLRENDERTEXTURE_H__
 #define __GLRENDERTEXTURE_H__
 
 
 #include "CmGLTexture.h"
 #include "CmGLTexture.h"
+#include "CmModule.h"
 
 
 namespace CamelotEngine {
 namespace CamelotEngine {
     /** GL surface descriptor. Points to a 2D surface that can be rendered to. 
     /** GL surface descriptor. Points to a 2D surface that can be rendered to. 
@@ -57,7 +58,7 @@ namespace CamelotEngine {
     
     
     /** Manager/factory for RenderTextures.
     /** Manager/factory for RenderTextures.
     */
     */
-    class CM_RSGL_EXPORT GLRTTManager: public Singleton<GLRTTManager>
+    class CM_RSGL_EXPORT GLRTTManager: public Module<GLRTTManager>
     {
     {
     public:
     public:
         virtual ~GLRTTManager();
         virtual ~GLRTTManager();

+ 2 - 2
CamelotGLRenderer/Source/CmGLHardwareIndexBuffer.cpp

@@ -72,7 +72,7 @@ namespace CamelotEngine {
         
         
 		void* retPtr = 0;
 		void* retPtr = 0;
 
 
-		GLHardwareBufferManager* glBufManager = static_cast<GLHardwareBufferManager*>(HardwareBufferManager::getSingletonPtr());
+		GLHardwareBufferManager* glBufManager = static_cast<GLHardwareBufferManager*>(HardwareBufferManager::instancePtr());
 
 
 		// Try to use scratch buffers for smaller buffers
 		// Try to use scratch buffers for smaller buffers
 		if( length < glBufManager->getGLMapBufferThreshold() )
 		if( length < glBufManager->getGLMapBufferThreshold() )
@@ -143,7 +143,7 @@ namespace CamelotEngine {
 
 
 			// deallocate from scratch buffer
 			// deallocate from scratch buffer
 			static_cast<GLHardwareBufferManager*>(
 			static_cast<GLHardwareBufferManager*>(
-				HardwareBufferManager::getSingletonPtr())->deallocateScratch(mScratchPtr);
+				HardwareBufferManager::instancePtr())->deallocateScratch(mScratchPtr);
 
 
 			mLockedToScratch = false;
 			mLockedToScratch = false;
 		}
 		}

+ 2 - 2
CamelotGLRenderer/Source/CmGLHardwarePixelBuffer.cpp

@@ -264,7 +264,7 @@ GLTextureBuffer::GLTextureBuffer(const String &baseName, GLenum target, GLuint i
             GLSurfaceDesc surface;
             GLSurfaceDesc surface;
             surface.buffer = this;
             surface.buffer = this;
             surface.zoffset = zoffset;
             surface.zoffset = zoffset;
-            RenderTexture *trt = GLRTTManager::getSingleton().createRenderTexture(name, surface, writeGamma, fsaa);
+            RenderTexture *trt = GLRTTManager::instance().createRenderTexture(name, surface, writeGamma, fsaa);
             mSliceTRT.push_back(trt);
             mSliceTRT.push_back(trt);
             CamelotEngine::RenderSystemManager::getActive()->attachRenderTarget(*mSliceTRT[zoffset]);
             CamelotEngine::RenderSystemManager::getActive()->attachRenderTarget(*mSliceTRT[zoffset]);
         }
         }
@@ -568,7 +568,7 @@ void GLTextureBuffer::blitFromTexture(GLTextureBuffer *src, const Box &srcBox, c
     //src->mTextureID << ":" << srcBox.left << "," << srcBox.top << "," << srcBox.right << "," << srcBox.bottom << " " << 
     //src->mTextureID << ":" << srcBox.left << "," << srcBox.top << "," << srcBox.right << "," << srcBox.bottom << " " << 
     //mTextureID << ":" << dstBox.left << "," << dstBox.top << "," << dstBox.right << "," << dstBox.bottom << std::endl;
     //mTextureID << ":" << dstBox.left << "," << dstBox.top << "," << dstBox.right << "," << dstBox.bottom << std::endl;
     /// Store reference to FBO manager
     /// Store reference to FBO manager
-    GLFBOManager *fboMan = static_cast<GLFBOManager *>(GLRTTManager::getSingletonPtr());
+    GLFBOManager *fboMan = static_cast<GLFBOManager *>(GLRTTManager::instancePtr());
     
     
     /// Save and clear GL state for rendering
     /// Save and clear GL state for rendering
     glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | 
     glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | 

+ 2 - 2
CamelotGLRenderer/Source/CmGLHardwareVertexBuffer.cpp

@@ -72,7 +72,7 @@ namespace CamelotEngine {
 
 
 		void* retPtr = 0;
 		void* retPtr = 0;
 
 
-		GLHardwareBufferManager* glBufManager = static_cast<GLHardwareBufferManager*>(HardwareBufferManager::getSingletonPtr());
+		GLHardwareBufferManager* glBufManager = static_cast<GLHardwareBufferManager*>(HardwareBufferManager::instancePtr());
 
 
 		// Try to use scratch buffers for smaller buffers
 		// Try to use scratch buffers for smaller buffers
 		if( length < glBufManager->getGLMapBufferThreshold() )
 		if( length < glBufManager->getGLMapBufferThreshold() )
@@ -145,7 +145,7 @@ namespace CamelotEngine {
 
 
 			// deallocate from scratch buffer
 			// deallocate from scratch buffer
 			static_cast<GLHardwareBufferManager*>(
 			static_cast<GLHardwareBufferManager*>(
-				HardwareBufferManager::getSingletonPtr())->deallocateScratch(mScratchPtr);
+				HardwareBufferManager::instancePtr())->deallocateScratch(mScratchPtr);
 
 
 			mLockedToScratch = false;
 			mLockedToScratch = false;
 		}
 		}

+ 31 - 41
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -73,10 +73,8 @@ namespace CamelotEngine {
 	}
 	}
 
 
 	GLRenderSystem::GLRenderSystem()
 	GLRenderSystem::GLRenderSystem()
-		: mDepthWrite(true), mStencilMask(0xFFFFFFFF), mHardwareBufferManager(0),
-		mGpuProgramManager(0),
+		: mDepthWrite(true), mStencilMask(0xFFFFFFFF),
 		mGLSLProgramFactory(0),
 		mGLSLProgramFactory(0),
-		mRTTManager(0),
 		mActiveTextureUnit(0)
 		mActiveTextureUnit(0)
 	{
 	{
 		size_t i;
 		size_t i;
@@ -639,44 +637,42 @@ namespace CamelotEngine {
 
 
 		if(caps->hasCapability(RSC_VBO))
 		if(caps->hasCapability(RSC_VBO))
 		{
 		{
-
-			mHardwareBufferManager = new GLHardwareBufferManager;
+			HardwareBufferManager::startUp(new GLHardwareBufferManager);
 		}
 		}
 		else
 		else
 		{
 		{
-			mHardwareBufferManager = new GLDefaultHardwareBufferManager;
+			HardwareBufferManager::startUp(new GLDefaultHardwareBufferManager);
 		}
 		}
 
 
-		// XXX Need to check for nv2 support and make a program manager for it
-		// XXX Probably nv1 as well for older cards
 		// GPU Program Manager setup
 		// GPU Program Manager setup
-		mGpuProgramManager = new GLGpuProgramManager();
+		GpuProgramManager::startUp(new GLGpuProgramManager());
+		GLGpuProgramManager* gpuProgramManager = static_cast<GLGpuProgramManager*>(GpuProgramManager::instancePtr());
 
 
 		if(caps->hasCapability(RSC_VERTEX_PROGRAM))
 		if(caps->hasCapability(RSC_VERTEX_PROGRAM))
 		{
 		{
 			if(caps->isShaderProfileSupported("arbvp1"))
 			if(caps->isShaderProfileSupported("arbvp1"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("arbvp1", createGLArbGpuProgram);
+				gpuProgramManager->registerProgramFactory("arbvp1", createGLArbGpuProgram);
 			}
 			}
 
 
 			if(caps->isShaderProfileSupported("vp30"))
 			if(caps->isShaderProfileSupported("vp30"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("vp30", createGLArbGpuProgram);
+				gpuProgramManager->registerProgramFactory("vp30", createGLArbGpuProgram);
 			}
 			}
 
 
 			if(caps->isShaderProfileSupported("vp40"))
 			if(caps->isShaderProfileSupported("vp40"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("vp40", createGLArbGpuProgram);
+				gpuProgramManager->registerProgramFactory("vp40", createGLArbGpuProgram);
 			}
 			}
 
 
 			if(caps->isShaderProfileSupported("gp4vp"))
 			if(caps->isShaderProfileSupported("gp4vp"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("gp4vp", createGLArbGpuProgram);
+				gpuProgramManager->registerProgramFactory("gp4vp", createGLArbGpuProgram);
 			}
 			}
 
 
 			if(caps->isShaderProfileSupported("gpu_vp"))
 			if(caps->isShaderProfileSupported("gpu_vp"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("gpu_vp", createGLArbGpuProgram);
+				gpuProgramManager->registerProgramFactory("gpu_vp", createGLArbGpuProgram);
 			}
 			}
 		}
 		}
 
 
@@ -685,15 +681,15 @@ namespace CamelotEngine {
 			//TODO : Should these be createGLArbGpuProgram or createGLGpuNVparseProgram?
 			//TODO : Should these be createGLArbGpuProgram or createGLGpuNVparseProgram?
 			if(caps->isShaderProfileSupported("nvgp4"))
 			if(caps->isShaderProfileSupported("nvgp4"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("nvgp4", createGLArbGpuProgram);
+				gpuProgramManager->registerProgramFactory("nvgp4", createGLArbGpuProgram);
 			}
 			}
 			if(caps->isShaderProfileSupported("gp4gp"))
 			if(caps->isShaderProfileSupported("gp4gp"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("gp4gp", createGLArbGpuProgram);
+				gpuProgramManager->registerProgramFactory("gp4gp", createGLArbGpuProgram);
 			}
 			}
 			if(caps->isShaderProfileSupported("gpu_gp"))
 			if(caps->isShaderProfileSupported("gpu_gp"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("gpu_gp", createGLArbGpuProgram);
+				gpuProgramManager->registerProgramFactory("gpu_gp", createGLArbGpuProgram);
 			}
 			}
 		}
 		}
 
 
@@ -701,37 +697,37 @@ namespace CamelotEngine {
 		{
 		{
 			if(caps->isShaderProfileSupported("ps_1_4"))
 			if(caps->isShaderProfileSupported("ps_1_4"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("ps_1_4", createGL_ATI_FS_GpuProgram);
+				gpuProgramManager->registerProgramFactory("ps_1_4", createGL_ATI_FS_GpuProgram);
 			}
 			}
 
 
 			if(caps->isShaderProfileSupported("ps_1_3"))
 			if(caps->isShaderProfileSupported("ps_1_3"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("ps_1_3", createGL_ATI_FS_GpuProgram);
+				gpuProgramManager->registerProgramFactory("ps_1_3", createGL_ATI_FS_GpuProgram);
 			}
 			}
 
 
 			if(caps->isShaderProfileSupported("ps_1_2"))
 			if(caps->isShaderProfileSupported("ps_1_2"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("ps_1_2", createGL_ATI_FS_GpuProgram);
+				gpuProgramManager->registerProgramFactory("ps_1_2", createGL_ATI_FS_GpuProgram);
 			}
 			}
 
 
 			if(caps->isShaderProfileSupported("ps_1_1"))
 			if(caps->isShaderProfileSupported("ps_1_1"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("ps_1_1", createGL_ATI_FS_GpuProgram);
+				gpuProgramManager->registerProgramFactory("ps_1_1", createGL_ATI_FS_GpuProgram);
 			}
 			}
 
 
 			if(caps->isShaderProfileSupported("arbfp1"))
 			if(caps->isShaderProfileSupported("arbfp1"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("arbfp1", createGLArbGpuProgram);
+				gpuProgramManager->registerProgramFactory("arbfp1", createGLArbGpuProgram);
 			}
 			}
 
 
 			if(caps->isShaderProfileSupported("fp40"))
 			if(caps->isShaderProfileSupported("fp40"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("fp40", createGLArbGpuProgram);
+				gpuProgramManager->registerProgramFactory("fp40", createGLArbGpuProgram);
 			}
 			}
 
 
 			if(caps->isShaderProfileSupported("fp30"))
 			if(caps->isShaderProfileSupported("fp30"))
 			{
 			{
-				mGpuProgramManager->registerProgramFactory("fp30", createGLArbGpuProgram);
+				gpuProgramManager->registerProgramFactory("fp30", createGLArbGpuProgram);
 			}
 			}
 
 
 		}
 		}
@@ -740,7 +736,7 @@ namespace CamelotEngine {
 		{
 		{
 			// NFZ - check for GLSL vertex and fragment shader support successful
 			// NFZ - check for GLSL vertex and fragment shader support successful
 			mGLSLProgramFactory = new GLSLProgramFactory();
 			mGLSLProgramFactory = new GLSLProgramFactory();
-			HighLevelGpuProgramManager::getSingleton().addFactory(mGLSLProgramFactory);
+			HighLevelGpuProgramManager::instance().addFactory(mGLSLProgramFactory);
 		}
 		}
 
 
 		if(caps->hasCapability(RSC_HWOCCLUSION))
 		if(caps->hasCapability(RSC_HWOCCLUSION))
@@ -795,7 +791,7 @@ namespace CamelotEngine {
 				// Create FBO manager
 				// Create FBO manager
 				// TODO LOG PORT - Log this somewhere?
 				// TODO LOG PORT - Log this somewhere?
 				//LogManager::getSingleton().logMessage("GL: Using GL_EXT_framebuffer_object for rendering to textures (best)");
 				//LogManager::getSingleton().logMessage("GL: Using GL_EXT_framebuffer_object for rendering to textures (best)");
-				mRTTManager = new GLFBOManager(false);
+				GLRTTManager::startUp(new GLFBOManager(false));
 			}
 			}
 
 
 		}
 		}
@@ -807,7 +803,7 @@ namespace CamelotEngine {
 				if(caps->hasCapability(RSC_HWRENDER_TO_TEXTURE))
 				if(caps->hasCapability(RSC_HWRENDER_TO_TEXTURE))
 				{
 				{
 					// Use PBuffers
 					// Use PBuffers
-					mRTTManager = new GLPBRTTManager(mGLSupport, primary);
+					GLRTTManager::startUp(new GLPBRTTManager(mGLSupport, primary));
 
 
 					// TODO LOG PORT - Log this somewhere?
 					// TODO LOG PORT - Log this somewhere?
 					//LogManager::getSingleton().logMessage("GL: Using PBuffers for rendering to textures");
 					//LogManager::getSingleton().logMessage("GL: Using PBuffers for rendering to textures");
@@ -816,7 +812,7 @@ namespace CamelotEngine {
 			else
 			else
 			{
 			{
 				// No pbuffer support either -- fallback to simplest copying from framebuffer
 				// No pbuffer support either -- fallback to simplest copying from framebuffer
-				mRTTManager = new GLCopyingRTTManager();
+				GLRTTManager::startUp(new GLCopyingRTTManager());
 				// TODO LOG PORT - Log this somewhere?
 				// TODO LOG PORT - Log this somewhere?
 				//LogManager::getSingleton().logMessage("GL: Using framebuffer copy for rendering to textures (worst)");
 				//LogManager::getSingleton().logMessage("GL: Using framebuffer copy for rendering to textures (worst)");
 				//LogManager::getSingleton().logMessage("GL: Warning: RenderTexture size is restricted to size of framebuffer. If you are on Linux, consider using GLX instead of SDL.");
 				//LogManager::getSingleton().logMessage("GL: Warning: RenderTexture size is restricted to size of framebuffer. If you are on Linux, consider using GLX instead of SDL.");
@@ -846,21 +842,15 @@ namespace CamelotEngine {
 		if (mGLSLProgramFactory)
 		if (mGLSLProgramFactory)
 		{
 		{
 			// Remove from manager safely
 			// Remove from manager safely
-			if (HighLevelGpuProgramManager::getSingletonPtr())
-				HighLevelGpuProgramManager::getSingleton().removeFactory(mGLSLProgramFactory);
+			HighLevelGpuProgramManager::instance().removeFactory(mGLSLProgramFactory);
 			delete mGLSLProgramFactory;
 			delete mGLSLProgramFactory;
 			mGLSLProgramFactory = 0;
 			mGLSLProgramFactory = 0;
 		}
 		}
 
 
 		// Deleting the GPU program manager and hardware buffer manager.  Has to be done before the mGLSupport->stop().
 		// Deleting the GPU program manager and hardware buffer manager.  Has to be done before the mGLSupport->stop().
-		delete mGpuProgramManager;
-		mGpuProgramManager = 0;
-
-		delete mHardwareBufferManager;
-		mHardwareBufferManager = 0;
-
-		delete mRTTManager;
-		mRTTManager = 0;
+		GpuProgramManager::shutDown();
+		HardwareBufferManager::shutDown();
+		GLRTTManager::shutDown();
 
 
 		// Delete extra threads contexts
 		// Delete extra threads contexts
 		for (GLContextList::iterator i = mBackgroundContextList.begin(); 
 		for (GLContextList::iterator i = mBackgroundContextList.begin(); 
@@ -1007,7 +997,7 @@ namespace CamelotEngine {
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	MultiRenderTarget * GLRenderSystem::createMultiRenderTarget(const String & name)
 	MultiRenderTarget * GLRenderSystem::createMultiRenderTarget(const String & name)
 	{
 	{
-		MultiRenderTarget *retval = mRTTManager->createMultiRenderTarget(name);
+		MultiRenderTarget *retval = GLRTTManager::instancePtr()->createMultiRenderTarget(name);
 		attachRenderTarget( *retval );
 		attachRenderTarget( *retval );
 		return retval;
 		return retval;
 	}
 	}
@@ -3026,7 +3016,7 @@ namespace CamelotEngine {
 	{
 	{
 		// Unbind frame buffer object
 		// Unbind frame buffer object
 		if(mActiveRenderTarget)
 		if(mActiveRenderTarget)
-			mRTTManager->unbind(mActiveRenderTarget);
+			GLRTTManager::instancePtr()->unbind(mActiveRenderTarget);
 
 
 		mActiveRenderTarget = target;
 		mActiveRenderTarget = target;
 
 
@@ -3039,7 +3029,7 @@ namespace CamelotEngine {
 		}
 		}
 
 
 		// Bind frame buffer object
 		// Bind frame buffer object
-		mRTTManager->bind(target);
+		GLRTTManager::instancePtr()->bind(target);
 
 
 		if (GLEW_EXT_framebuffer_sRGB)
 		if (GLEW_EXT_framebuffer_sRGB)
 		{
 		{

+ 0 - 1
CamelotGLRenderer/Source/CmGLRenderTexture.cpp

@@ -34,7 +34,6 @@ namespace CamelotEngine {
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 
 
-template<> GLRTTManager* Singleton<GLRTTManager>::ms_Singleton = 0;
     GLRTTManager::~GLRTTManager()
     GLRTTManager::~GLRTTManager()
     {
     {
     }
     }

+ 1 - 1
CamelotGLRenderer/Source/CmGLTextureManager.cpp

@@ -105,7 +105,7 @@ namespace CamelotEngine {
         {
         {
             /// Get closest supported alternative
             /// Get closest supported alternative
             /// If mFormat is supported it's returned
             /// If mFormat is supported it's returned
-            return GLRTTManager::getSingleton().getSupportedAlternative(format);
+            return GLRTTManager::instance().getSupportedAlternative(format);
         }
         }
 
 
 		// Supported
 		// Supported

+ 2 - 6
CamelotGLRenderer/Source/GLSL/include/CmGLSLLinkProgramManager.h

@@ -29,7 +29,7 @@ THE SOFTWARE.
 #define __GLSLLinkProgramManager_H__
 #define __GLSLLinkProgramManager_H__
 
 
 #include "CmGLPrerequisites.h"
 #include "CmGLPrerequisites.h"
-#include "CmSingleton.h"
+#include "CmModule.h"
 
 
 #include "CmGLSLExtSupport.h"
 #include "CmGLSLExtSupport.h"
 #include "CmGLSLLinkProgram.h"
 #include "CmGLSLLinkProgram.h"
@@ -49,7 +49,7 @@ namespace CamelotEngine {
 
 
 	*/
 	*/
 
 
-	class CM_RSGL_EXPORT GLSLLinkProgramManager : public Singleton<GLSLLinkProgramManager>
+	class CM_RSGL_EXPORT GLSLLinkProgramManager : public Module<GLSLLinkProgramManager>
 	{
 	{
 
 
 	private:
 	private:
@@ -133,10 +133,6 @@ namespace CamelotEngine {
 		*/
 		*/
 		void extractConstantDefs(const String& src, GpuNamedConstants& constantDefs, 
 		void extractConstantDefs(const String& src, GpuNamedConstants& constantDefs, 
 			const String& filename);
 			const String& filename);
-
-		static GLSLLinkProgramManager& getSingleton(void);
-        static GLSLLinkProgramManager* getSingletonPtr(void);
-
 	};
 	};
 
 
 }
 }

+ 0 - 4
CamelotGLRenderer/Source/GLSL/include/CmGLSLProgramFactory.h

@@ -48,10 +48,6 @@ namespace CamelotEngine
 		/// create an instance of GLSLProgram
 		/// create an instance of GLSLProgram
         HighLevelGpuProgram* create(const String& source, const String& entryPoint, GpuProgramProfile profile);
         HighLevelGpuProgram* create(const String& source, const String& entryPoint, GpuProgramProfile profile);
 		void destroy(HighLevelGpuProgram* prog);
 		void destroy(HighLevelGpuProgram* prog);
-
-	private:
-		GLSLLinkProgramManager* mLinkProgramManager;
-
     };
     };
 }
 }
 
 

+ 10 - 10
CamelotGLRenderer/Source/GLSL/src/CmGLSLGpuProgram.cpp

@@ -90,13 +90,13 @@ namespace CamelotEngine {
 		switch (mType)
 		switch (mType)
 		{
 		{
 		case GPT_VERTEX_PROGRAM:
 		case GPT_VERTEX_PROGRAM:
-			GLSLLinkProgramManager::getSingleton().setActiveVertexShader( this );
+			GLSLLinkProgramManager::instance().setActiveVertexShader( this );
 			break;
 			break;
 		case GPT_FRAGMENT_PROGRAM:
 		case GPT_FRAGMENT_PROGRAM:
-			GLSLLinkProgramManager::getSingleton().setActiveFragmentShader( this );
+			GLSLLinkProgramManager::instance().setActiveFragmentShader( this );
 			break;
 			break;
 		case GPT_GEOMETRY_PROGRAM:
 		case GPT_GEOMETRY_PROGRAM:
-			GLSLLinkProgramManager::getSingleton().setActiveGeometryShader( this );
+			GLSLLinkProgramManager::instance().setActiveGeometryShader( this );
 			break;
 			break;
 		}
 		}
 	}
 	}
@@ -107,15 +107,15 @@ namespace CamelotEngine {
 		// tell the Link Program Manager what shader is to become inactive
 		// tell the Link Program Manager what shader is to become inactive
 		if (mType == GPT_VERTEX_PROGRAM)
 		if (mType == GPT_VERTEX_PROGRAM)
 		{
 		{
-			GLSLLinkProgramManager::getSingleton().setActiveVertexShader( NULL );
+			GLSLLinkProgramManager::instance().setActiveVertexShader( NULL );
 		}
 		}
 		else if (mType == GPT_GEOMETRY_PROGRAM)
 		else if (mType == GPT_GEOMETRY_PROGRAM)
 		{
 		{
-			GLSLLinkProgramManager::getSingleton().setActiveGeometryShader( NULL );
+			GLSLLinkProgramManager::instance().setActiveGeometryShader( NULL );
 		}
 		}
 		else // its a fragment shader
 		else // its a fragment shader
 		{
 		{
-			GLSLLinkProgramManager::getSingleton().setActiveFragmentShader( NULL );
+			GLSLLinkProgramManager::instance().setActiveFragmentShader( NULL );
 		}
 		}
 
 
 	}
 	}
@@ -124,7 +124,7 @@ namespace CamelotEngine {
 	void GLSLGpuProgram::bindProgramParameters(GpuProgramParametersSharedPtr params, UINT16 mask)
 	void GLSLGpuProgram::bindProgramParameters(GpuProgramParametersSharedPtr params, UINT16 mask)
 	{
 	{
 		// activate the link program object
 		// activate the link program object
-		GLSLLinkProgram* linkProgram = GLSLLinkProgramManager::getSingleton().getActiveLinkProgram();
+		GLSLLinkProgram* linkProgram = GLSLLinkProgramManager::instance().getActiveLinkProgram();
 		// pass on parameters from params to program object uniforms
 		// pass on parameters from params to program object uniforms
 		linkProgram->updateUniforms(params, mask, mType);
 		linkProgram->updateUniforms(params, mask, mType);
 	}
 	}
@@ -133,7 +133,7 @@ namespace CamelotEngine {
 	void GLSLGpuProgram::bindProgramPassIterationParameters(GpuProgramParametersSharedPtr params)
 	void GLSLGpuProgram::bindProgramPassIterationParameters(GpuProgramParametersSharedPtr params)
 	{
 	{
 		// activate the link program object
 		// activate the link program object
-		GLSLLinkProgram* linkProgram = GLSLLinkProgramManager::getSingleton().getActiveLinkProgram();
+		GLSLLinkProgram* linkProgram = GLSLLinkProgramManager::instance().getActiveLinkProgram();
 		// pass on parameters from params to program object uniforms
 		// pass on parameters from params to program object uniforms
 		linkProgram->updatePassIterationUniforms( params );
 		linkProgram->updatePassIterationUniforms( params );
 		
 		
@@ -142,7 +142,7 @@ namespace CamelotEngine {
 	GLuint GLSLGpuProgram::getAttributeIndex(VertexElementSemantic semantic, UINT32 index)
 	GLuint GLSLGpuProgram::getAttributeIndex(VertexElementSemantic semantic, UINT32 index)
 	{
 	{
 		// get link program - only call this in the context of bound program
 		// get link program - only call this in the context of bound program
-		GLSLLinkProgram* linkProgram = GLSLLinkProgramManager::getSingleton().getActiveLinkProgram();
+		GLSLLinkProgram* linkProgram = GLSLLinkProgramManager::instance().getActiveLinkProgram();
 
 
 		if (linkProgram->isAttributeValid(semantic, index))
 		if (linkProgram->isAttributeValid(semantic, index))
 		{
 		{
@@ -159,7 +159,7 @@ namespace CamelotEngine {
 	bool GLSLGpuProgram::isAttributeValid(VertexElementSemantic semantic, UINT32 index)
 	bool GLSLGpuProgram::isAttributeValid(VertexElementSemantic semantic, UINT32 index)
 	{
 	{
 		// get link program - only call this in the context of bound program
 		// get link program - only call this in the context of bound program
-		GLSLLinkProgram* linkProgram = GLSLLinkProgramManager::getSingleton().getActiveLinkProgram();
+		GLSLLinkProgram* linkProgram = GLSLLinkProgramManager::instance().getActiveLinkProgram();
 
 
 		if (linkProgram->isAttributeValid(semantic, index))
 		if (linkProgram->isAttributeValid(semantic, index))
 		{
 		{

+ 1 - 1
CamelotGLRenderer/Source/GLSL/src/CmGLSLLinkProgram.cpp

@@ -291,7 +291,7 @@ namespace CamelotEngine {
 				fragParams = &(mFragmentProgram->getGLSLProgram()->getConstantDefinitions().map);
 				fragParams = &(mFragmentProgram->getGLSLProgram()->getConstantDefinitions().map);
 			}
 			}
 
 
-			GLSLLinkProgramManager::getSingleton().extractUniforms(
+			GLSLLinkProgramManager::instance().extractUniforms(
 				mGLHandle, vertParams, geomParams, fragParams, mGLUniformReferences);
 				mGLHandle, vertParams, geomParams, fragParams, mGLUniformReferences);
 
 
 			mUniformRefsBuilt = true;
 			mUniformRefsBuilt = true;

+ 0 - 15
CamelotGLRenderer/Source/GLSL/src/CmGLSLLinkProgramManager.cpp

@@ -32,21 +32,6 @@ THE SOFTWARE.
 
 
 namespace CamelotEngine {
 namespace CamelotEngine {
 
 
-	//-----------------------------------------------------------------------
-	template<> GLSLLinkProgramManager* Singleton<GLSLLinkProgramManager>::ms_Singleton = 0;
-
-	//-----------------------------------------------------------------------
-    GLSLLinkProgramManager* GLSLLinkProgramManager::getSingletonPtr(void)
-    {
-        return ms_Singleton;
-    }
-
-	//-----------------------------------------------------------------------
-    GLSLLinkProgramManager& GLSLLinkProgramManager::getSingleton(void)
-    {  
-        assert( ms_Singleton );  return ( *ms_Singleton );  
-    }
-
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	GLSLLinkProgramManager::GLSLLinkProgramManager(void) : mActiveVertexGpuProgram(NULL),
 	GLSLLinkProgramManager::GLSLLinkProgramManager(void) : mActiveVertexGpuProgram(NULL),
 		mActiveGeometryGpuProgram(NULL), mActiveFragmentGpuProgram(NULL), mActiveLinkProgram(NULL)
 		mActiveGeometryGpuProgram(NULL), mActiveFragmentGpuProgram(NULL), mActiveLinkProgram(NULL)

+ 2 - 2
CamelotGLRenderer/Source/GLSL/src/CmGLSLProgram.cpp

@@ -216,7 +216,7 @@ namespace CamelotEngine {
 
 
 		// Therefore instead, parse the source code manually and extract the uniforms
 		// Therefore instead, parse the source code manually and extract the uniforms
 		createParameterMappingStructures(true);
 		createParameterMappingStructures(true);
-		GLSLLinkProgramManager::getSingleton().extractConstantDefs(
+		GLSLLinkProgramManager::instance().extractConstantDefs(
 			mSource, *mConstantDefs.get(), "");
 			mSource, *mConstantDefs.get(), "");
 
 
 		// Also parse any attached sources
 		// Also parse any attached sources
@@ -225,7 +225,7 @@ namespace CamelotEngine {
 		{
 		{
 			GLSLProgram* childShader = *i;
 			GLSLProgram* childShader = *i;
 
 
-			GLSLLinkProgramManager::getSingleton().extractConstantDefs(
+			GLSLLinkProgramManager::instance().extractConstantDefs(
 				childShader->getSource(), *mConstantDefs.get(), "");
 				childShader->getSource(), *mConstantDefs.get(), "");
 
 
 		}
 		}

+ 2 - 3
CamelotGLRenderer/Source/GLSL/src/CmGLSLProgramFactory.cpp

@@ -36,13 +36,12 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
 	GLSLProgramFactory::GLSLProgramFactory(void)
 	GLSLProgramFactory::GLSLProgramFactory(void)
     {
     {
-		mLinkProgramManager = new GLSLLinkProgramManager();
+		GLSLLinkProgramManager::startUp(new GLSLLinkProgramManager());
     }
     }
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     GLSLProgramFactory::~GLSLProgramFactory(void)
     GLSLProgramFactory::~GLSLProgramFactory(void)
     {
     {
-		if (mLinkProgramManager)
-			delete mLinkProgramManager;
+		GLSLLinkProgramManager::shutDown();
     }
     }
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     const String& GLSLProgramFactory::getLanguage(void) const
     const String& GLSLProgramFactory::getLanguage(void) const

+ 0 - 2
CamelotRenderer/Include/CmApplication.h

@@ -24,8 +24,6 @@ namespace CamelotEngine
 			void DBG_renderSimpleFrame();
 			void DBG_renderSimpleFrame();
 
 
 		private:
 		private:
-			HighLevelGpuProgramManager* mGpuProgramManager;
-
 			RenderWindow* mRenderWindow;
 			RenderWindow* mRenderWindow;
 			Viewport* mViewport;
 			Viewport* mViewport;
 			Camera* mCamera;
 			Camera* mCamera;

+ 2 - 38
CamelotRenderer/Include/CmGpuProgramManager.h

@@ -32,7 +32,7 @@ THE SOFTWARE.
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include "CmException.h"
 #include "CmException.h"
 #include "CmGpuProgram.h"
 #include "CmGpuProgram.h"
-#include "CmSingleton.h"
+#include "CmModule.h"
 
 
 namespace CamelotEngine {
 namespace CamelotEngine {
 
 
@@ -42,7 +42,7 @@ namespace CamelotEngine {
 	/** \addtogroup Resources
 	/** \addtogroup Resources
 	*  @{
 	*  @{
 	*/
 	*/
-	class CM_EXPORT GpuProgramManager : public Singleton<GpuProgramManager>
+	class CM_EXPORT GpuProgramManager : public Module<GpuProgramManager>
 	{
 	{
 	public:
 	public:
 
 
@@ -122,42 +122,6 @@ namespace CamelotEngine {
 		/** Get (const) access to the available shared parameter sets. 
 		/** Get (const) access to the available shared parameter sets. 
 		*/
 		*/
 		virtual const SharedParametersMap& getAvailableSharedParameters() const;
 		virtual const SharedParametersMap& getAvailableSharedParameters() const;
-
-        /** Override standard Singleton retrieval.
-        @remarks
-        Why do we do this? Well, it's because the Singleton
-        implementation is in a .h file, which means it gets compiled
-        into anybody who includes it. This is needed for the
-        Singleton template to work, but we actually only want it
-        compiled into the implementation of the class based on the
-        Singleton, not all of them. If we don't change this, we get
-        link errors when trying to use the Singleton-based class from
-        an outside dll.
-        @par
-        This method just delegates to the template version anyway,
-        but the implementation stays in this single compilation unit,
-        preventing link errors.
-        */
-        static GpuProgramManager& getSingleton(void);
-        /** Override standard Singleton retrieval.
-        @remarks
-        Why do we do this? Well, it's because the Singleton
-        implementation is in a .h file, which means it gets compiled
-        into anybody who includes it. This is needed for the
-        Singleton template to work, but we actually only want it
-        compiled into the implementation of the class based on the
-        Singleton, not all of them. If we don't change this, we get
-        link errors when trying to use the Singleton-based class from
-        an outside dll.
-        @par
-        This method just delegates to the template version anyway,
-        but the implementation stays in this single compilation unit,
-        preventing link errors.
-        */
-        static GpuProgramManager* getSingletonPtr(void);
-    
-
-
 	};
 	};
 
 
 	/** @} */
 	/** @} */

+ 3 - 38
CamelotRenderer/Include/CmHardwareBufferManager.h

@@ -31,7 +31,7 @@ THE SOFTWARE.
 // Precompiler options
 // Precompiler options
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 
 
-#include "CmSingleton.h"
+#include "CmModule.h"
 #include "CmHardwareVertexBuffer.h"
 #include "CmHardwareVertexBuffer.h"
 #include "CmHardwareIndexBuffer.h"
 #include "CmHardwareIndexBuffer.h"
 
 
@@ -193,7 +193,7 @@ namespace CamelotEngine {
 	};
 	};
 
 
     /** Singleton wrapper for hardware buffer manager. */
     /** Singleton wrapper for hardware buffer manager. */
-    class CM_EXPORT HardwareBufferManager : public HardwareBufferManagerBase, public Singleton<HardwareBufferManager>
+    class CM_EXPORT HardwareBufferManager : public HardwareBufferManagerBase, public Module<HardwareBufferManager>
     {
     {
     protected:
     protected:
 		HardwareBufferManagerBase* mImpl;
 		HardwareBufferManagerBase* mImpl;
@@ -253,42 +253,7 @@ namespace CamelotEngine {
 		void _notifyIndexBufferDestroyed(HardwareIndexBuffer* buf)
 		void _notifyIndexBufferDestroyed(HardwareIndexBuffer* buf)
 		{
 		{
 			mImpl->_notifyIndexBufferDestroyed(buf);
 			mImpl->_notifyIndexBufferDestroyed(buf);
-		}
-
-
-        /** Override standard Singleton retrieval.
-        @remarks
-        Why do we do this? Well, it's because the Singleton
-        implementation is in a .h file, which means it gets compiled
-        into anybody who includes it. This is needed for the
-        Singleton template to work, but we actually only want it
-        compiled into the implementation of the class based on the
-        Singleton, not all of them. If we don't change this, we get
-        link errors when trying to use the Singleton-based class from
-        an outside dll.
-        @par
-        This method just delegates to the template version anyway,
-        but the implementation stays in this single compilation unit,
-        preventing link errors.
-        */
-        static HardwareBufferManager& getSingleton(void);
-        /** Override standard Singleton retrieval.
-        @remarks
-        Why do we do this? Well, it's because the Singleton
-        implementation is in a .h file, which means it gets compiled
-        into anybody who includes it. This is needed for the
-        Singleton template to work, but we actually only want it
-        compiled into the implementation of the class based on the
-        Singleton, not all of them. If we don't change this, we get
-        link errors when trying to use the Singleton-based class from
-        an outside dll.
-        @par
-        This method just delegates to the template version anyway,
-        but the implementation stays in this single compilation unit,
-        preventing link errors.
-        */
-        static HardwareBufferManager* getSingletonPtr(void);
-            
+		}            
     };
     };
 
 
 	/** @} */
 	/** @} */

+ 2 - 37
CamelotRenderer/Include/CmHighLevelGpuProgramManager.h

@@ -29,7 +29,7 @@ THE SOFTWARE.
 #define __HighLevelGpuProgramManager_H__
 #define __HighLevelGpuProgramManager_H__
 
 
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
-#include "CmSingleton.h"
+#include "CmModule.h"
 #include "CmException.h"
 #include "CmException.h"
 #include "CmHighLevelGpuProgram.h"
 #include "CmHighLevelGpuProgram.h"
 
 
@@ -65,7 +65,7 @@ namespace CamelotEngine {
 		factories and as such the engine can be extended to accept virtually any kind of
 		factories and as such the engine can be extended to accept virtually any kind of
 		program provided a plugin is written.
 		program provided a plugin is written.
 	*/
 	*/
-	class CM_EXPORT HighLevelGpuProgramManager : public Singleton<HighLevelGpuProgramManager>
+	class CM_EXPORT HighLevelGpuProgramManager : public Module<HighLevelGpuProgramManager>
 	{
 	{
 	public:
 	public:
 		typedef map<String, HighLevelGpuProgramFactory*>::type FactoryMap;
 		typedef map<String, HighLevelGpuProgramFactory*>::type FactoryMap;
@@ -101,41 +101,6 @@ namespace CamelotEngine {
 		@param gptype The type of program to create
 		@param gptype The type of program to create
 		*/
 		*/
 		HighLevelGpuProgramPtr createProgram(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype, GpuProgramProfile profile);
 		HighLevelGpuProgramPtr createProgram(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype, GpuProgramProfile profile);
-
-        /** Override standard Singleton retrieval.
-        @remarks
-        Why do we do this? Well, it's because the Singleton
-        implementation is in a .h file, which means it gets compiled
-        into anybody who includes it. This is needed for the
-        Singleton template to work, but we actually only want it
-        compiled into the implementation of the class based on the
-        Singleton, not all of them. If we don't change this, we get
-        link errors when trying to use the Singleton-based class from
-        an outside dll.
-        @par
-        This method just delegates to the template version anyway,
-        but the implementation stays in this single compilation unit,
-        preventing link errors.
-        */
-        static HighLevelGpuProgramManager& getSingleton(void);
-        /** Override standard Singleton retrieval.
-        @remarks
-        Why do we do this? Well, it's because the Singleton
-        implementation is in a .h file, which means it gets compiled
-        into anybody who includes it. This is needed for the
-        Singleton template to work, but we actually only want it
-        compiled into the implementation of the class based on the
-        Singleton, not all of them. If we don't change this, we get
-        link errors when trying to use the Singleton-based class from
-        an outside dll.
-        @par
-        This method just delegates to the template version anyway,
-        but the implementation stays in this single compilation unit,
-        preventing link errors.
-        */
-        static HighLevelGpuProgramManager* getSingletonPtr(void);
-
-
 	};
 	};
 	/** @} */
 	/** @} */
 	/** @} */
 	/** @} */

+ 7 - 9
CamelotRenderer/Source/CmApplication.cpp

@@ -15,13 +15,13 @@
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
 	Application::Application()
 	Application::Application()
-		:mRenderWindow(nullptr), mViewport(nullptr), mCamera(nullptr), mGpuProgramManager(nullptr)
+		:mRenderWindow(nullptr), mViewport(nullptr), mCamera(nullptr)
 	{ }
 	{ }
 
 
 	void Application::startUp(String renderSystemDll)
 	void Application::startUp(String renderSystemDll)
 	{
 	{
-		mGpuProgramManager = new HighLevelGpuProgramManager(); // TODO - Use Camelot::Module for instantiating this
 		DynLibManager::startUp(new DynLibManager());
 		DynLibManager::startUp(new DynLibManager());
+		HighLevelGpuProgramManager::startUp(new HighLevelGpuProgramManager());
 
 
 		RenderSystemManager::initialize(renderSystemDll);
 		RenderSystemManager::initialize(renderSystemDll);
 
 
@@ -69,7 +69,7 @@ namespace CamelotEngine
 									  gl_FragColor = vec4(0.0,1.0,0.0,1.0); \
 									  gl_FragColor = vec4(0.0,1.0,0.0,1.0); \
 									  }";
 									  }";
 
 
-		mFragProg = mGpuProgramManager->createProgram(fragShaderCode, "main", "glsl", GPT_FRAGMENT_PROGRAM, GPP_PS_2_0);
+		mFragProg = HighLevelGpuProgramManager::instance().createProgram(fragShaderCode, "main", "glsl", GPT_FRAGMENT_PROGRAM, GPP_PS_2_0);
 		mFragProg->load();
 		mFragProg->load();
 
 
 		// TODO - Ogres GLSL parsing requires some strict parameter naming, can that be avoided?
 		// TODO - Ogres GLSL parsing requires some strict parameter naming, can that be avoided?
@@ -80,7 +80,7 @@ namespace CamelotEngine
 									  gl_Position = matViewProjection * vertex; \
 									  gl_Position = matViewProjection * vertex; \
 									  }";
 									  }";
 
 
-		mVertProg = mGpuProgramManager->createProgram(vertShaderCode, "main", "glsl", GPT_VERTEX_PROGRAM, GPP_VS_2_0);
+		mVertProg = HighLevelGpuProgramManager::instance().createProgram(vertShaderCode, "main", "glsl", GPT_VERTEX_PROGRAM, GPP_VS_2_0);
 		mVertProg->load();
 		mVertProg->load();
 
 
 
 
@@ -97,9 +97,7 @@ namespace CamelotEngine
 		if(RenderSystemManager::getActive() != nullptr)
 		if(RenderSystemManager::getActive() != nullptr)
 			RenderSystemManager::getActive()->shutdown();
 			RenderSystemManager::getActive()->shutdown();
 
 
-		if(mGpuProgramManager != nullptr)
-			delete mGpuProgramManager;
-
+		HighLevelGpuProgramManager::shutDown();
 		DynLibManager::shutDown();
 		DynLibManager::shutDown();
 	}
 	}
 
 
@@ -109,7 +107,7 @@ namespace CamelotEngine
 		IndexData* indexData = new IndexData();
 		IndexData* indexData = new IndexData();
 
 
 		indexData->indexCount = 36;
 		indexData->indexCount = 36;
-		indexData->indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer(
+		indexData->indexBuffer = HardwareBufferManager::instance().createIndexBuffer(
 			HardwareIndexBuffer::IT_16BIT,
 			HardwareIndexBuffer::IT_16BIT,
 			36, 
 			36, 
 			HardwareBuffer::HBU_STATIC_WRITE_ONLY);
 			HardwareBuffer::HBU_STATIC_WRITE_ONLY);
@@ -152,7 +150,7 @@ namespace CamelotEngine
 		//decl->addElement(0, offset, VET_COLOUR, VES_DIFFUSE);
 		//decl->addElement(0, offset, VET_COLOUR, VES_DIFFUSE);
 		//offset += VertexElement::getTypeSize(VET_COLOUR);
 		//offset += VertexElement::getTypeSize(VET_COLOUR);
 
 
-		HardwareVertexBufferPtr vertexBuffer = HardwareBufferManager::getSingleton().createVertexBuffer(
+		HardwareVertexBufferPtr vertexBuffer = HardwareBufferManager::instance().createVertexBuffer(
 			vertexData->vertexDeclaration->getVertexSize(0),
 			vertexData->vertexDeclaration->getVertexSize(0),
 			vertexData->vertexCount,
 			vertexData->vertexCount,
 			HardwareBuffer::HBU_STATIC_WRITE_ONLY);
 			HardwareBuffer::HBU_STATIC_WRITE_ONLY);

+ 1 - 1
CamelotRenderer/Source/CmFrustum.cpp

@@ -532,7 +532,7 @@ namespace CamelotEngine {
                 mVertexData.vertexCount = 32;
                 mVertexData.vertexCount = 32;
                 mVertexData.vertexStart = 0;
                 mVertexData.vertexStart = 0;
                 mVertexData.vertexBufferBinding->setBinding( 0,
                 mVertexData.vertexBufferBinding->setBinding( 0,
-                    HardwareBufferManager::getSingleton().createVertexBuffer(
+                    HardwareBufferManager::instance().createVertexBuffer(
                         sizeof(float)*3, 32, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY) );
                         sizeof(float)*3, 32, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY) );
             }
             }
 
 

+ 0 - 10
CamelotRenderer/Source/CmGpuProgramManager.cpp

@@ -32,16 +32,6 @@ THE SOFTWARE.
 
 
 
 
 namespace CamelotEngine {
 namespace CamelotEngine {
-    //-----------------------------------------------------------------------
-    template<> GpuProgramManager* Singleton<GpuProgramManager>::ms_Singleton = 0;
-    GpuProgramManager* GpuProgramManager::getSingletonPtr(void)
-    {
-        return ms_Singleton;
-    }
-    GpuProgramManager& GpuProgramManager::getSingleton(void)
-    {  
-        assert( ms_Singleton );  return ( *ms_Singleton );  
-    }
 	//---------------------------------------------------------------------------
 	//---------------------------------------------------------------------------
 	GpuProgramManager::GpuProgramManager()
 	GpuProgramManager::GpuProgramManager()
 	{
 	{

+ 0 - 11
CamelotRenderer/Source/CmHardwareBufferManager.cpp

@@ -31,17 +31,6 @@ THE SOFTWARE.
 
 
 
 
 namespace CamelotEngine {
 namespace CamelotEngine {
-
-    //-----------------------------------------------------------------------
-    template<> HardwareBufferManager* Singleton<HardwareBufferManager>::ms_Singleton = 0;
-    HardwareBufferManager* HardwareBufferManager::getSingletonPtr(void)
-    {
-        return ms_Singleton;
-    }
-    HardwareBufferManager& HardwareBufferManager::getSingleton(void)
-    {  
-        assert( ms_Singleton );  return ( *ms_Singleton );  
-    }
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	HardwareBufferManager::HardwareBufferManager(HardwareBufferManagerBase* imp)
 	HardwareBufferManager::HardwareBufferManager(HardwareBufferManagerBase* imp)
 		: HardwareBufferManagerBase(), mImpl(imp)
 		: HardwareBufferManagerBase(), mImpl(imp)

+ 1 - 1
CamelotRenderer/Source/CmHardwareVertexBuffer.cpp

@@ -411,7 +411,7 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------------
     //-----------------------------------------------------------------------------
     VertexDeclaration* VertexDeclaration::clone(HardwareBufferManagerBase* mgr)
     VertexDeclaration* VertexDeclaration::clone(HardwareBufferManagerBase* mgr)
     {
     {
-		HardwareBufferManagerBase* pManager = mgr ? mgr : HardwareBufferManager::getSingletonPtr(); 
+		HardwareBufferManagerBase* pManager = mgr ? mgr : HardwareBufferManager::instancePtr(); 
         VertexDeclaration* ret = pManager->createVertexDeclaration();
         VertexDeclaration* ret = pManager->createVertexDeclaration();
 
 
 		VertexElementList::const_iterator i, iend;
 		VertexElementList::const_iterator i, iend;

+ 0 - 11
CamelotRenderer/Source/CmHighLevelGpuProgramManager.cpp

@@ -91,17 +91,6 @@ namespace CamelotEngine {
 		}
 		}
 
 
 	};
 	};
-	//-----------------------------------------------------------------------
-	template<> HighLevelGpuProgramManager* 
-	Singleton<HighLevelGpuProgramManager>::ms_Singleton = 0;
-    HighLevelGpuProgramManager* HighLevelGpuProgramManager::getSingletonPtr(void)
-    {
-        return ms_Singleton;
-    }
-    HighLevelGpuProgramManager& HighLevelGpuProgramManager::getSingleton(void)
-    {  
-        assert( ms_Singleton );  return ( *ms_Singleton );  
-    }
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	HighLevelGpuProgramManager::HighLevelGpuProgramManager()
 	HighLevelGpuProgramManager::HighLevelGpuProgramManager()
 	{
 	{

+ 3 - 3
CamelotRenderer/Source/CmVertexIndexData.cpp

@@ -41,7 +41,7 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
 	VertexData::VertexData(HardwareBufferManagerBase* mgr)
 	VertexData::VertexData(HardwareBufferManagerBase* mgr)
 	{
 	{
-		mMgr = mgr ? mgr : HardwareBufferManager::getSingletonPtr();
+		mMgr = mgr ? mgr : HardwareBufferManager::instancePtr();
 		vertexBufferBinding = mMgr->createVertexBufferBinding();
 		vertexBufferBinding = mMgr->createVertexBufferBinding();
 		vertexDeclaration = mMgr->createVertexDeclaration();
 		vertexDeclaration = mMgr->createVertexDeclaration();
 		mDeleteDclBinding = true;
 		mDeleteDclBinding = true;
@@ -53,7 +53,7 @@ namespace CamelotEngine {
 	VertexData::VertexData(VertexDeclaration* dcl, VertexBufferBinding* bind)
 	VertexData::VertexData(VertexDeclaration* dcl, VertexBufferBinding* bind)
 	{
 	{
 		// this is a fallback rather than actively used
 		// this is a fallback rather than actively used
-		mMgr = HardwareBufferManager::getSingletonPtr();
+		mMgr = HardwareBufferManager::instancePtr();
 		vertexDeclaration = dcl;
 		vertexDeclaration = dcl;
 		vertexBufferBinding = bind;
 		vertexBufferBinding = bind;
 		mDeleteDclBinding = false;
 		mDeleteDclBinding = false;
@@ -669,7 +669,7 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
 	IndexData* IndexData::clone(bool copyData, HardwareBufferManagerBase* mgr) const
 	IndexData* IndexData::clone(bool copyData, HardwareBufferManagerBase* mgr) const
 	{
 	{
-		HardwareBufferManagerBase* pManager = mgr ? mgr : HardwareBufferManager::getSingletonPtr();
+		HardwareBufferManagerBase* pManager = mgr ? mgr : HardwareBufferManager::instancePtr();
 		IndexData* dest = new IndexData();
 		IndexData* dest = new IndexData();
 		if (indexBuffer.get())
 		if (indexBuffer.get())
 		{
 		{

+ 0 - 1
CamelotUtility/CamelotUtility.vcxproj

@@ -79,7 +79,6 @@
     <ClInclude Include="Include\CmMathAsm.h" />
     <ClInclude Include="Include\CmMathAsm.h" />
     <ClInclude Include="Include\CmModule.h" />
     <ClInclude Include="Include\CmModule.h" />
     <ClInclude Include="Include\CmPixelUtil.h" />
     <ClInclude Include="Include\CmPixelUtil.h" />
-    <ClInclude Include="Include\CmSingleton.h" />
     <ClInclude Include="Include\CmString.h" />
     <ClInclude Include="Include\CmString.h" />
     <ClInclude Include="Include\CmThreadDefines.h" />
     <ClInclude Include="Include\CmThreadDefines.h" />
     <ClInclude Include="Include\CmTypes.h" />
     <ClInclude Include="Include\CmTypes.h" />

+ 0 - 3
CamelotUtility/CamelotUtility.vcxproj.filters

@@ -105,9 +105,6 @@
     <ClInclude Include="Include\CmDynLibManager.h">
     <ClInclude Include="Include\CmDynLibManager.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="Include\CmSingleton.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmModule.h">
     <ClInclude Include="Include\CmModule.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>

+ 17 - 0
CamelotUtility/Include/CmModule.h

@@ -29,6 +29,23 @@ namespace CamelotEngine
 			return *_instance;
 			return *_instance;
 		}
 		}
 
 
+		static T* instancePtr()
+		{
+			if(isShutDown)
+			{
+				CM_EXCEPT(InternalErrorException, 
+					"Trying to access a module but it hasn't been started up yet.");
+			}
+
+			if(isDestroyed)
+			{
+				CM_EXCEPT(InternalErrorException, 
+					"Trying to access a destroyed module.");
+			}
+
+			return _instance;
+		}
+
 		/**
 		/**
 		 * @brief	Initializes the module.
 		 * @brief	Initializes the module.
 		 *
 		 *

+ 0 - 102
CamelotUtility/Include/CmSingleton.h

@@ -1,102 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-/* Original version Copyright (C) Scott Bilas, 2000.
- * All rights reserved worldwide.
- *
- * This software is provided "as is" without express or implied
- * warranties. You may freely copy and compile this source into
- * applications you distribute provided that the copyright text
- * below is included in the resulting source code, for example:
- * "Portions Copyright (C) Scott Bilas, 2000"
- */
-#ifndef _SINGLETON_H__
-#define _SINGLETON_H__
-
-// Added by Steve Streeting for Ogre
-#include "CmPrerequisitesUtil.h"
-
-#if CM_COMPILER == CM_COMPILER_MSVC
-// Turn off warnings generated by this singleton implementation
-#   pragma warning (disable : 4311)
-#   pragma warning (disable : 4312)
-#endif
-
-#if defined ( CM_GCC_VISIBILITY )
-#   pragma GCC visibility push(default)
-#endif
-namespace CamelotEngine {
-	/** \addtogroup Core
-	*  @{
-	*/
-	/** \addtogroup General
-	*  @{
-	*/
-
-// End SJS additions
-    /** Template class for creating single-instance global classes.
-    */
-    template <typename T> class Singleton
-    {
-	private:
-		/** \brief Explicit private copy constructor. This is a forbidden operation.*/
-		Singleton(const Singleton<T> &);
-
-		/** \brief Private operator= . This is a forbidden operation. */
-		Singleton& operator=(const Singleton<T> &);
-    
-	protected:
-
-        static T* ms_Singleton;
-
-    public:
-        Singleton( void )
-        {
-            assert( !ms_Singleton );
-#if defined( _MSC_VER ) && _MSC_VER < 1200	 
-            int offset = (int)(T*)1 - (int)(Singleton <T>*)(T*)1;
-            ms_Singleton = (T*)((int)this + offset);
-#else
-	    ms_Singleton = static_cast< T* >( this );
-#endif
-        }
-        ~Singleton( void )
-            {  assert( ms_Singleton );  ms_Singleton = 0;  }
-        static T& getSingleton( void )
-		{	assert( ms_Singleton );  return ( *ms_Singleton ); }
-        static T* getSingletonPtr( void )
-		{ return ms_Singleton; }
-    };
-	/** @} */
-	/** @} */
-
-}
-#if defined ( CM_GCC_VISIBILITY )
-#   pragma GCC visibility pop
-#endif
-
-#endif

+ 2 - 2
Dependencies.txt

@@ -1,8 +1,8 @@
 Camelot relies on following 3rd party libraries:
 Camelot relies on following 3rd party libraries:
- - Boost 1.49
+ - Boost 1.49 (Later versions might work as well, but you need to test it on your own)
 
 
 
 
 Make sure to include:
 Make sure to include:
- - Library include file in /Dependencies/Include
+ - Library include files in /Dependencies/Include
  - Static library files in /Dependencies/lib/Debug and /Dependencies/lib/Release
  - Static library files in /Dependencies/lib/Debug and /Dependencies/lib/Release
  - Dynamic library files in /bin/Debug and /bin/Release (Possibly others if you define other configuration types)
  - Dynamic library files in /bin/Debug and /bin/Release (Possibly others if you define other configuration types)