Browse Source

Reverted previous revision and only removed certain render texture references

Marko Pintera 13 years ago
parent
commit
03b6ace987

+ 1 - 1
CamelotD3D9Renderer/Include/CmD3D9HardwarePixelBuffer.h

@@ -108,7 +108,7 @@ namespace CamelotEngine {
 		/// Mipmapping
 		/// Mipmapping
 		bool mDoMipmapGen;
 		bool mDoMipmapGen;
 		bool mHWMipmaps;
 		bool mHWMipmaps;
-
+		
 		// The owner texture if exists.
 		// The owner texture if exists.
 		D3D9Texture* mOwnerTexture;
 		D3D9Texture* mOwnerTexture;
 		
 		

+ 9 - 1
CamelotD3D9Renderer/Include/CmD3D9Texture.h

@@ -86,7 +86,9 @@ namespace CamelotEngine {
 			/// Volume texture
 			/// Volume texture
 			IDirect3DVolumeTexture9* pVolumeTex;
 			IDirect3DVolumeTexture9* pVolumeTex;
 			/// actual texture pointer
 			/// actual texture pointer
-			IDirect3DBaseTexture9* pBaseTex;		
+			IDirect3DBaseTexture9* pBaseTex;
+			/// Optional FSAA surface
+			IDirect3DSurface9* pFSAASurface;			
 		};
 		};
 		
 		
 		typedef map<IDirect3DDevice9*, TextureResources*>::type	DeviceToTextureResourcesMap;
 		typedef map<IDirect3DDevice9*, TextureResources*>::type	DeviceToTextureResourcesMap;
@@ -109,6 +111,10 @@ namespace CamelotEngine {
 
 
 		/// Is hardware gamma supported (read)?
 		/// Is hardware gamma supported (read)?
 		bool mHwGammaReadSupported;
 		bool mHwGammaReadSupported;
+		/// Is hardware gamma supported (write)?
+		bool mHwGammaWriteSupported;
+		D3DMULTISAMPLE_TYPE mFSAAType;
+		DWORD mFSAAQuality;
 
 
 		D3D9Texture();
 		D3D9Texture();
 
 
@@ -205,7 +211,9 @@ namespace CamelotEngine {
 
 
 		/// Override needed to deal with FSAA
 		/// Override needed to deal with FSAA
 		void swapBuffers(bool waitForVSync = true);
 		void swapBuffers(bool waitForVSync = true);
+
 	};
 	};
+
 }
 }
 
 
 #endif
 #endif

+ 7 - 2
CamelotD3D9Renderer/Source/CmD3D9HardwarePixelBuffer.cpp

@@ -94,7 +94,9 @@ namespace CamelotEngine
 		mSlicePitch = mHeight*mWidth;
 		mSlicePitch = mHeight*mWidth;
 		mSizeInBytes = PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);	
 		mSizeInBytes = PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);	
 	
 	
-		if (isNewBuffer)
+		// TODO PORT - My Texture doesn't inherit from Resource and doesn't have that method. Not sure why it needs to call it,
+		// but since we're not there's potential for trouble here.
+		if (isNewBuffer /*&& mOwnerTexture->isManuallyLoaded()*/)
 		{
 		{
 			DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
 			DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
 
 
@@ -320,7 +322,10 @@ namespace CamelotEngine
 	PixelData D3D9HardwarePixelBuffer::lockImpl(const Box lockBox,  LockOptions options)
 	PixelData D3D9HardwarePixelBuffer::lockImpl(const Box lockBox,  LockOptions options)
 	{	
 	{	
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
-	
+
+		// Check for misuse
+		if(mUsage & TU_RENDERTARGET)
+			CM_EXCEPT(RenderingAPIException, "DirectX does not allow locking of or directly writing to RenderTargets. Use blitFromMemory if you need the contents.");		
 		// Set locking flags according to options
 		// Set locking flags according to options
 		DWORD flags = 0;
 		DWORD flags = 0;
 		switch(options)
 		switch(options)

+ 2 - 0
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -2502,6 +2502,8 @@ namespace CamelotEngine
 
 
 			// Calculate usage
 			// Calculate usage
 			DWORD d3dusage = D3DUSAGE_QUERY_FILTER;
 			DWORD d3dusage = D3DUSAGE_QUERY_FILTER;
+			if (usage & TU_RENDERTARGET) 
+				d3dusage |= D3DUSAGE_RENDERTARGET;
 			if (usage & TU_DYNAMIC)
 			if (usage & TU_DYNAMIC)
 				d3dusage |= D3DUSAGE_DYNAMIC;
 				d3dusage |= D3DUSAGE_DYNAMIC;
 
 

+ 103 - 8
CamelotD3D9Renderer/Source/CmD3D9Texture.cpp

@@ -49,7 +49,10 @@ namespace CamelotEngine
         :Texture(),              
         :Texture(),              
         mD3DPool(D3DPOOL_MANAGED),
         mD3DPool(D3DPOOL_MANAGED),
 		mDynamicTextures(false),
 		mDynamicTextures(false),
-		mHwGammaReadSupported(false)
+		mHwGammaReadSupported(false),
+		mHwGammaWriteSupported(false),	
+		mFSAAType(D3DMULTISAMPLE_NONE),
+		mFSAAQuality(0)
 	{
 	{
        
        
 	}
 	}
@@ -218,6 +221,19 @@ namespace CamelotEngine
 
 
 		createInternalResources();
 		createInternalResources();
 
 
+		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
+
+		for (UINT32 i = 0; i < D3D9RenderSystem::getResourceCreationDeviceCount(); ++i)
+		{
+			IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getResourceCreationDevice(i);
+
+			if (mUsage & TU_RENDERTARGET)
+			{
+				createInternalResourcesImpl(d3d9Device);
+				return;
+			}	
+		}	
+
 		Resource::initialize_internal();
 		Resource::initialize_internal();
 	}
 	}
 	/****************************************************************************************/
 	/****************************************************************************************/
@@ -258,6 +274,7 @@ namespace CamelotEngine
 		textureResources->pCubeTex		= NULL;
 		textureResources->pCubeTex		= NULL;
 		textureResources->pVolumeTex	= NULL;
 		textureResources->pVolumeTex	= NULL;
 		textureResources->pBaseTex		= NULL;
 		textureResources->pBaseTex		= NULL;
+		textureResources->pFSAASurface	= NULL;
 
 
 		mMapDeviceToTextureResources[d3d9Device] = textureResources;
 		mMapDeviceToTextureResources[d3d9Device] = textureResources;
 
 
@@ -294,6 +311,7 @@ namespace CamelotEngine
 		SAFE_RELEASE(textureResources->pNormTex);
 		SAFE_RELEASE(textureResources->pNormTex);
 		SAFE_RELEASE(textureResources->pCubeTex);
 		SAFE_RELEASE(textureResources->pCubeTex);
 		SAFE_RELEASE(textureResources->pVolumeTex);
 		SAFE_RELEASE(textureResources->pVolumeTex);
+		SAFE_RELEASE(textureResources->pFSAASurface);
 	}
 	}
 	/****************************************************************************************/
 	/****************************************************************************************/
 	UINT32 D3D9Texture::calculateSize(void) const
 	UINT32 D3D9Texture::calculateSize(void) const
@@ -371,7 +389,7 @@ namespace CamelotEngine
 		hr = D3DXCheckTextureRequirements(d3d9Device, NULL, NULL, NULL, 0, &d3dPF, mD3DPool);
 		hr = D3DXCheckTextureRequirements(d3d9Device, NULL, NULL, NULL, 0, &d3dPF, mD3DPool);
 
 
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
-		DWORD usage = 0;
+		DWORD usage = (mUsage & TU_RENDERTARGET) ? D3DUSAGE_RENDERTARGET : 0;
 		UINT numMips = (mNumMipmaps == MIP_UNLIMITED) ? 
 		UINT numMips = (mNumMipmaps == MIP_UNLIMITED) ? 
 				D3DX_DEFAULT : mNumMipmaps + 1;
 				D3DX_DEFAULT : mNumMipmaps + 1;
 		// Check dynamic textures
 		// Check dynamic textures
@@ -391,6 +409,20 @@ namespace CamelotEngine
 		if (mHwGamma)
 		if (mHwGamma)
 		{
 		{
 			mHwGammaReadSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_TEXTURE, d3dPF, false);
 			mHwGammaReadSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_TEXTURE, d3dPF, false);
+			if (mUsage & TU_RENDERTARGET)
+				mHwGammaWriteSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_TEXTURE, d3dPF, true);
+		}
+		// Check FSAA level
+		if (mUsage & TU_RENDERTARGET)
+		{
+			D3D9RenderSystem* rsys = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystem::instancePtr());
+			rsys->determineFSAASettings(d3d9Device, mFSAA, mFSAAHint, d3dPF, false, 
+				&mFSAAType, &mFSAAQuality);
+		}
+		else
+		{
+			mFSAAType = D3DMULTISAMPLE_NONE;
+			mFSAAQuality = 0;
 		}
 		}
 
 
 		D3D9Device* device = D3D9RenderSystem::getDeviceManager()->getDeviceFromD3D9Device(d3d9Device);
 		D3D9Device* device = D3D9RenderSystem::getDeviceManager()->getDeviceFromD3D9Device(d3d9Device);
@@ -452,6 +484,22 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Can't get texture description: " + String(DXGetErrorDescription(hr)));
 			CM_EXCEPT(RenderingAPIException, "Can't get texture description: " + String(DXGetErrorDescription(hr)));
 		}
 		}
 
 
+		if (mFSAAType)
+		{
+			// create AA surface
+			HRESULT hr = d3d9Device->CreateRenderTarget(desc.Width, desc.Height, d3dPF, 
+				mFSAAType, 
+				mFSAAQuality,
+				FALSE, // not lockable
+				&textureResources->pFSAASurface, NULL);
+
+			if (FAILED(hr))
+			{
+				CM_EXCEPT(RenderingAPIException, "Unable to create AA render target: " + String(DXGetErrorDescription(hr)));
+			}
+
+		}
+
 		_setFinalAttributes(d3d9Device, textureResources, 
 		_setFinalAttributes(d3d9Device, textureResources, 
 			desc.Width, desc.Height, 1, D3D9Mappings::_getPF(desc.Format));
 			desc.Width, desc.Height, 1, D3D9Mappings::_getPF(desc.Format));
 	}
 	}
@@ -469,7 +517,7 @@ namespace CamelotEngine
 		hr = D3DXCheckCubeTextureRequirements(d3d9Device, NULL, NULL, 0, &d3dPF, mD3DPool);
 		hr = D3DXCheckCubeTextureRequirements(d3d9Device, NULL, NULL, 0, &d3dPF, mD3DPool);
 
 
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
-		DWORD usage = 0;
+		DWORD usage = (mUsage & TU_RENDERTARGET) ? D3DUSAGE_RENDERTARGET : 0;
 		UINT numMips = (mNumMipmaps == MIP_UNLIMITED) ? 
 		UINT numMips = (mNumMipmaps == MIP_UNLIMITED) ? 
 			D3DX_DEFAULT : mNumMipmaps + 1;
 			D3DX_DEFAULT : mNumMipmaps + 1;
 		// Check dynamic textures
 		// Check dynamic textures
@@ -489,6 +537,20 @@ namespace CamelotEngine
 		if (mHwGamma)
 		if (mHwGamma)
 		{
 		{
 			mHwGammaReadSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_CUBETEXTURE, d3dPF, false);
 			mHwGammaReadSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_CUBETEXTURE, d3dPF, false);
+			if (mUsage & TU_RENDERTARGET)
+				mHwGammaWriteSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_CUBETEXTURE, d3dPF, true);
+		}
+		// Check FSAA level
+		if (mUsage & TU_RENDERTARGET)
+		{
+			D3D9RenderSystem* rsys = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystem::instancePtr());
+			rsys->determineFSAASettings(d3d9Device, mFSAA, mFSAAHint, d3dPF, false, 
+				&mFSAAType, &mFSAAQuality);
+		}
+		else
+		{
+			mFSAAType = D3DMULTISAMPLE_NONE;
+			mFSAAQuality = 0;
 		}
 		}
 
 
 		D3D9Device* device = D3D9RenderSystem::getDeviceManager()->getDeviceFromD3D9Device(d3d9Device);
 		D3D9Device* device = D3D9RenderSystem::getDeviceManager()->getDeviceFromD3D9Device(d3d9Device);
@@ -548,6 +610,21 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Can't get texture description: " + String(DXGetErrorDescription(hr)));
 			CM_EXCEPT(RenderingAPIException, "Can't get texture description: " + String(DXGetErrorDescription(hr)));
 		}
 		}
 
 
+		if (mFSAAType)
+		{
+			// create AA surface
+			HRESULT hr = d3d9Device->CreateRenderTarget(desc.Width, desc.Height, d3dPF, 
+				mFSAAType, 
+				mFSAAQuality,
+				FALSE, // not lockable
+				&textureResources->pFSAASurface, NULL);
+
+			if (FAILED(hr))
+			{
+				CM_EXCEPT(RenderingAPIException, "Unable to create AA render target: " + String(DXGetErrorDescription(hr)));
+			}
+		}
+
 		_setFinalAttributes(d3d9Device, textureResources, 
 		_setFinalAttributes(d3d9Device, textureResources, 
 			desc.Width, desc.Height, 1, D3D9Mappings::_getPF(desc.Format));
 			desc.Width, desc.Height, 1, D3D9Mappings::_getPF(desc.Format));
 	}
 	}
@@ -557,6 +634,11 @@ namespace CamelotEngine
 		// we must have those defined here
 		// we must have those defined here
 		assert(mWidth > 0 && mHeight > 0 && mDepth>0);
 		assert(mWidth > 0 && mHeight > 0 && mDepth>0);
 
 
+		if (mUsage & TU_RENDERTARGET)
+		{
+			CM_EXCEPT(RenderingAPIException, "D3D9 Volume texture can not be created as render target !!");
+		}
+
 		// determine which D3D9 pixel format we'll use
 		// determine which D3D9 pixel format we'll use
 		HRESULT hr;
 		HRESULT hr;
 		D3DFORMAT d3dPF = _chooseD3DFormat(d3d9Device);
 		D3DFORMAT d3dPF = _chooseD3DFormat(d3d9Device);
@@ -564,7 +646,7 @@ namespace CamelotEngine
 		hr = D3DXCheckVolumeTextureRequirements(d3d9Device, NULL, NULL, NULL, NULL, 0, &d3dPF, mD3DPool);
 		hr = D3DXCheckVolumeTextureRequirements(d3d9Device, NULL, NULL, NULL, NULL, 0, &d3dPF, mD3DPool);
 
 
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
-		DWORD usage = 0;
+		DWORD usage = (mUsage & TU_RENDERTARGET) ? D3DUSAGE_RENDERTARGET : 0;
 		UINT numMips = (mNumMipmaps == MIP_UNLIMITED) ? 
 		UINT numMips = (mNumMipmaps == MIP_UNLIMITED) ? 
 			D3DX_DEFAULT : mNumMipmaps + 1;
 			D3DX_DEFAULT : mNumMipmaps + 1;
 		// Check dynamic textures
 		// Check dynamic textures
@@ -582,11 +664,16 @@ namespace CamelotEngine
 		}
 		}
 		// Check sRGB support
 		// Check sRGB support
 		if (mHwGamma)
 		if (mHwGamma)
+		{
 			mHwGammaReadSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_VOLUMETEXTURE, d3dPF, false);
 			mHwGammaReadSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_VOLUMETEXTURE, d3dPF, false);
+			if (mUsage & TU_RENDERTARGET)
+				mHwGammaWriteSupported = _canUseHardwareGammaCorrection(d3d9Device, usage, D3DRTYPE_VOLUMETEXTURE, d3dPF, true);
+		}
 
 
 		D3D9Device* device = D3D9RenderSystem::getDeviceManager()->getDeviceFromD3D9Device(d3d9Device);
 		D3D9Device* device = D3D9RenderSystem::getDeviceManager()->getDeviceFromD3D9Device(d3d9Device);
 		const D3DCAPS9& rkCurCaps = device->getD3D9DeviceCaps();			
 		const D3DCAPS9& rkCurCaps = device->getD3D9DeviceCaps();			
 
 
+
 		// check if mip map volume textures are supported
 		// check if mip map volume textures are supported
 		if (!(rkCurCaps.TextureCaps & D3DPTEXTURECAPS_MIPVOLUMEMAP))
 		if (!(rkCurCaps.TextureCaps & D3DPTEXTURECAPS_MIPVOLUMEMAP))
 		{
 		{
@@ -878,6 +965,10 @@ namespace CamelotEngine
 		{
 		{
 			bufusage = HardwareBuffer::HBU_STATIC;
 			bufusage = HardwareBuffer::HBU_STATIC;
 		}
 		}
+		if (mUsage & TU_RENDERTARGET)
+		{
+			bufusage |= TU_RENDERTARGET;
+		}
 		
 		
 		UINT32 surfaceCount  = static_cast<UINT32>((getNumFaces() * (mNumMipmaps + 1)));
 		UINT32 surfaceCount  = static_cast<UINT32>((getNumFaces() * (mNumMipmaps + 1)));
 		bool updateOldList = mSurfaceList.size() == surfaceCount;
 		bool updateOldList = mSurfaceList.size() == surfaceCount;
@@ -895,6 +986,8 @@ namespace CamelotEngine
 			}
 			}
 		}
 		}
 
 
+		
+
 		switch(getTextureType()) {
 		switch(getTextureType()) {
 		case TEX_TYPE_2D:
 		case TEX_TYPE_2D:
 		case TEX_TYPE_1D:
 		case TEX_TYPE_1D:
@@ -907,7 +1000,8 @@ namespace CamelotEngine
 
 
 				D3D9HardwarePixelBuffer* currPixelBuffer = GETLEVEL(0, mip);
 				D3D9HardwarePixelBuffer* currPixelBuffer = GETLEVEL(0, mip);
 								
 								
-				currPixelBuffer->bind(d3d9Device, surface, nullptr, false, 0, "PortNoName", textureResources->pBaseTex);
+				currPixelBuffer->bind(d3d9Device, surface, textureResources->pFSAASurface,
+					mHwGammaWriteSupported, mFSAA, "PortNoName", textureResources->pBaseTex);
 
 
 				// decrement reference count, the GetSurfaceLevel call increments this
 				// decrement reference count, the GetSurfaceLevel call increments this
 				// this is safe because the pixel buffer keeps a reference as well
 				// this is safe because the pixel buffer keeps a reference as well
@@ -927,7 +1021,8 @@ namespace CamelotEngine
 
 
 					D3D9HardwarePixelBuffer* currPixelBuffer = GETLEVEL(face, mip);
 					D3D9HardwarePixelBuffer* currPixelBuffer = GETLEVEL(face, mip);
 
 
-					currPixelBuffer->bind(d3d9Device, surface, nullptr, false, 0, "NoNamePort", textureResources->pBaseTex);
+					currPixelBuffer->bind(d3d9Device, surface, textureResources->pFSAASurface,
+						mHwGammaWriteSupported, mFSAA, "NoNamePort", textureResources->pBaseTex);
 
 
 					// decrement reference count, the GetSurfaceLevel call increments this
 					// decrement reference count, the GetSurfaceLevel call increments this
 					// this is safe because the pixel buffer keeps a reference as well
 					// this is safe because the pixel buffer keeps a reference as well
@@ -982,10 +1077,10 @@ namespace CamelotEngine
 	bool D3D9Texture::useDefaultPool()
 	bool D3D9Texture::useDefaultPool()
 	{
 	{
 		// Determine D3D pool to use
 		// Determine D3D pool to use
-		// Use managed unless user has asked for 
+		// Use managed unless we're a render target or user has asked for 
 		// a dynamic texture, and device supports D3DUSAGE_DYNAMIC (because default pool
 		// a dynamic texture, and device supports D3DUSAGE_DYNAMIC (because default pool
 		// resources without the dynamic flag are not lockable)
 		// resources without the dynamic flag are not lockable)
-		return ((mUsage & TU_DYNAMIC) && mDynamicTextures);
+		return (mUsage & TU_RENDERTARGET) || ((mUsage & TU_DYNAMIC) && mDynamicTextures);
 	}
 	}
 	
 	
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------

+ 5 - 0
CamelotD3D9Renderer/Source/CmD3D9TextureManager.cpp

@@ -63,6 +63,11 @@ namespace CamelotEngine
 		// Calculate usage
 		// Calculate usage
 		DWORD d3dusage = 0;
 		DWORD d3dusage = 0;
 		D3DPOOL pool = D3DPOOL_MANAGED;
 		D3DPOOL pool = D3DPOOL_MANAGED;
+		if (usage & TU_RENDERTARGET) 
+		{
+			d3dusage |= D3DUSAGE_RENDERTARGET;
+			pool = D3DPOOL_DEFAULT;
+		}
 		if (usage & TU_DYNAMIC)
 		if (usage & TU_DYNAMIC)
 		{
 		{
 			d3dusage |= D3DUSAGE_DYNAMIC;
 			d3dusage |= D3DUSAGE_DYNAMIC;

+ 2 - 0
CamelotGLRenderer/Include/CmGLTexture.h

@@ -74,6 +74,8 @@ namespace CamelotEngine {
 		*/
 		*/
 		void createSurfaceList();
 		void createSurfaceList();
 
 
+		void createRenderTexture();
+
 		/** Return hardware pixel buffer for a surface. This buffer can then
 		/** Return hardware pixel buffer for a surface. This buffer can then
 			be used to copy data from and to a particular level of the texture.
 			be used to copy data from and to a particular level of the texture.
 			@param face 	Face number, in case of a cubemap texture. Must be 0
 			@param face 	Face number, in case of a cubemap texture. Must be 0

+ 5 - 4
CamelotGLRenderer/Source/CmGLHardwarePixelBuffer.cpp

@@ -239,9 +239,7 @@ GLTextureBuffer::GLTextureBuffer(const String &baseName, GLenum target, GLuint i
         return;
         return;
 }
 }
 GLTextureBuffer::~GLTextureBuffer()
 GLTextureBuffer::~GLTextureBuffer()
-{
-
-}
+{ }
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void GLTextureBuffer::upload(const PixelData &data, const Box &dest)
 void GLTextureBuffer::upload(const PixelData &data, const Box &dest)
 {
 {
@@ -502,7 +500,10 @@ void GLTextureBuffer::blit(const HardwarePixelBufferPtr &src, const Box &srcBox,
     /// Destination texture must be 1D, 2D, 3D, or Cube
     /// Destination texture must be 1D, 2D, 3D, or Cube
     /// Source texture must be 1D, 2D or 3D
     /// Source texture must be 1D, 2D or 3D
 	
 	
-    if(GLEW_EXT_framebuffer_object && (srct->mTarget==GL_TEXTURE_1D||srct->mTarget==GL_TEXTURE_2D||srct->mTarget==GL_TEXTURE_3D))
+	// This does not sem to work for RTTs after the first update
+	// I have no idea why! For the moment, disable 
+    if(GLEW_EXT_framebuffer_object && (src->getUsage() & TU_RENDERTARGET) == 0 &&
+        (srct->mTarget==GL_TEXTURE_1D||srct->mTarget==GL_TEXTURE_2D||srct->mTarget==GL_TEXTURE_3D))
     {
     {
         blitFromTexture(srct, srcBox, dstBox);
         blitFromTexture(srct, srcBox, dstBox);
     }
     }

+ 17 - 1
CamelotGLRenderer/Source/CmGLTexture.cpp

@@ -74,6 +74,11 @@ namespace CamelotEngine {
 	{
 	{
 		createInternalResources();
 		createInternalResources();
 
 
+		if( mUsage & TU_RENDERTARGET )
+		{
+			createRenderTexture();
+		}
+
 		Resource::initialize_internal();
 		Resource::initialize_internal();
 	}
 	}
 
 
@@ -273,12 +278,22 @@ namespace CamelotEngine {
 		// Get final internal format
 		// Get final internal format
 		mFormat = getBuffer(0,0)->getFormat();
 		mFormat = getBuffer(0,0)->getFormat();
 	}
 	}
+	
+    void GLTexture::createRenderTexture(void)
+    {
+        // Create the GL texture
+		// This already does everything neccessary
+        createInternalResources();
+    }
 	//*************************************************************************
 	//*************************************************************************
+    
     void GLTexture::freeInternalResourcesImpl()
     void GLTexture::freeInternalResourcesImpl()
     {
     {
 		mSurfaceList.clear();
 		mSurfaceList.clear();
         glDeleteTextures( 1, &mTextureID );
         glDeleteTextures( 1, &mTextureID );
     }
     }
+
+	
 	//---------------------------------------------------------------------------------------------
 	//---------------------------------------------------------------------------------------------
 	void GLTexture::createSurfaceList()
 	void GLTexture::createSurfaceList()
 	{
 	{
@@ -289,7 +304,7 @@ namespace CamelotEngine {
 			for(UINT32 mip=0; mip<=getNumMipmaps(); mip++)
 			for(UINT32 mip=0; mip<=getNumMipmaps(); mip++)
 			{
 			{
                 GLHardwarePixelBuffer *buf = new GLTextureBuffer("", getGLTextureTarget_internal(), mTextureID, face, mip,
                 GLHardwarePixelBuffer *buf = new GLTextureBuffer("", getGLTextureTarget_internal(), mTextureID, face, mip,
-						static_cast<HardwareBuffer::Usage>(mUsage), false, mHwGamma, 0);
+						static_cast<HardwareBuffer::Usage>(mUsage), false, mHwGamma, mFSAA);
 				mSurfaceList.push_back(HardwarePixelBufferPtr(buf));
 				mSurfaceList.push_back(HardwarePixelBufferPtr(buf));
                 
                 
                 /// Check for error
                 /// Check for error
@@ -304,6 +319,7 @@ namespace CamelotEngine {
 			}
 			}
 		}
 		}
 	}
 	}
+	
 	//---------------------------------------------------------------------------------------------
 	//---------------------------------------------------------------------------------------------
 	HardwarePixelBufferPtr GLTexture::getBuffer(UINT32 face, UINT32 mipmap)
 	HardwarePixelBufferPtr GLTexture::getBuffer(UINT32 face, UINT32 mipmap)
 	{
 	{

+ 10 - 0
CamelotGLRenderer/Source/CmGLTextureManager.cpp

@@ -104,9 +104,19 @@ namespace CamelotEngine {
 		{
 		{
 			return PF_A8R8G8B8;
 			return PF_A8R8G8B8;
 		}
 		}
+        
+        // Check if this is a valid rendertarget format
+		if( usage & TU_RENDERTARGET )
+        {
+            /// Get closest supported alternative
+            /// If mFormat is supported it's returned
+            return GLRTTManager::instance().getSupportedAlternative(format);
+        }
 
 
 		// Supported
 		// Supported
 		return format;
 		return format;
+
+		
 	}
 	}
 	//-----------------------------------------------------------------------------
 	//-----------------------------------------------------------------------------
     bool GLTextureManager::isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage,
     bool GLTextureManager::isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage,

+ 18 - 18
CamelotRenderer/Include/CmDepthStencilBuffer.h

@@ -7,30 +7,30 @@ namespace CamelotEngine
 	class CM_EXPORT DepthStencilBuffer
 	class CM_EXPORT DepthStencilBuffer
 	{
 	{
 	public:
 	public:
-		DepthStencilBuffer(UINT32 bitDepth, UINT32 width, UINT32 height, UINT32 fsaa, const String &fsaaHint);
+		DepthStencilBuffer(UINT32 bitDepth, UINT32 width, UINT32 height, UINT32 fsaa, const String &fsaaHint);
 		virtual ~DepthStencilBuffer();
 		virtual ~DepthStencilBuffer();
 
 
-		UINT32 getBitDepth() const { return mBitDepth; }
-		UINT32 getWidth() const { return mWidth; }
-		UINT32 getHeight() const { return mHeight; }
-		UINT32 getFsaa() const { return mFsaa; }
+		UINT32 getBitDepth() const { return mBitDepth; }
+		UINT32 getWidth() const { return mWidth; }
+		UINT32 getHeight() const { return mHeight; }
+		UINT32 getFsaa() const { return mFsaa; }
 		const String& getFsaaHint() const { return mFsaaHint; }
 		const String& getFsaaHint() const { return mFsaaHint; }
 
 
-		/** Returns whether the specified RenderTarget is compatible with this DepthBuffer
-			That is, this DepthBuffer can be attached to that RenderTarget
-            @note
-                Most APIs impose the following restrictions:
-				Width & height must be equal or higher than the render target's
-				They must be of the same bit depth.
-				They need to have the same FSAA setting
-        */
+		/** Returns whether the specified RenderTarget is compatible with this DepthBuffer
+			That is, this DepthBuffer can be attached to that RenderTarget
+            @note
+                Most APIs impose the following restrictions:
+				Width & height must be equal or higher than the render target's
+				They must be of the same bit depth.
+				They need to have the same FSAA setting
+        */
 		virtual bool isCompatible(RenderTarget *renderTarget) const;
 		virtual bool isCompatible(RenderTarget *renderTarget) const;
 
 
-	protected:
-		UINT32						mBitDepth;
-		UINT32						mWidth;
-		UINT32						mHeight;
-		UINT32						mFsaa;
+	protected:
+		UINT32						mBitDepth;
+		UINT32						mWidth;
+		UINT32						mHeight;
+		UINT32						mFsaa;
 		String						mFsaaHint;
 		String						mFsaaHint;
 	};
 	};
 }
 }

+ 19 - 4
CamelotRenderer/Include/CmTexture.h

@@ -47,7 +47,9 @@ namespace CamelotEngine {
     {
     {
 		/// @copydoc HardwareBuffer::Usage
 		/// @copydoc HardwareBuffer::Usage
 		TU_STATIC = HardwareBuffer::HBU_STATIC, // Optimal setting if texture is read by the GPU often, and very rarely written by CPU
 		TU_STATIC = HardwareBuffer::HBU_STATIC, // Optimal setting if texture is read by the GPU often, and very rarely written by CPU
-		TU_DYNAMIC = HardwareBuffer::HBU_DYNAMIC // Optimal if the texture is updated by CPU often (e.g. every frame)
+		TU_DYNAMIC = HardwareBuffer::HBU_DYNAMIC, // Optimal if the texture is updated by CPU often (e.g. every frame)
+		TU_RENDERTARGET = 0x200, // Used for rendering by the GPU
+		TU_DEFAULT = TU_STATIC
     };
     };
 
 
     /** Enum identifying the texture type
     /** Enum identifying the texture type
@@ -99,6 +101,15 @@ namespace CamelotEngine {
 		*/
 		*/
 		virtual bool isHardwareGammaEnabled() const { return mHwGamma; }
 		virtual bool isHardwareGammaEnabled() const { return mHwGamma; }
 
 
+		/** Get the level of multisample AA to be used if this texture is a 
+		rendertarget.
+		*/
+		virtual UINT32 getFSAA() const { return mFSAA; }
+
+		/** Get the multisample AA hint if this texture is a rendertarget.
+		*/
+		virtual const String& getFSAAHint() const { return mFSAAHint; }
+
 		/** Returns the height of the texture.
 		/** Returns the height of the texture.
         */
         */
         virtual UINT32 getHeight(void) const { return mHeight; }
         virtual UINT32 getHeight(void) const { return mHeight; }
@@ -204,6 +215,8 @@ namespace CamelotEngine {
 
 
 		UINT32 mNumMipmaps;
 		UINT32 mNumMipmaps;
 		bool mHwGamma;
 		bool mHwGamma;
+		UINT32 mFSAA;
+		String mFSAAHint;
 
 
         TextureType mTextureType;
         TextureType mTextureType;
 		PixelFormat mFormat;
 		PixelFormat mFormat;
@@ -218,7 +231,7 @@ namespace CamelotEngine {
 		 * @note	Initialization is not done immediately, and is instead just scheduled on the render thread.
 		 * @note	Initialization is not done immediately, and is instead just scheduled on the render thread.
 		 */
 		 */
 		void initialize(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps, 
 		void initialize(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps, 
-			PixelFormat format, int usage, bool hwGamma);
+			PixelFormat format, int usage, bool hwGamma, UINT32 fsaa, const String& fsaaHint);
 		
 		
 		/**
 		/**
 		 * @brief	Performs GpuProgram initialization. Only callable from the render thread.
 		 * @brief	Performs GpuProgram initialization. Only callable from the render thread.
@@ -276,10 +289,12 @@ namespace CamelotEngine {
 		/************************************************************************/
 		/************************************************************************/
 	public:
 	public:
 		static TexturePtr create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
 		static TexturePtr create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
-			int num_mips, PixelFormat format, int usage = TU_STATIC, bool hwGammaCorrection = false);
+			int num_mips, PixelFormat format, int usage = TU_DEFAULT,
+			bool hwGammaCorrection = false, UINT32 fsaa = 0, const String& fsaaHint = StringUtil::BLANK);
 
 
 		static TexturePtr create(TextureType texType, UINT32 width, UINT32 height, int num_mips,
 		static TexturePtr create(TextureType texType, UINT32 width, UINT32 height, int num_mips,
-			PixelFormat format, int usage = TU_STATIC, bool hwGammaCorrection = false);
+			PixelFormat format, int usage = TU_DEFAULT,
+			bool hwGammaCorrection = false, UINT32 fsaa = 0, const String& fsaaHint = StringUtil::BLANK);
     };
     };
 	/** @} */
 	/** @} */
 }
 }

+ 53 - 15
CamelotRenderer/Include/CmTextureManager.h

@@ -70,6 +70,10 @@ namespace CamelotEngine {
         virtual ~TextureManager();
         virtual ~TextureManager();
 
 
 		/** Create a manual texture with specified width, height and depth (not loaded from a file).
 		/** Create a manual texture with specified width, height and depth (not loaded from a file).
+            @param
+                name The name to give the resulting texture
+            @param
+                group The name of the resource group to assign the texture to
             @param
             @param
                 texType The type of texture to load/create, defaults to normal 2D textures
                 texType The type of texture to load/create, defaults to normal 2D textures
             @param
             @param
@@ -84,20 +88,38 @@ namespace CamelotEngine {
                 the right to create a different format if the one you select is
                 the right to create a different format if the one you select is
                 not available in this context.
                 not available in this context.
 			@param 
 			@param 
-				usage The kind of usage this texture is intended for. You are
-				strongly advised to use TU_STATIC wherever possible, if you need to 
-				update regularly, consider TU_DYNAMIC.
+				usage The kind of usage this texture is intended for. It 
+				is a combination of TU_STATIC, TU_DYNAMIC, TU_WRITE_ONLY, 
+				TU_AUTOMIPMAP and TU_RENDERTARGET (see TextureUsage enum). You are
+            	strongly advised to use HBU_STATIC_WRITE_ONLY wherever possible, if you need to 
+            	update regularly, consider HBU_DYNAMIC_WRITE_ONLY.
+            @param
+                loader If you intend the contents of the manual texture to be 
+                regularly updated, to the extent that you don't need to recover 
+                the contents if the texture content is lost somehow, you can leave
+                this parameter as 0. However, if you intend to populate the
+                texture only once, then you should implement ManualResourceLoader
+                and pass a pointer to it in this parameter; this means that if the
+                manual texture ever needs to be reloaded, the ManualResourceLoader
+                will be called to do it.
 			@param hwGammaCorrection Pass 'true' to enable hardware gamma correction
 			@param hwGammaCorrection Pass 'true' to enable hardware gamma correction
 				(sRGB) on this texture. The hardware will convert from gamma space
 				(sRGB) on this texture. The hardware will convert from gamma space
 				to linear space when reading from this texture. Only applicable for 
 				to linear space when reading from this texture. Only applicable for 
 				8-bits per channel textures, will be ignored for other types. Has the advantage
 				8-bits per channel textures, will be ignored for other types. Has the advantage
 				over pre-applied gamma that the texture precision is maintained.
 				over pre-applied gamma that the texture precision is maintained.
+			@param fsaa The level of multisampling to use if this is a render target. Ignored
+				if usage does not include TU_RENDERTARGET or if the device does
+				not support it.
         */
         */
         TexturePtr create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
         TexturePtr create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
-			int num_mips, PixelFormat format, int usage = TU_STATIC,
-			bool hwGammaCorrection = false);
+			int num_mips, PixelFormat format, int usage = TU_DEFAULT,
+			bool hwGammaCorrection = false, UINT32 fsaa = 0, const String& fsaaHint = StringUtil::BLANK);
 			
 			
         /** Create a manual texture with a depth of 1 (not loaded from a file).
         /** Create a manual texture with a depth of 1 (not loaded from a file).
+            @param
+                name The name to give the resulting texture
+            @param
+                group The name of the resource group to assign the texture to
             @param
             @param
                 texType The type of texture to load/create, defaults to normal 2D textures
                 texType The type of texture to load/create, defaults to normal 2D textures
             @param
             @param
@@ -112,21 +134,35 @@ namespace CamelotEngine {
                 the right to create a different format if the one you select is
                 the right to create a different format if the one you select is
                 not available in this context.
                 not available in this context.
 			@param 
 			@param 
-				usage The kind of usage this texture is intended for. You are
-            	strongly advised to use TU_STATIC wherever possible, if you need to 
-            	update regularly, consider TU_DYNAMIC.
-			@param hwGammaCorrection Pass 'true' to enable hardware gamma correction
+				usage The kind of usage this texture is intended for. It 
+				is a combination of TU_STATIC, TU_DYNAMIC, TU_WRITE_ONLY, 
+				TU_AUTOMIPMAP and TU_RENDERTARGET (see TextureUsage enum). You are
+            	strongly advised to use HBU_STATIC_WRITE_ONLY wherever possible, if you need to 
+            	update regularly, consider HBU_DYNAMIC_WRITE_ONLY.
+            @param
+                loader If you intend the contents of the manual texture to be 
+                regularly updated, to the extent that you don't need to recover 
+                the contents if the texture content is lost somehow, you can leave
+                this parameter as 0. However, if you intend to populate the
+                texture only once, then you should implement ManualResourceLoader
+                and pass a pointer to it in this parameter; this means that if the
+                manual texture ever needs to be reloaded, the ManualResourceLoader
+                will be called to do it.
+			 @param hwGammaCorrection Pass 'true' to enable hardware gamma correction
 				 (sRGB) on this texture. The hardware will convert from gamma space
 				 (sRGB) on this texture. The hardware will convert from gamma space
 				 to linear space when reading from this texture. Only applicable for 
 				 to linear space when reading from this texture. Only applicable for 
 				 8-bits per channel textures, will be ignored for other types. Has the advantage
 				 8-bits per channel textures, will be ignored for other types. Has the advantage
 				 over pre-applied gamma that the texture precision is maintained.
 				 over pre-applied gamma that the texture precision is maintained.
+			@param fsaa The level of multisampling to use if this is a render target. Ignored
+				if usage does not include TU_RENDERTARGET or if the device does
+				not support it.
         */
         */
         TexturePtr create(TextureType texType, UINT32 width, UINT32 height, int num_mips,
         TexturePtr create(TextureType texType, UINT32 width, UINT32 height, int num_mips,
-            PixelFormat format, int usage = TU_STATIC,
-			bool hwGammaCorrection = false)
+            PixelFormat format, int usage = TU_DEFAULT,
+			bool hwGammaCorrection = false, UINT32 fsaa = 0, const String& fsaaHint = StringUtil::BLANK)
 		{
 		{
 			return create(texType, width, height, 1, 
 			return create(texType, width, height, 1, 
-				num_mips, format, usage, hwGammaCorrection);
+				num_mips, format, usage, hwGammaCorrection, fsaa, fsaaHint);
 		}
 		}
 
 
 		/**
 		/**
@@ -139,8 +175,9 @@ namespace CamelotEngine {
 		/**
 		/**
 		 * @brief	Creates a new depth/stencil buffer.
 		 * @brief	Creates a new depth/stencil buffer.
 		 */
 		 */
-		virtual DepthStencilBufferPtr createDepthStencilBuffer(UINT32 bitDepth, UINT32 width, UINT32 height, 
-			UINT32 fsaa, const String& fsaaHint) = 0;
+		virtual DepthStencilBufferPtr createDepthStencilBuffer(UINT32 bitDepth, UINT32 width, 
+			UINT32 height, UINT32 fsaa, const String& fsaaHint) = 0;
+
 
 
 		/** Returns whether this render system can natively support the precise texture 
 		/** Returns whether this render system can natively support the precise texture 
 			format requested with the given usage options.
 			format requested with the given usage options.
@@ -209,7 +246,8 @@ namespace CamelotEngine {
             check if in fallback mode.
             check if in fallback mode.
 		@returns true if the texture filtering is supported.
 		@returns true if the texture filtering is supported.
         */
         */
-        virtual bool isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage, bool preciseFormatOnly = false) = 0;
+        virtual bool isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage,
+            bool preciseFormatOnly = false) = 0;
 
 
     protected:
     protected:
 
 

+ 9 - 4
CamelotRenderer/Include/CmTextureRTTI.h

@@ -21,6 +21,8 @@ namespace CamelotEngine
 		CM_SETGET_MEMBER(mDepth, UINT32, Texture)
 		CM_SETGET_MEMBER(mDepth, UINT32, Texture)
 		CM_SETGET_MEMBER(mNumMipmaps, UINT32, Texture)
 		CM_SETGET_MEMBER(mNumMipmaps, UINT32, Texture)
 		CM_SETGET_MEMBER(mHwGamma, bool, Texture)
 		CM_SETGET_MEMBER(mHwGamma, bool, Texture)
+		CM_SETGET_MEMBER(mFSAA, UINT32, Texture)
+		CM_SETGET_MEMBER(mFSAAHint, String, Texture)
 		CM_SETGET_MEMBER(mTextureType, TextureType, Texture)
 		CM_SETGET_MEMBER(mTextureType, TextureType, Texture)
 		CM_SETGET_MEMBER(mFormat, PixelFormat, Texture)
 		CM_SETGET_MEMBER(mFormat, PixelFormat, Texture)
 		CM_SETGET_MEMBER(mUsage, INT32, Texture)
 		CM_SETGET_MEMBER(mUsage, INT32, Texture)
@@ -62,9 +64,11 @@ namespace CamelotEngine
 			CM_ADD_PLAINFIELD(mDepth, 4, TextureRTTI)
 			CM_ADD_PLAINFIELD(mDepth, 4, TextureRTTI)
 			CM_ADD_PLAINFIELD(mNumMipmaps, 5, TextureRTTI)
 			CM_ADD_PLAINFIELD(mNumMipmaps, 5, TextureRTTI)
 			CM_ADD_PLAINFIELD(mHwGamma, 6, TextureRTTI)
 			CM_ADD_PLAINFIELD(mHwGamma, 6, TextureRTTI)
-			CM_ADD_PLAINFIELD(mTextureType, 7, TextureRTTI)
-			CM_ADD_PLAINFIELD(mFormat, 8, TextureRTTI)
-			CM_ADD_PLAINFIELD(mUsage, 9, TextureRTTI)
+			CM_ADD_PLAINFIELD(mFSAA, 7, TextureRTTI)
+			CM_ADD_PLAINFIELD(mFSAAHint, 8, TextureRTTI)
+			CM_ADD_PLAINFIELD(mTextureType, 9, TextureRTTI)
+			CM_ADD_PLAINFIELD(mFormat, 10, TextureRTTI)
+			CM_ADD_PLAINFIELD(mUsage, 11, TextureRTTI)
 
 
 			addReflectablePtrArrayField("mPixelData", 12, &TextureRTTI::getPixelData, &TextureRTTI::getPixelDataArraySize, 
 			addReflectablePtrArrayField("mPixelData", 12, &TextureRTTI::getPixelData, &TextureRTTI::getPixelDataArraySize, 
 				&TextureRTTI::setPixelData, &TextureRTTI::setPixelDataArraySize);
 				&TextureRTTI::setPixelData, &TextureRTTI::setPixelDataArraySize);
@@ -87,7 +91,8 @@ namespace CamelotEngine
 			// A bit clumsy initializing with already set values, but I feel its better than complicating things and storing the values
 			// A bit clumsy initializing with already set values, but I feel its better than complicating things and storing the values
 			// in mRTTIData.
 			// in mRTTIData.
 			texture->initialize(texture->getTextureType(), texture->getWidth(), texture->getHeight(), texture->getDepth(), 
 			texture->initialize(texture->getTextureType(), texture->getWidth(), texture->getHeight(), texture->getDepth(), 
-				texture->getNumMipmaps(), texture->getFormat(), texture->getUsage(), texture->isHardwareGammaEnabled());
+				texture->getNumMipmaps(), texture->getFormat(), texture->getUsage(), texture->isHardwareGammaEnabled(), 
+				texture->getFSAA(), texture->getFSAAHint());
 
 
 			vector<PixelDataPtr>::type* pixelData = boost::any_cast<vector<PixelDataPtr>::type*>(texture->mRTTIData);
 			vector<PixelDataPtr>::type* pixelData = boost::any_cast<vector<PixelDataPtr>::type*>(texture->mRTTIData);
 			for(size_t i = 0; i < pixelData->size(); i++)
 			for(size_t i = 0; i < pixelData->size(); i++)

+ 1 - 0
CamelotRenderer/Source/CmRenderTexture.cpp

@@ -45,6 +45,7 @@ namespace CamelotEngine
     }
     }
     RenderTexture::~RenderTexture()
     RenderTexture::~RenderTexture()
     {
     {
+
     }
     }
 
 
 	void RenderTexture::copyContentsToMemory(const PixelData &dst, FrameBuffer buffer)
 	void RenderTexture::copyContentsToMemory(const PixelData &dst, FrameBuffer buffer)

+ 9 - 6
CamelotRenderer/Source/CmTexture.cpp

@@ -49,15 +49,16 @@ namespace CamelotEngine {
             mDepth(1),
             mDepth(1),
             mNumMipmaps(0),
             mNumMipmaps(0),
 			mHwGamma(false),
 			mHwGamma(false),
+			mFSAA(0),
             mTextureType(TEX_TYPE_2D),            
             mTextureType(TEX_TYPE_2D),            
             mFormat(PF_UNKNOWN),
             mFormat(PF_UNKNOWN),
-            mUsage(TU_STATIC)
+            mUsage(TU_DEFAULT)
     {
     {
         
         
     }
     }
 	//-------------------------------------------------------------------------
 	//-------------------------------------------------------------------------
 	void Texture::initialize(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps, 
 	void Texture::initialize(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps, 
-		PixelFormat format, int usage, bool hwGamma)
+		PixelFormat format, int usage, bool hwGamma, UINT32 fsaa, const String& fsaaHint)
 	{
 	{
 		mTextureType = textureType;
 		mTextureType = textureType;
 		mWidth = width;
 		mWidth = width;
@@ -67,6 +68,8 @@ namespace CamelotEngine {
 		mFormat = format;
 		mFormat = format;
 		mUsage = usage;
 		mUsage = usage;
 		mHwGamma = hwGamma;
 		mHwGamma = hwGamma;
+		mFSAA = fsaa;
+		mFSAAHint = fsaaHint;
 
 
 		mSize = getNumFaces() * PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);
 		mSize = getNumFaces() * PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);
 
 
@@ -249,17 +252,17 @@ namespace CamelotEngine {
 	/* 								STATICS	                      			*/
 	/* 								STATICS	                      			*/
 	/************************************************************************/
 	/************************************************************************/
 	TexturePtr Texture::create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
 	TexturePtr Texture::create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
-		int num_mips, PixelFormat format, int usage, bool hwGammaCorrection)
+		int num_mips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 fsaa, const String& fsaaHint)
 	{
 	{
 		return TextureManager::instance().create(texType, 
 		return TextureManager::instance().create(texType, 
-			width, height, depth, num_mips, format, usage, hwGammaCorrection);
+			width, height, depth, num_mips, format, usage, hwGammaCorrection, fsaa, fsaaHint);
 	}
 	}
 	
 	
 	TexturePtr Texture::create(TextureType texType, UINT32 width, UINT32 height, 
 	TexturePtr Texture::create(TextureType texType, UINT32 width, UINT32 height, 
-		int num_mips, PixelFormat format, int usage, bool hwGammaCorrection)
+		int num_mips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 fsaa, const String& fsaaHint)
 	{
 	{
 		return TextureManager::instance().create(texType, 
 		return TextureManager::instance().create(texType, 
-			width, height, num_mips, format, usage, hwGammaCorrection);
+			width, height, num_mips, format, usage, hwGammaCorrection, fsaa, fsaaHint);
 	}
 	}
 }
 }
 
 

+ 3 - 2
CamelotRenderer/Source/CmTextureManager.cpp

@@ -53,10 +53,11 @@ namespace CamelotEngine {
 	}
 	}
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     TexturePtr TextureManager::create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, int numMipmaps,
     TexturePtr TextureManager::create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, int numMipmaps,
-        PixelFormat format, int usage, bool hwGamma)
+        PixelFormat format, int usage, bool hwGamma, 
+		UINT32 fsaa, const String& fsaaHint)
     {
     {
         TexturePtr ret = TexturePtr(createImpl(), boost::bind(&TextureManager::destroy, this, _1));
         TexturePtr ret = TexturePtr(createImpl(), boost::bind(&TextureManager::destroy, this, _1));
-		ret->initialize(texType, width, height, depth, static_cast<size_t>(numMipmaps), format, usage, hwGamma);
+		ret->initialize(texType, width, height, depth, static_cast<size_t>(numMipmaps), format, usage, hwGamma, fsaa, fsaaHint);
 
 
 		return ret;
 		return ret;
     }
     }