Marko Pintera 13 年之前
父節點
當前提交
b70d7d4210

+ 2 - 3
CamelotRenderer/CamelotRenderer.vcxproj

@@ -137,8 +137,7 @@
     <ClInclude Include="CmHardwareVertexBuffer.h" />
     <ClInclude Include="CmHardwareVertexBuffer.h" />
     <ClInclude Include="CmHighLevelGpuProgram.h" />
     <ClInclude Include="CmHighLevelGpuProgram.h" />
     <ClInclude Include="CmHighLevelGpuProgramManager.h" />
     <ClInclude Include="CmHighLevelGpuProgramManager.h" />
-    <ClInclude Include="CmImageResampler.h" />
-    <ClInclude Include="CmPixelFormat.h" />
+    <ClInclude Include="CmPixelUtil.h" />
     <ClInclude Include="CmPrerequisites.h" />
     <ClInclude Include="CmPrerequisites.h" />
     <ClInclude Include="CmRenderOperation.h" />
     <ClInclude Include="CmRenderOperation.h" />
     <ClInclude Include="CmRenderSystem.h" />
     <ClInclude Include="CmRenderSystem.h" />
@@ -237,7 +236,7 @@
     <ClCompile Include="CmHardwareVertexBuffer.cpp" />
     <ClCompile Include="CmHardwareVertexBuffer.cpp" />
     <ClCompile Include="CmHighLevelGpuProgram.cpp" />
     <ClCompile Include="CmHighLevelGpuProgram.cpp" />
     <ClCompile Include="CmHighLevelGpuProgramManager.cpp" />
     <ClCompile Include="CmHighLevelGpuProgramManager.cpp" />
-    <ClCompile Include="CmPixelFormat.cpp" />
+    <ClCompile Include="CmPixelUtil.cpp" />
     <ClCompile Include="CmRenderSystem.cpp" />
     <ClCompile Include="CmRenderSystem.cpp" />
     <ClCompile Include="CmRenderSystemCapabilities.cpp" />
     <ClCompile Include="CmRenderSystemCapabilities.cpp" />
     <ClCompile Include="CmRenderTarget.cpp" />
     <ClCompile Include="CmRenderTarget.cpp" />

+ 4 - 7
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -356,13 +356,10 @@
     <ClInclude Include="CmCommon.h">
     <ClInclude Include="CmCommon.h">
       <Filter>Header Files\Utility</Filter>
       <Filter>Header Files\Utility</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="CmImageResampler.h">
-      <Filter>Header Files\Utility</Filter>
-    </ClInclude>
-    <ClInclude Include="CmPixelFormat.h">
+    <ClInclude Include="CmWindowEventUtilities.h">
       <Filter>Header Files\Utility</Filter>
       <Filter>Header Files\Utility</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="CmWindowEventUtilities.h">
+    <ClInclude Include="CmPixelUtil.h">
       <Filter>Header Files\Utility</Filter>
       <Filter>Header Files\Utility</Filter>
     </ClInclude>
     </ClInclude>
   </ItemGroup>
   </ItemGroup>
@@ -631,10 +628,10 @@
     <ClCompile Include="RenderSystemGL\Source\CmWin32Window.cpp">
     <ClCompile Include="RenderSystemGL\Source\CmWin32Window.cpp">
       <Filter>RenderSystemGL\Source Files</Filter>
       <Filter>RenderSystemGL\Source Files</Filter>
     </ClCompile>
     </ClCompile>
-    <ClCompile Include="CmPixelFormat.cpp">
+    <ClCompile Include="CmWindowEventUtilities.cpp">
       <Filter>Source Files\Utility</Filter>
       <Filter>Source Files\Utility</Filter>
     </ClCompile>
     </ClCompile>
-    <ClCompile Include="CmWindowEventUtilities.cpp">
+    <ClCompile Include="CmPixelUtil.cpp">
       <Filter>Source Files\Utility</Filter>
       <Filter>Source Files\Utility</Filter>
     </ClCompile>
     </ClCompile>
   </ItemGroup>
   </ItemGroup>

+ 2 - 2
CamelotRenderer/CmD3D9Device.cpp

@@ -1196,7 +1196,7 @@ namespace CamelotEngine
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9Device::copyContentsToMemory(D3D9RenderWindow* renderWindow, 
 	void D3D9Device::copyContentsToMemory(D3D9RenderWindow* renderWindow, 
-		const PixelBox &dst, RenderTarget::FrameBuffer buffer)
+		const PixelData &dst, RenderTarget::FrameBuffer buffer)
 	{
 	{
 		RenderWindowToResorucesIterator it = getRenderWindowIterator(renderWindow);
 		RenderWindowToResorucesIterator it = getRenderWindowIterator(renderWindow);
 		RenderWindowResources* resources = it->second;
 		RenderWindowResources* resources = it->second;
@@ -1423,7 +1423,7 @@ namespace CamelotEngine
 				"Unsupported format", "D3D9Device::copyContentsToMemory");
 				"Unsupported format", "D3D9Device::copyContentsToMemory");
 		}
 		}
 
 
-		PixelBox src(dst.getWidth(), dst.getHeight(), 1, format, lockedRect.pBits);
+		PixelData src(dst.getWidth(), dst.getHeight(), 1, format, lockedRect.pBits);
 		src.rowPitch = lockedRect.Pitch / PixelUtil::getNumElemBytes(format);
 		src.rowPitch = lockedRect.Pitch / PixelUtil::getNumElemBytes(format);
 		src.slicePitch = desc.Height * src.rowPitch;
 		src.slicePitch = desc.Height * src.rowPitch;
 
 

+ 1 - 1
CamelotRenderer/CmD3D9Device.h

@@ -76,7 +76,7 @@ namespace CamelotEngine {
 		UINT32					getLastPresentFrame		() const { return mLastPresentFrame; }
 		UINT32					getLastPresentFrame		() const { return mLastPresentFrame; }
 
 
 		void					setAdapterOrdinalIndex  (D3D9RenderWindow* renderWindow, UINT32 adapterOrdinalInGroupIndex);
 		void					setAdapterOrdinalIndex  (D3D9RenderWindow* renderWindow, UINT32 adapterOrdinalInGroupIndex);
-		void					copyContentsToMemory(D3D9RenderWindow* window, const PixelBox &dst, RenderTarget::FrameBuffer buffer);
+		void					copyContentsToMemory(D3D9RenderWindow* window, const PixelData &dst, RenderTarget::FrameBuffer buffer);
 		void					clearDeviceStreams		();
 		void					clearDeviceStreams		();
 	
 	
 	public:
 	public:

+ 17 - 17
CamelotRenderer/CmD3D9HardwarePixelBuffer.cpp

@@ -116,7 +116,7 @@ void D3D9HardwarePixelBuffer::bind(IDirect3DDevice9 *dev, IDirect3DSurface9 *sur
 				dev->TestCooperativeLevel() == D3D_OK)
 				dev->TestCooperativeLevel() == D3D_OK)
 			{
 			{
 				Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
 				Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
-				PixelBox dstBox(fullBufferBox, mFormat);
+				PixelData dstBox(fullBufferBox, mFormat);
 
 
 				dstBox.data = new char[getSizeInBytes()];
 				dstBox.data = new char[getSizeInBytes()];
 				blitToMemory(fullBufferBox, dstBox, it->second, it->first);
 				blitToMemory(fullBufferBox, dstBox, it->second, it->first);
@@ -174,7 +174,7 @@ void D3D9HardwarePixelBuffer::bind(IDirect3DDevice9 *dev, IDirect3DVolume9 *volu
 				dev->TestCooperativeLevel() == D3D_OK)
 				dev->TestCooperativeLevel() == D3D_OK)
 			{
 			{
 				Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
 				Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
-				PixelBox dstBox(fullBufferBox, mFormat);
+				PixelData dstBox(fullBufferBox, mFormat);
 
 
 				dstBox.data = new char[getSizeInBytes()];
 				dstBox.data = new char[getSizeInBytes()];
 				blitToMemory(fullBufferBox, dstBox, it->second, it->first);
 				blitToMemory(fullBufferBox, dstBox, it->second, it->first);
@@ -238,7 +238,7 @@ void D3D9HardwarePixelBuffer::unlockDeviceAccess()
 
 
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
 // Util functions to convert a D3D locked box to a pixel box
 // Util functions to convert a D3D locked box to a pixel box
-void fromD3DLock(PixelBox &rval, const D3DLOCKED_RECT &lrect)
+void fromD3DLock(PixelData &rval, const D3DLOCKED_RECT &lrect)
 {
 {
 	size_t bpp = PixelUtil::getNumElemBytes(rval.format);
 	size_t bpp = PixelUtil::getNumElemBytes(rval.format);
 	if (bpp != 0)
 	if (bpp != 0)
@@ -260,7 +260,7 @@ void fromD3DLock(PixelBox &rval, const D3DLOCKED_RECT &lrect)
 
 
 	rval.data = lrect.pBits;
 	rval.data = lrect.pBits;
 }
 }
-void fromD3DLock(PixelBox &rval, const D3DLOCKED_BOX &lbox)
+void fromD3DLock(PixelData &rval, const D3DLOCKED_BOX &lbox)
 {
 {
 	size_t bpp = PixelUtil::getNumElemBytes(rval.format);
 	size_t bpp = PixelUtil::getNumElemBytes(rval.format);
 	if (bpp != 0)
 	if (bpp != 0)
@@ -307,7 +307,7 @@ D3DBOX toD3DBOX(const Box &lockBox)
 	return pbox;
 	return pbox;
 }
 }
 // Convert Ogre pixelbox extent to D3D rectangle
 // Convert Ogre pixelbox extent to D3D rectangle
-RECT toD3DRECTExtent(const PixelBox &lockBox)
+RECT toD3DRECTExtent(const PixelData &lockBox)
 {
 {
 	RECT prect;
 	RECT prect;
 	assert(lockBox.getDepth() == 1);
 	assert(lockBox.getDepth() == 1);
@@ -318,7 +318,7 @@ RECT toD3DRECTExtent(const PixelBox &lockBox)
 	return prect;
 	return prect;
 }
 }
 // Convert Ogre pixelbox extent to D3D box
 // Convert Ogre pixelbox extent to D3D box
-D3DBOX toD3DBOXExtent(const PixelBox &lockBox)
+D3DBOX toD3DBOXExtent(const PixelData &lockBox)
 {
 {
 	D3DBOX pbox;
 	D3DBOX pbox;
 	pbox.Left = 0;
 	pbox.Left = 0;
@@ -330,7 +330,7 @@ D3DBOX toD3DBOXExtent(const PixelBox &lockBox)
 	return pbox;
 	return pbox;
 }
 }
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
-PixelBox 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
 
 
@@ -371,14 +371,14 @@ PixelBox D3D9HardwarePixelBuffer::lockImpl(const Box lockBox,  LockOptions optio
 }
 }
 
 
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
-CamelotEngine::PixelBox D3D9HardwarePixelBuffer::lockBuffer(BufferResources* bufferResources, 
+CamelotEngine::PixelData D3D9HardwarePixelBuffer::lockBuffer(BufferResources* bufferResources, 
 												   const Box &lockBox, 
 												   const Box &lockBox, 
 												   DWORD flags)
 												   DWORD flags)
 {
 {
 	// Set extents and format
 	// Set extents and format
 	// Note that we do not carry over the left/top/front here, since the returned
 	// Note that we do not carry over the left/top/front here, since the returned
 	// PixelBox will be re-based from the locking point onwards
 	// PixelBox will be re-based from the locking point onwards
-	PixelBox rval(lockBox.getWidth(), lockBox.getHeight(), lockBox.getDepth(), mFormat);
+	PixelData rval(lockBox.getWidth(), lockBox.getHeight(), lockBox.getDepth(), mFormat);
 
 
 
 
 	if (bufferResources->surface != NULL) 
 	if (bufferResources->surface != NULL) 
@@ -597,7 +597,7 @@ void D3D9HardwarePixelBuffer::blit(IDirect3DDevice9* d3d9Device,
 }
 }
 
 
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::blitFromMemory(const PixelBox &src, const Box &dstBox)
+void D3D9HardwarePixelBuffer::blitFromMemory(const PixelData &src, const Box &dstBox)
 {	
 {	
 	D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 	D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
 
@@ -613,17 +613,17 @@ void D3D9HardwarePixelBuffer::blitFromMemory(const PixelBox &src, const Box &dst
 }
 }
 
 
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::blitFromMemory(const PixelBox &src, const Box &dstBox, BufferResources* dstBufferResources)
+void D3D9HardwarePixelBuffer::blitFromMemory(const PixelData &src, const Box &dstBox, BufferResources* dstBufferResources)
 {
 {
 	// for scoped deletion of conversion buffer
 	// for scoped deletion of conversion buffer
 	void* data = NULL;
 	void* data = NULL;
-	PixelBox converted = src;
+	PixelData converted = src;
 
 
 	// convert to pixelbuffer's native format if necessary
 	// convert to pixelbuffer's native format if necessary
 	if (D3D9Mappings::_getPF(src.format) == D3DFMT_UNKNOWN)
 	if (D3D9Mappings::_getPF(src.format) == D3DFMT_UNKNOWN)
 	{
 	{
 		data = new void*[PixelUtil::getMemorySize(src.getWidth(), src.getHeight(), src.getDepth(), mFormat)];
 		data = new void*[PixelUtil::getMemorySize(src.getWidth(), src.getHeight(), src.getDepth(), mFormat)];
-		converted = PixelBox(src.getWidth(), src.getHeight(), src.getDepth(), mFormat, data);
+		converted = PixelData(src.getWidth(), src.getHeight(), src.getDepth(), mFormat, data);
 		PixelUtil::bulkPixelConversion(src, converted);
 		PixelUtil::bulkPixelConversion(src, converted);
 	}
 	}
 
 
@@ -707,7 +707,7 @@ void D3D9HardwarePixelBuffer::blitFromMemory(const PixelBox &src, const Box &dst
 }
 }
 
 
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelBox &dst)
+void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst)
 {
 {
 	D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 	D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
 
@@ -718,7 +718,7 @@ void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelBox &ds
 }
 }
 
 
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
-void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelBox &dst, 
+void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst, 
 										   BufferResources* srcBufferResources,
 										   BufferResources* srcBufferResources,
 										   IDirect3DDevice9* d3d9Device)
 										   IDirect3DDevice9* d3d9Device)
 {
 {
@@ -815,7 +815,7 @@ void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelBox &ds
 				"D3D9HardwarePixelBuffer::blitToMemory");
 				"D3D9HardwarePixelBuffer::blitToMemory");
 		}
 		}
 		// Copy it
 		// Copy it
-		PixelBox locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
+		PixelData locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
 		fromD3DLock(locked, lrect);
 		fromD3DLock(locked, lrect);
 		PixelUtil::bulkPixelConversion(locked, dst);
 		PixelUtil::bulkPixelConversion(locked, dst);
 		surface->UnlockRect();
 		surface->UnlockRect();
@@ -872,7 +872,7 @@ void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelBox &ds
 				"D3D9HardwarePixelBuffer::blitToMemory");
 				"D3D9HardwarePixelBuffer::blitToMemory");
 		}
 		}
 		// Copy it
 		// Copy it
-		PixelBox locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
+		PixelData locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
 		fromD3DLock(locked, lbox);
 		fromD3DLock(locked, lbox);
 		PixelUtil::bulkPixelConversion(locked, dst);
 		PixelUtil::bulkPixelConversion(locked, dst);
 		surface->UnlockBox();
 		surface->UnlockBox();

+ 6 - 6
CamelotRenderer/CmD3D9HardwarePixelBuffer.h

@@ -78,8 +78,8 @@ namespace CamelotEngine {
 		CM_STATIC_MUTEX(msDeviceAccessMutex)		
 		CM_STATIC_MUTEX(msDeviceAccessMutex)		
 	protected:
 	protected:
 		/// Lock a box
 		/// Lock a box
-		PixelBox lockImpl(const Box lockBox,  LockOptions options);
-		PixelBox lockBuffer(BufferResources* bufferResources, const Box &lockBox, DWORD flags);
+		PixelData lockImpl(const Box lockBox,  LockOptions options);
+		PixelData lockBuffer(BufferResources* bufferResources, const Box &lockBox, DWORD flags);
 
 
 		/// Unlock a box
 		/// Unlock a box
 		void unlockImpl(void);
 		void unlockImpl(void);
@@ -97,9 +97,9 @@ namespace CamelotEngine {
 				const Box &srcBox, const Box &dstBox, 
 				const Box &srcBox, const Box &dstBox, 
 				BufferResources* srcBufferResources, 
 				BufferResources* srcBufferResources, 
 				BufferResources* dstBufferResources);
 				BufferResources* dstBufferResources);
-		void blitFromMemory(const PixelBox &src, const Box &dstBox, BufferResources* dstBufferResources);
+		void blitFromMemory(const PixelData &src, const Box &dstBox, BufferResources* dstBufferResources);
 
 
-		void blitToMemory(const Box &srcBox, const PixelBox &dst, BufferResources* srcBufferResources, IDirect3DDevice9* d3d9Device);
+		void blitToMemory(const Box &srcBox, const PixelData &dst, BufferResources* srcBufferResources, IDirect3DDevice9* d3d9Device);
 			
 			
 	public:
 	public:
 		D3D9HardwarePixelBuffer(HardwareBuffer::Usage usage, 
 		D3D9HardwarePixelBuffer(HardwareBuffer::Usage usage, 
@@ -115,10 +115,10 @@ namespace CamelotEngine {
         void blit(const HardwarePixelBufferPtr &src, const Box &srcBox, const Box &dstBox);
         void blit(const HardwarePixelBufferPtr &src, const Box &srcBox, const Box &dstBox);
 		
 		
 		/// @copydoc HardwarePixelBuffer::blitFromMemory
 		/// @copydoc HardwarePixelBuffer::blitFromMemory
-		void blitFromMemory(const PixelBox &src, const Box &dstBox);
+		void blitFromMemory(const PixelData &src, const Box &dstBox);
 	
 	
 		/// @copydoc HardwarePixelBuffer::blitToMemory
 		/// @copydoc HardwarePixelBuffer::blitToMemory
-		void blitToMemory(const Box &srcBox, const PixelBox &dst);
+		void blitToMemory(const Box &srcBox, const PixelData &dst);
 		
 		
 		/// Internal function to update mipmaps on update of level 0
 		/// Internal function to update mipmaps on update of level 0
 		void _genMipmaps(IDirect3DBaseTexture9* mipTex);
 		void _genMipmaps(IDirect3DBaseTexture9* mipTex);

+ 1 - 1
CamelotRenderer/CmD3D9RenderWindow.cpp

@@ -737,7 +737,7 @@ namespace CamelotEngine
 		}
 		}
 	}
 	}
 
 
-	void D3D9RenderWindow::copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer)
+	void D3D9RenderWindow::copyContentsToMemory(const PixelData &dst, FrameBuffer buffer)
 	{
 	{
 		mDevice->copyContentsToMemory(this, dst, buffer);
 		mDevice->copyContentsToMemory(this, dst, buffer);
 	}
 	}

+ 1 - 1
CamelotRenderer/CmD3D9RenderWindow.h

@@ -67,7 +67,7 @@ namespace CamelotEngine
 		
 		
 		/** Overridden - see RenderTarget.
 		/** Overridden - see RenderTarget.
 		*/
 		*/
-		void				copyContentsToMemory	(const PixelBox &dst, FrameBuffer buffer);
+		void				copyContentsToMemory	(const PixelData &dst, FrameBuffer buffer);
 		bool				requiresTextureFlipping	() const { return false; }
 		bool				requiresTextureFlipping	() const { return false; }
 
 
 		// Method for dealing with resize / move & 3d library
 		// Method for dealing with resize / move & 3d library

+ 5 - 5
CamelotRenderer/CmHardwarePixelBuffer.cpp

@@ -57,12 +57,12 @@ namespace CamelotEngine
         assert(offset == 0 && length == mSizeInBytes && "Cannot lock memory region, most lock box or entire buffer");
         assert(offset == 0 && length == mSizeInBytes && "Cannot lock memory region, most lock box or entire buffer");
         
         
         Box myBox(0, 0, 0, mWidth, mHeight, mDepth);
         Box myBox(0, 0, 0, mWidth, mHeight, mDepth);
-        const PixelBox &rv = lock(myBox, options);
+        const PixelData &rv = lock(myBox, options);
         return rv.data;
         return rv.data;
     }
     }
     
     
     //-----------------------------------------------------------------------------    
     //-----------------------------------------------------------------------------    
-    const PixelBox& HardwarePixelBuffer::lock(const Box& lockBox, LockOptions options)
+    const PixelData& HardwarePixelBuffer::lock(const Box& lockBox, LockOptions options)
     {
     {
         if (mUseShadowBuffer)
         if (mUseShadowBuffer)
         {
         {
@@ -86,7 +86,7 @@ namespace CamelotEngine
     }
     }
     
     
     //-----------------------------------------------------------------------------    
     //-----------------------------------------------------------------------------    
-    const PixelBox& HardwarePixelBuffer::getCurrentLock() 
+    const PixelData& HardwarePixelBuffer::getCurrentLock() 
 	{ 
 	{ 
         assert(isLocked() && "Cannot get current lock: buffer not locked");
         assert(isLocked() && "Cannot get current lock: buffer not locked");
         
         
@@ -117,7 +117,7 @@ namespace CamelotEngine
                 "Source must not be the same object",
                 "Source must not be the same object",
                 "HardwarePixelBuffer::blit" ) ;
                 "HardwarePixelBuffer::blit" ) ;
 		}
 		}
-		const PixelBox &srclock = src->lock(srcBox, HBL_READ_ONLY);
+		const PixelData &srclock = src->lock(srcBox, HBL_READ_ONLY);
 
 
 		LockOptions method = HBL_NORMAL;
 		LockOptions method = HBL_NORMAL;
 		if(dstBox.left == 0 && dstBox.top == 0 && dstBox.front == 0 &&
 		if(dstBox.left == 0 && dstBox.top == 0 && dstBox.front == 0 &&
@@ -126,7 +126,7 @@ namespace CamelotEngine
 			// Entire buffer -- we can discard the previous contents
 			// Entire buffer -- we can discard the previous contents
 			method = HBL_DISCARD;
 			method = HBL_DISCARD;
 			
 			
-		const PixelBox &dstlock = lock(dstBox, method);
+		const PixelData &dstlock = lock(dstBox, method);
 		if(dstlock.getWidth() != srclock.getWidth() ||
 		if(dstlock.getWidth() != srclock.getWidth() ||
         	dstlock.getHeight() != srclock.getHeight() ||
         	dstlock.getHeight() != srclock.getHeight() ||
         	dstlock.getDepth() != srclock.getDepth())
         	dstlock.getDepth() != srclock.getDepth())

+ 9 - 9
CamelotRenderer/CmHardwarePixelBuffer.h

@@ -31,7 +31,7 @@ THE SOFTWARE.
 // Precompiler options
 // Precompiler options
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include "CmHardwareBuffer.h"
 #include "CmHardwareBuffer.h"
-#include "CmPixelFormat.h"
+#include "CmPixelUtil.h"
 
 
 namespace CamelotEngine {
 namespace CamelotEngine {
 
 
@@ -57,13 +57,13 @@ namespace CamelotEngine {
         // Internal format
         // Internal format
         PixelFormat mFormat;
         PixelFormat mFormat;
         // Currently locked region (local coords)
         // Currently locked region (local coords)
-        PixelBox mCurrentLock;
+        PixelData mCurrentLock;
 		// The current locked box of this surface (entire surface coords)
 		// The current locked box of this surface (entire surface coords)
 		Box mLockedBox;
 		Box mLockedBox;
 
 
         
         
         /// Internal implementation of lock(), must be overridden in subclasses
         /// Internal implementation of lock(), must be overridden in subclasses
-        virtual PixelBox lockImpl(const Box lockBox,  LockOptions options) = 0;
+        virtual PixelData lockImpl(const Box lockBox,  LockOptions options) = 0;
 
 
         /// Internal implementation of lock(), do not OVERRIDE or CALL this
         /// Internal implementation of lock(), do not OVERRIDE or CALL this
         /// for HardwarePixelBuffer implementations, but override the previous method
         /// for HardwarePixelBuffer implementations, but override the previous method
@@ -95,7 +95,7 @@ namespace CamelotEngine {
 		    @returns PixelBox containing the locked region, the pitches and
 		    @returns PixelBox containing the locked region, the pitches and
 		    	the pixel format
 		    	the pixel format
 		*/
 		*/
-		virtual const PixelBox& lock(const Box& lockBox, LockOptions options);
+		virtual const PixelData& lock(const Box& lockBox, LockOptions options);
 		/// @copydoc HardwareBuffer::lock
 		/// @copydoc HardwareBuffer::lock
         virtual void* lock(size_t offset, size_t length, LockOptions options);
         virtual void* lock(size_t offset, size_t length, LockOptions options);
 
 
@@ -103,7 +103,7 @@ namespace CamelotEngine {
 		    by lock(const Image::Box, LockOptions)
 		    by lock(const Image::Box, LockOptions)
 		    @returns PixelBox containing the locked region
 		    @returns PixelBox containing the locked region
 		*/        
 		*/        
-        const PixelBox& getCurrentLock();
+        const PixelData& getCurrentLock();
 		
 		
 		/// @copydoc HardwareBuffer::readData
 		/// @copydoc HardwareBuffer::readData
 		virtual void readData(size_t offset, size_t length, void* pDest);
 		virtual void readData(size_t offset, size_t length, void* pDest);
@@ -139,14 +139,14 @@ namespace CamelotEngine {
             but it is faster to pass the source image in the right dimensions.
             but it is faster to pass the source image in the right dimensions.
 			@note Only call this function when the buffer is unlocked. 
 			@note Only call this function when the buffer is unlocked. 
 		*/
 		*/
-		virtual void blitFromMemory(const PixelBox &src, const Box &dstBox) = 0;
+		virtual void blitFromMemory(const PixelData &src, const Box &dstBox) = 0;
 		
 		
 		/** Convenience function that blits a pixelbox from memory to the entire 
 		/** Convenience function that blits a pixelbox from memory to the entire 
 			buffer. The source image is scaled as needed.
 			buffer. The source image is scaled as needed.
 			@param src		PixelBox containing the source pixels and format in memory
 			@param src		PixelBox containing the source pixels and format in memory
 			@note Only call this function when the buffer is unlocked. 
 			@note Only call this function when the buffer is unlocked. 
 		*/
 		*/
-		void blitFromMemory(const PixelBox &src)
+		void blitFromMemory(const PixelData &src)
 		{
 		{
 			blitFromMemory(src, Box(0,0,0,mWidth,mHeight,mDepth));
 			blitFromMemory(src, Box(0,0,0,mWidth,mHeight,mDepth));
 		}
 		}
@@ -158,14 +158,14 @@ namespace CamelotEngine {
 		   	case scaling is done.
 		   	case scaling is done.
 			@note Only call this function when the buffer is unlocked. 
 			@note Only call this function when the buffer is unlocked. 
 		 */
 		 */
-		virtual void blitToMemory(const Box &srcBox, const PixelBox &dst) = 0;
+		virtual void blitToMemory(const Box &srcBox, const PixelData &dst) = 0;
 
 
 		/** Convience function that blits this entire buffer to a pixelbox.
 		/** Convience function that blits this entire buffer to a pixelbox.
 			The image is scaled as needed.
 			The image is scaled as needed.
 			@param src		PixelBox containing the source pixels and format in memory
 			@param src		PixelBox containing the source pixels and format in memory
 			@note Only call this function when the buffer is unlocked. 
 			@note Only call this function when the buffer is unlocked. 
 		*/
 		*/
-		void blitToMemory(const PixelBox &dst)
+		void blitToMemory(const PixelData &dst)
 		{
 		{
 			blitToMemory(Box(0,0,0,mWidth,mHeight,mDepth), dst);
 			blitToMemory(Box(0,0,0,mWidth,mHeight,mDepth), dst);
 		}
 		}

+ 0 - 349
CamelotRenderer/CmImageResampler.h

@@ -1,349 +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.
------------------------------------------------------------------------------
-*/
-#ifndef OGREIMAGERESAMPLER_H
-#define OGREIMAGERESAMPLER_H
-
-#include <algorithm>
-
-// this file is inlined into OgreImage.cpp!
-// do not include anywhere else.
-namespace CamelotEngine {
-	/** \addtogroup Core
-	*  @{
-	*/
-	/** \addtogroup Image
-	*  @{
-	*/
-
-// variable name hints:
-// sx_48 = 16/48-bit fixed-point x-position in source
-// stepx = difference between adjacent sx_48 values
-// sx1 = lower-bound integer x-position in source
-// sx2 = upper-bound integer x-position in source
-// sxf = fractional weight beween sx1 and sx2
-// x,y,z = location of output pixel in destination
-
-// nearest-neighbor resampler, does not convert formats.
-// templated on bytes-per-pixel to allow compiler optimizations, such
-// as simplifying memcpy() and replacing multiplies with bitshifts
-template<unsigned int elemsize> struct NearestResampler {
-	static void scale(const PixelBox& src, const PixelBox& dst) {
-		// assert(src.format == dst.format);
-
-		// srcdata stays at beginning, pdst is a moving pointer
-		UINT8* srcdata = (UINT8*)src.data;
-		UINT8* pdst = (UINT8*)dst.data;
-
-		// sx_48,sy_48,sz_48 represent current position in source
-		// using 16/48-bit fixed precision, incremented by steps
-		UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
-		UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
-		UINT64 stepz = ((UINT64)src.getDepth() << 48) / dst.getDepth();
-
-		// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
-		// for the center of the destination pixel, not the top-left corner
-		UINT64 sz_48 = (stepz >> 1) - 1;
-		for (size_t z = dst.front; z < dst.back; z++, sz_48 += stepz) {
-			size_t srczoff = (size_t)(sz_48 >> 48) * src.slicePitch;
-			
-			UINT64 sy_48 = (stepy >> 1) - 1;
-			for (size_t y = dst.top; y < dst.bottom; y++, sy_48 += stepy) {
-				size_t srcyoff = (size_t)(sy_48 >> 48) * src.rowPitch;
-			
-				UINT64 sx_48 = (stepx >> 1) - 1;
-				for (size_t x = dst.left; x < dst.right; x++, sx_48 += stepx) {
-					UINT8* psrc = srcdata +
-						elemsize*((size_t)(sx_48 >> 48) + srcyoff + srczoff);
-                    memcpy(pdst, psrc, elemsize);
-					pdst += elemsize;
-				}
-				pdst += elemsize*dst.getRowSkip();
-			}
-			pdst += elemsize*dst.getSliceSkip();
-		}
-	}
-};
-
-
-// default floating-point linear resampler, does format conversion
-struct LinearResampler {
-	static void scale(const PixelBox& src, const PixelBox& dst) {
-		size_t srcelemsize = PixelUtil::getNumElemBytes(src.format);
-		size_t dstelemsize = PixelUtil::getNumElemBytes(dst.format);
-
-		// srcdata stays at beginning, pdst is a moving pointer
-		UINT8* srcdata = (UINT8*)src.data;
-		UINT8* pdst = (UINT8*)dst.data;
-		
-		// sx_48,sy_48,sz_48 represent current position in source
-		// using 16/48-bit fixed precision, incremented by steps
-		UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
-		UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
-		UINT64 stepz = ((UINT64)src.getDepth() << 48) / dst.getDepth();
-		
-		// temp is 16/16 bit fixed precision, used to adjust a source
-		// coordinate (x, y, or z) backwards by half a pixel so that the
-		// integer bits represent the first sample (eg, sx1) and the
-		// fractional bits are the blend weight of the second sample
-		unsigned int temp;
-
-		// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
-		// for the center of the destination pixel, not the top-left corner
-		UINT64 sz_48 = (stepz >> 1) - 1;
-		for (size_t z = dst.front; z < dst.back; z++, sz_48+=stepz) {
-			temp = static_cast<unsigned int>(sz_48 >> 32);
-			temp = (temp > 0x8000)? temp - 0x8000 : 0;
-			size_t sz1 = temp >> 16;				 // src z, sample #1
-			size_t sz2 = std::min(sz1+1,src.getDepth()-1);// src z, sample #2
-			float szf = (temp & 0xFFFF) / 65536.f; // weight of sample #2
-
-			UINT64 sy_48 = (stepy >> 1) - 1;
-			for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
-				temp = static_cast<unsigned int>(sy_48 >> 32);
-				temp = (temp > 0x8000)? temp - 0x8000 : 0;
-				size_t sy1 = temp >> 16;					// src y #1
-				size_t sy2 = std::min(sy1+1,src.getHeight()-1);// src y #2
-				float syf = (temp & 0xFFFF) / 65536.f; // weight of #2
-				
-				UINT64 sx_48 = (stepx >> 1) - 1;
-				for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
-					temp = static_cast<unsigned int>(sx_48 >> 32);
-					temp = (temp > 0x8000)? temp - 0x8000 : 0;
-					size_t sx1 = temp >> 16;					// src x #1
-					size_t sx2 = std::min(sx1+1,src.getWidth()-1);// src x #2
-					float sxf = (temp & 0xFFFF) / 65536.f; // weight of #2
-				
-					Color x1y1z1, x2y1z1, x1y2z1, x2y2z1;
-					Color x1y1z2, x2y1z2, x1y2z2, x2y2z2;
-
-#define UNPACK(dst,x,y,z) PixelUtil::unpackColour(&dst, src.format, \
-	srcdata + srcelemsize*((x)+(y)*src.rowPitch+(z)*src.slicePitch))
-
-					UNPACK(x1y1z1,sx1,sy1,sz1); UNPACK(x2y1z1,sx2,sy1,sz1);
-					UNPACK(x1y2z1,sx1,sy2,sz1); UNPACK(x2y2z1,sx2,sy2,sz1);
-					UNPACK(x1y1z2,sx1,sy1,sz2); UNPACK(x2y1z2,sx2,sy1,sz2);
-					UNPACK(x1y2z2,sx1,sy2,sz2); UNPACK(x2y2z2,sx2,sy2,sz2);
-#undef UNPACK
-
-					Color accum =
-						x1y1z1 * ((1.0f - sxf)*(1.0f - syf)*(1.0f - szf)) +
-						x2y1z1 * (        sxf *(1.0f - syf)*(1.0f - szf)) +
-						x1y2z1 * ((1.0f - sxf)*        syf *(1.0f - szf)) +
-						x2y2z1 * (        sxf *        syf *(1.0f - szf)) +
-						x1y1z2 * ((1.0f - sxf)*(1.0f - syf)*        szf ) +
-						x2y1z2 * (        sxf *(1.0f - syf)*        szf ) +
-						x1y2z2 * ((1.0f - sxf)*        syf *        szf ) +
-						x2y2z2 * (        sxf *        syf *        szf );
-
-					PixelUtil::packColour(accum, dst.format, pdst);
-
-					pdst += dstelemsize;
-				}
-				pdst += dstelemsize*dst.getRowSkip();
-			}
-			pdst += dstelemsize*dst.getSliceSkip();
-		}
-	}
-};
-
-
-// float32 linear resampler, converts FLOAT32_RGB/FLOAT32_RGBA only.
-// avoids overhead of pixel unpack/repack function calls
-struct LinearResampler_Float32 {
-	static void scale(const PixelBox& src, const PixelBox& dst) {
-		size_t srcchannels = PixelUtil::getNumElemBytes(src.format) / sizeof(float);
-		size_t dstchannels = PixelUtil::getNumElemBytes(dst.format) / sizeof(float);
-		// assert(srcchannels == 3 || srcchannels == 4);
-		// assert(dstchannels == 3 || dstchannels == 4);
-
-		// srcdata stays at beginning, pdst is a moving pointer
-		float* srcdata = (float*)src.data;
-		float* pdst = (float*)dst.data;
-		
-		// sx_48,sy_48,sz_48 represent current position in source
-		// using 16/48-bit fixed precision, incremented by steps
-		UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
-		UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
-		UINT64 stepz = ((UINT64)src.getDepth() << 48) / dst.getDepth();
-		
-		// temp is 16/16 bit fixed precision, used to adjust a source
-		// coordinate (x, y, or z) backwards by half a pixel so that the
-		// integer bits represent the first sample (eg, sx1) and the
-		// fractional bits are the blend weight of the second sample
-		unsigned int temp;
-
-		// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
-		// for the center of the destination pixel, not the top-left corner
-		UINT64 sz_48 = (stepz >> 1) - 1;
-		for (size_t z = dst.front; z < dst.back; z++, sz_48+=stepz) {
-			temp = static_cast<unsigned int>(sz_48 >> 32);
-			temp = (temp > 0x8000)? temp - 0x8000 : 0;
-			size_t sz1 = temp >> 16;				 // src z, sample #1
-			size_t sz2 = std::min(sz1+1,src.getDepth()-1);// src z, sample #2
-			float szf = (temp & 0xFFFF) / 65536.f; // weight of sample #2
-
-			UINT64 sy_48 = (stepy >> 1) - 1;
-			for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
-				temp = static_cast<unsigned int>(sy_48 >> 32);
-				temp = (temp > 0x8000)? temp - 0x8000 : 0;
-				size_t sy1 = temp >> 16;					// src y #1
-				size_t sy2 = std::min(sy1+1,src.getHeight()-1);// src y #2
-				float syf = (temp & 0xFFFF) / 65536.f; // weight of #2
-				
-				UINT64 sx_48 = (stepx >> 1) - 1;
-				for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
-					temp = static_cast<unsigned int>(sx_48 >> 32);
-					temp = (temp > 0x8000)? temp - 0x8000 : 0;
-					size_t sx1 = temp >> 16;					// src x #1
-					size_t sx2 = std::min(sx1+1,src.getWidth()-1);// src x #2
-					float sxf = (temp & 0xFFFF) / 65536.f; // weight of #2
-					
-					// process R,G,B,A simultaneously for cache coherence?
-					float accum[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
-
-#define ACCUM3(x,y,z,factor) \
-	{ float f = factor; \
-	size_t off = (x+y*src.rowPitch+z*src.slicePitch)*srcchannels; \
-    accum[0]+=srcdata[off+0]*f; accum[1]+=srcdata[off+1]*f; \
-	accum[2]+=srcdata[off+2]*f; }
-
-#define ACCUM4(x,y,z,factor) \
-	{ float f = factor; \
-	size_t off = (x+y*src.rowPitch+z*src.slicePitch)*srcchannels; \
-    accum[0]+=srcdata[off+0]*f; accum[1]+=srcdata[off+1]*f; \
-	accum[2]+=srcdata[off+2]*f; accum[3]+=srcdata[off+3]*f; }
-
-					if (srcchannels == 3 || dstchannels == 3) {
-						// RGB, no alpha
-						ACCUM3(sx1,sy1,sz1,(1.0f-sxf)*(1.0f-syf)*(1.0f-szf));
-						ACCUM3(sx2,sy1,sz1,      sxf *(1.0f-syf)*(1.0f-szf));
-						ACCUM3(sx1,sy2,sz1,(1.0f-sxf)*      syf *(1.0f-szf));
-						ACCUM3(sx2,sy2,sz1,      sxf *      syf *(1.0f-szf));
-						ACCUM3(sx1,sy1,sz2,(1.0f-sxf)*(1.0f-syf)*      szf );
-						ACCUM3(sx2,sy1,sz2,      sxf *(1.0f-syf)*      szf );
-						ACCUM3(sx1,sy2,sz2,(1.0f-sxf)*      syf *      szf );
-						ACCUM3(sx2,sy2,sz2,      sxf *      syf *      szf );
-						accum[3] = 1.0f;
-					} else {
-						// RGBA
-						ACCUM4(sx1,sy1,sz1,(1.0f-sxf)*(1.0f-syf)*(1.0f-szf));
-						ACCUM4(sx2,sy1,sz1,      sxf *(1.0f-syf)*(1.0f-szf));
-						ACCUM4(sx1,sy2,sz1,(1.0f-sxf)*      syf *(1.0f-szf));
-						ACCUM4(sx2,sy2,sz1,      sxf *      syf *(1.0f-szf));
-						ACCUM4(sx1,sy1,sz2,(1.0f-sxf)*(1.0f-syf)*      szf );
-						ACCUM4(sx2,sy1,sz2,      sxf *(1.0f-syf)*      szf );
-						ACCUM4(sx1,sy2,sz2,(1.0f-sxf)*      syf *      szf );
-						ACCUM4(sx2,sy2,sz2,      sxf *      syf *      szf );
-					}
-
-					memcpy(pdst, accum, sizeof(float)*dstchannels);
-
-#undef ACCUM3
-#undef ACCUM4
-
-					pdst += dstchannels;
-				}
-				pdst += dstchannels*dst.getRowSkip();
-			}
-			pdst += dstchannels*dst.getSliceSkip();
-		}
-	}
-};
-
-
-
-// byte linear resampler, does not do any format conversions.
-// only handles pixel formats that use 1 byte per color channel.
-// 2D only; punts 3D pixelboxes to default LinearResampler (slow).
-// templated on bytes-per-pixel to allow compiler optimizations, such
-// as unrolling loops and replacing multiplies with bitshifts
-template<unsigned int channels> struct LinearResampler_Byte {
-	static void scale(const PixelBox& src, const PixelBox& dst) {
-		// assert(src.format == dst.format);
-
-		// only optimized for 2D
-		if (src.getDepth() > 1 || dst.getDepth() > 1) {
-			LinearResampler::scale(src, dst);
-			return;
-		}
-
-		// srcdata stays at beginning of slice, pdst is a moving pointer
-		UINT8* srcdata = (UINT8*)src.data;
-		UINT8* pdst = (UINT8*)dst.data;
-
-		// sx_48,sy_48 represent current position in source
-		// using 16/48-bit fixed precision, incremented by steps
-		UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
-		UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
-		
-		// bottom 28 bits of temp are 16/12 bit fixed precision, used to
-		// adjust a source coordinate backwards by half a pixel so that the
-		// integer bits represent the first sample (eg, sx1) and the
-		// fractional bits are the blend weight of the second sample
-		unsigned int temp;
-		
-		UINT64 sy_48 = (stepy >> 1) - 1;
-		for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
-			temp = static_cast<unsigned int>(sy_48 >> 36);
-			temp = (temp > 0x800)? temp - 0x800: 0;
-			unsigned int syf = temp & 0xFFF;
-			size_t sy1 = temp >> 12;
-			size_t sy2 = std::min(sy1+1, src.bottom-src.top-1);
-			size_t syoff1 = sy1 * src.rowPitch;
-			size_t syoff2 = sy2 * src.rowPitch;
-
-			UINT64 sx_48 = (stepx >> 1) - 1;
-			for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
-				temp = static_cast<unsigned int>(sx_48 >> 36);
-				temp = (temp > 0x800)? temp - 0x800 : 0;
-				unsigned int sxf = temp & 0xFFF;
-				size_t sx1 = temp >> 12;
-				size_t sx2 = std::min(sx1+1, src.right-src.left-1);
-
-				unsigned int sxfsyf = sxf*syf;
-				for (unsigned int k = 0; k < channels; k++) {
-					unsigned int accum =
-						srcdata[(sx1 + syoff1)*channels+k]*(0x1000000-(sxf<<12)-(syf<<12)+sxfsyf) +
-						srcdata[(sx2 + syoff1)*channels+k]*((sxf<<12)-sxfsyf) +
-						srcdata[(sx1 + syoff2)*channels+k]*((syf<<12)-sxfsyf) +
-						srcdata[(sx2 + syoff2)*channels+k]*sxfsyf;
-					// accum is computed using 8/24-bit fixed-point math
-					// (maximum is 0xFF000000; rounding will not cause overflow)
-					*pdst++ = static_cast<UINT8>((accum + 0x800000) >> 24);
-				}
-			}
-			pdst += channels*dst.getRowSkip();
-		}
-	}
-};
-/** @} */
-/** @} */
-
-}
-
-#endif

+ 321 - 15
CamelotRenderer/CmPixelFormat.cpp → CamelotRenderer/CmPixelUtil.cpp

@@ -26,15 +26,321 @@ THE SOFTWARE.
 -----------------------------------------------------------------------------
 -----------------------------------------------------------------------------
 */
 */
 
 
-#include "CmPixelFormat.h"
+#include "CmPixelUtil.h"
 #include "CmBitwise.h"
 #include "CmBitwise.h"
 #include "CmColor.h"
 #include "CmColor.h"
-#include "CmImageResampler.h"
 #include "CmException.h"
 #include "CmException.h"
 
 
 
 
 namespace CamelotEngine {
 namespace CamelotEngine {
 
 
+	//-----------------------------------------------------------------------
+    /**
+    * Resamplers
+    */
+
+	// variable name hints:
+	// sx_48 = 16/48-bit fixed-point x-position in source
+	// stepx = difference between adjacent sx_48 values
+	// sx1 = lower-bound integer x-position in source
+	// sx2 = upper-bound integer x-position in source
+	// sxf = fractional weight beween sx1 and sx2
+	// x,y,z = location of output pixel in destination
+
+	// nearest-neighbor resampler, does not convert formats.
+	// templated on bytes-per-pixel to allow compiler optimizations, such
+	// as simplifying memcpy() and replacing multiplies with bitshifts
+	template<unsigned int elemsize> struct NearestResampler {
+		static void scale(const PixelData& src, const PixelData& dst) {
+			// assert(src.format == dst.format);
+
+			// srcdata stays at beginning, pdst is a moving pointer
+			UINT8* srcdata = (UINT8*)src.data;
+			UINT8* pdst = (UINT8*)dst.data;
+
+			// sx_48,sy_48,sz_48 represent current position in source
+			// using 16/48-bit fixed precision, incremented by steps
+			UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
+			UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
+			UINT64 stepz = ((UINT64)src.getDepth() << 48) / dst.getDepth();
+
+			// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
+			// for the center of the destination pixel, not the top-left corner
+			UINT64 sz_48 = (stepz >> 1) - 1;
+			for (size_t z = dst.front; z < dst.back; z++, sz_48 += stepz) {
+				size_t srczoff = (size_t)(sz_48 >> 48) * src.slicePitch;
+
+				UINT64 sy_48 = (stepy >> 1) - 1;
+				for (size_t y = dst.top; y < dst.bottom; y++, sy_48 += stepy) {
+					size_t srcyoff = (size_t)(sy_48 >> 48) * src.rowPitch;
+
+					UINT64 sx_48 = (stepx >> 1) - 1;
+					for (size_t x = dst.left; x < dst.right; x++, sx_48 += stepx) {
+						UINT8* psrc = srcdata +
+							elemsize*((size_t)(sx_48 >> 48) + srcyoff + srczoff);
+						memcpy(pdst, psrc, elemsize);
+						pdst += elemsize;
+					}
+					pdst += elemsize*dst.getRowSkip();
+				}
+				pdst += elemsize*dst.getSliceSkip();
+			}
+		}
+	};
+
+
+	// default floating-point linear resampler, does format conversion
+	struct LinearResampler {
+		static void scale(const PixelData& src, const PixelData& dst) {
+			size_t srcelemsize = PixelUtil::getNumElemBytes(src.format);
+			size_t dstelemsize = PixelUtil::getNumElemBytes(dst.format);
+
+			// srcdata stays at beginning, pdst is a moving pointer
+			UINT8* srcdata = (UINT8*)src.data;
+			UINT8* pdst = (UINT8*)dst.data;
+
+			// sx_48,sy_48,sz_48 represent current position in source
+			// using 16/48-bit fixed precision, incremented by steps
+			UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
+			UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
+			UINT64 stepz = ((UINT64)src.getDepth() << 48) / dst.getDepth();
+
+			// temp is 16/16 bit fixed precision, used to adjust a source
+			// coordinate (x, y, or z) backwards by half a pixel so that the
+			// integer bits represent the first sample (eg, sx1) and the
+			// fractional bits are the blend weight of the second sample
+			unsigned int temp;
+
+			// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
+			// for the center of the destination pixel, not the top-left corner
+			UINT64 sz_48 = (stepz >> 1) - 1;
+			for (size_t z = dst.front; z < dst.back; z++, sz_48+=stepz) {
+				temp = static_cast<unsigned int>(sz_48 >> 32);
+				temp = (temp > 0x8000)? temp - 0x8000 : 0;
+				size_t sz1 = temp >> 16;				 // src z, sample #1
+				size_t sz2 = std::min(sz1+1,src.getDepth()-1);// src z, sample #2
+				float szf = (temp & 0xFFFF) / 65536.f; // weight of sample #2
+
+				UINT64 sy_48 = (stepy >> 1) - 1;
+				for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
+					temp = static_cast<unsigned int>(sy_48 >> 32);
+					temp = (temp > 0x8000)? temp - 0x8000 : 0;
+					size_t sy1 = temp >> 16;					// src y #1
+					size_t sy2 = std::min(sy1+1,src.getHeight()-1);// src y #2
+					float syf = (temp & 0xFFFF) / 65536.f; // weight of #2
+
+					UINT64 sx_48 = (stepx >> 1) - 1;
+					for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
+						temp = static_cast<unsigned int>(sx_48 >> 32);
+						temp = (temp > 0x8000)? temp - 0x8000 : 0;
+						size_t sx1 = temp >> 16;					// src x #1
+						size_t sx2 = std::min(sx1+1,src.getWidth()-1);// src x #2
+						float sxf = (temp & 0xFFFF) / 65536.f; // weight of #2
+
+						Color x1y1z1, x2y1z1, x1y2z1, x2y2z1;
+						Color x1y1z2, x2y1z2, x1y2z2, x2y2z2;
+
+#define UNPACK(dst,x,y,z) PixelUtil::unpackColour(&dst, src.format, \
+	srcdata + srcelemsize*((x)+(y)*src.rowPitch+(z)*src.slicePitch))
+
+						UNPACK(x1y1z1,sx1,sy1,sz1); UNPACK(x2y1z1,sx2,sy1,sz1);
+						UNPACK(x1y2z1,sx1,sy2,sz1); UNPACK(x2y2z1,sx2,sy2,sz1);
+						UNPACK(x1y1z2,sx1,sy1,sz2); UNPACK(x2y1z2,sx2,sy1,sz2);
+						UNPACK(x1y2z2,sx1,sy2,sz2); UNPACK(x2y2z2,sx2,sy2,sz2);
+#undef UNPACK
+
+						Color accum =
+							x1y1z1 * ((1.0f - sxf)*(1.0f - syf)*(1.0f - szf)) +
+							x2y1z1 * (        sxf *(1.0f - syf)*(1.0f - szf)) +
+							x1y2z1 * ((1.0f - sxf)*        syf *(1.0f - szf)) +
+							x2y2z1 * (        sxf *        syf *(1.0f - szf)) +
+							x1y1z2 * ((1.0f - sxf)*(1.0f - syf)*        szf ) +
+							x2y1z2 * (        sxf *(1.0f - syf)*        szf ) +
+							x1y2z2 * ((1.0f - sxf)*        syf *        szf ) +
+							x2y2z2 * (        sxf *        syf *        szf );
+
+						PixelUtil::packColour(accum, dst.format, pdst);
+
+						pdst += dstelemsize;
+					}
+					pdst += dstelemsize*dst.getRowSkip();
+				}
+				pdst += dstelemsize*dst.getSliceSkip();
+			}
+		}
+	};
+
+
+	// float32 linear resampler, converts FLOAT32_RGB/FLOAT32_RGBA only.
+	// avoids overhead of pixel unpack/repack function calls
+	struct LinearResampler_Float32 {
+		static void scale(const PixelData& src, const PixelData& dst) {
+			size_t srcchannels = PixelUtil::getNumElemBytes(src.format) / sizeof(float);
+			size_t dstchannels = PixelUtil::getNumElemBytes(dst.format) / sizeof(float);
+			// assert(srcchannels == 3 || srcchannels == 4);
+			// assert(dstchannels == 3 || dstchannels == 4);
+
+			// srcdata stays at beginning, pdst is a moving pointer
+			float* srcdata = (float*)src.data;
+			float* pdst = (float*)dst.data;
+
+			// sx_48,sy_48,sz_48 represent current position in source
+			// using 16/48-bit fixed precision, incremented by steps
+			UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
+			UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
+			UINT64 stepz = ((UINT64)src.getDepth() << 48) / dst.getDepth();
+
+			// temp is 16/16 bit fixed precision, used to adjust a source
+			// coordinate (x, y, or z) backwards by half a pixel so that the
+			// integer bits represent the first sample (eg, sx1) and the
+			// fractional bits are the blend weight of the second sample
+			unsigned int temp;
+
+			// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
+			// for the center of the destination pixel, not the top-left corner
+			UINT64 sz_48 = (stepz >> 1) - 1;
+			for (size_t z = dst.front; z < dst.back; z++, sz_48+=stepz) {
+				temp = static_cast<unsigned int>(sz_48 >> 32);
+				temp = (temp > 0x8000)? temp - 0x8000 : 0;
+				size_t sz1 = temp >> 16;				 // src z, sample #1
+				size_t sz2 = std::min(sz1+1,src.getDepth()-1);// src z, sample #2
+				float szf = (temp & 0xFFFF) / 65536.f; // weight of sample #2
+
+				UINT64 sy_48 = (stepy >> 1) - 1;
+				for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
+					temp = static_cast<unsigned int>(sy_48 >> 32);
+					temp = (temp > 0x8000)? temp - 0x8000 : 0;
+					size_t sy1 = temp >> 16;					// src y #1
+					size_t sy2 = std::min(sy1+1,src.getHeight()-1);// src y #2
+					float syf = (temp & 0xFFFF) / 65536.f; // weight of #2
+
+					UINT64 sx_48 = (stepx >> 1) - 1;
+					for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
+						temp = static_cast<unsigned int>(sx_48 >> 32);
+						temp = (temp > 0x8000)? temp - 0x8000 : 0;
+						size_t sx1 = temp >> 16;					// src x #1
+						size_t sx2 = std::min(sx1+1,src.getWidth()-1);// src x #2
+						float sxf = (temp & 0xFFFF) / 65536.f; // weight of #2
+
+						// process R,G,B,A simultaneously for cache coherence?
+						float accum[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
+
+#define ACCUM3(x,y,z,factor) \
+						{ float f = factor; \
+						size_t off = (x+y*src.rowPitch+z*src.slicePitch)*srcchannels; \
+						accum[0]+=srcdata[off+0]*f; accum[1]+=srcdata[off+1]*f; \
+						accum[2]+=srcdata[off+2]*f; }
+
+#define ACCUM4(x,y,z,factor) \
+						{ float f = factor; \
+						size_t off = (x+y*src.rowPitch+z*src.slicePitch)*srcchannels; \
+						accum[0]+=srcdata[off+0]*f; accum[1]+=srcdata[off+1]*f; \
+						accum[2]+=srcdata[off+2]*f; accum[3]+=srcdata[off+3]*f; }
+
+						if (srcchannels == 3 || dstchannels == 3) {
+							// RGB, no alpha
+							ACCUM3(sx1,sy1,sz1,(1.0f-sxf)*(1.0f-syf)*(1.0f-szf));
+							ACCUM3(sx2,sy1,sz1,      sxf *(1.0f-syf)*(1.0f-szf));
+							ACCUM3(sx1,sy2,sz1,(1.0f-sxf)*      syf *(1.0f-szf));
+							ACCUM3(sx2,sy2,sz1,      sxf *      syf *(1.0f-szf));
+							ACCUM3(sx1,sy1,sz2,(1.0f-sxf)*(1.0f-syf)*      szf );
+							ACCUM3(sx2,sy1,sz2,      sxf *(1.0f-syf)*      szf );
+							ACCUM3(sx1,sy2,sz2,(1.0f-sxf)*      syf *      szf );
+							ACCUM3(sx2,sy2,sz2,      sxf *      syf *      szf );
+							accum[3] = 1.0f;
+						} else {
+							// RGBA
+							ACCUM4(sx1,sy1,sz1,(1.0f-sxf)*(1.0f-syf)*(1.0f-szf));
+							ACCUM4(sx2,sy1,sz1,      sxf *(1.0f-syf)*(1.0f-szf));
+							ACCUM4(sx1,sy2,sz1,(1.0f-sxf)*      syf *(1.0f-szf));
+							ACCUM4(sx2,sy2,sz1,      sxf *      syf *(1.0f-szf));
+							ACCUM4(sx1,sy1,sz2,(1.0f-sxf)*(1.0f-syf)*      szf );
+							ACCUM4(sx2,sy1,sz2,      sxf *(1.0f-syf)*      szf );
+							ACCUM4(sx1,sy2,sz2,(1.0f-sxf)*      syf *      szf );
+							ACCUM4(sx2,sy2,sz2,      sxf *      syf *      szf );
+						}
+
+						memcpy(pdst, accum, sizeof(float)*dstchannels);
+
+#undef ACCUM3
+#undef ACCUM4
+
+						pdst += dstchannels;
+					}
+					pdst += dstchannels*dst.getRowSkip();
+				}
+				pdst += dstchannels*dst.getSliceSkip();
+			}
+		}
+	};
+
+
+
+	// byte linear resampler, does not do any format conversions.
+	// only handles pixel formats that use 1 byte per color channel.
+	// 2D only; punts 3D pixelboxes to default LinearResampler (slow).
+	// templated on bytes-per-pixel to allow compiler optimizations, such
+	// as unrolling loops and replacing multiplies with bitshifts
+	template<unsigned int channels> struct LinearResampler_Byte {
+		static void scale(const PixelData& src, const PixelData& dst) {
+			// assert(src.format == dst.format);
+
+			// only optimized for 2D
+			if (src.getDepth() > 1 || dst.getDepth() > 1) {
+				LinearResampler::scale(src, dst);
+				return;
+			}
+
+			// srcdata stays at beginning of slice, pdst is a moving pointer
+			UINT8* srcdata = (UINT8*)src.data;
+			UINT8* pdst = (UINT8*)dst.data;
+
+			// sx_48,sy_48 represent current position in source
+			// using 16/48-bit fixed precision, incremented by steps
+			UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
+			UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
+
+			// bottom 28 bits of temp are 16/12 bit fixed precision, used to
+			// adjust a source coordinate backwards by half a pixel so that the
+			// integer bits represent the first sample (eg, sx1) and the
+			// fractional bits are the blend weight of the second sample
+			unsigned int temp;
+
+			UINT64 sy_48 = (stepy >> 1) - 1;
+			for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
+				temp = static_cast<unsigned int>(sy_48 >> 36);
+				temp = (temp > 0x800)? temp - 0x800: 0;
+				unsigned int syf = temp & 0xFFF;
+				size_t sy1 = temp >> 12;
+				size_t sy2 = std::min(sy1+1, src.bottom-src.top-1);
+				size_t syoff1 = sy1 * src.rowPitch;
+				size_t syoff2 = sy2 * src.rowPitch;
+
+				UINT64 sx_48 = (stepx >> 1) - 1;
+				for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
+					temp = static_cast<unsigned int>(sx_48 >> 36);
+					temp = (temp > 0x800)? temp - 0x800 : 0;
+					unsigned int sxf = temp & 0xFFF;
+					size_t sx1 = temp >> 12;
+					size_t sx2 = std::min(sx1+1, src.right-src.left-1);
+
+					unsigned int sxfsyf = sxf*syf;
+					for (unsigned int k = 0; k < channels; k++) {
+						unsigned int accum =
+							srcdata[(sx1 + syoff1)*channels+k]*(0x1000000-(sxf<<12)-(syf<<12)+sxfsyf) +
+							srcdata[(sx2 + syoff1)*channels+k]*((sxf<<12)-sxfsyf) +
+							srcdata[(sx1 + syoff2)*channels+k]*((syf<<12)-sxfsyf) +
+							srcdata[(sx2 + syoff2)*channels+k]*sxfsyf;
+						// accum is computed using 8/24-bit fixed-point math
+						// (maximum is 0xFF000000; rounding will not cause overflow)
+						*pdst++ = static_cast<UINT8>((accum + 0x800000) >> 24);
+					}
+				}
+				pdst += channels*dst.getRowSkip();
+			}
+		}
+	};
+
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     /**
     /**
     * A record that describes a pixel format in detail.
     * A record that describes a pixel format in detail.
@@ -630,11 +936,11 @@ namespace CamelotEngine {
         
         
     };
     };
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
-	size_t PixelBox::getConsecutiveSize() const
+	size_t PixelData::getConsecutiveSize() const
 	{
 	{
 		return PixelUtil::getMemorySize(getWidth(), getHeight(), getDepth(), format);
 		return PixelUtil::getMemorySize(getWidth(), getHeight(), getDepth(), format);
 	}
 	}
-	PixelBox PixelBox::getSubVolume(const Box &def) const
+	PixelData PixelData::getSubVolume(const Box &def) const
 	{
 	{
 		if(PixelUtil::isCompressed(format))
 		if(PixelUtil::isCompressed(format))
 		{
 		{
@@ -653,7 +959,7 @@ namespace CamelotEngine {
 		// Calculate new data origin
 		// Calculate new data origin
 		// Notice how we do not propagate left/top/front from the incoming box, since
 		// Notice how we do not propagate left/top/front from the incoming box, since
 		// the returned pointer is already offset
 		// the returned pointer is already offset
-		PixelBox rval(def.getWidth(), def.getHeight(), def.getDepth(), format, 
+		PixelData rval(def.getWidth(), def.getHeight(), def.getDepth(), format, 
 			((UINT8*)data) + ((def.left-left)*elemSize)
 			((UINT8*)data) + ((def.left-left)*elemSize)
 			+ ((def.top-top)*rowPitch*elemSize)
 			+ ((def.top-top)*rowPitch*elemSize)
 			+ ((def.front-front)*slicePitch*elemSize)
 			+ ((def.front-front)*slicePitch*elemSize)
@@ -1235,13 +1541,13 @@ namespace CamelotEngine {
     void PixelUtil::bulkPixelConversion(void *srcp, PixelFormat srcFormat,
     void PixelUtil::bulkPixelConversion(void *srcp, PixelFormat srcFormat,
         void *destp, PixelFormat dstFormat, unsigned int count)
         void *destp, PixelFormat dstFormat, unsigned int count)
     {
     {
-        PixelBox src(count, 1, 1, srcFormat, srcp),
+        PixelData src(count, 1, 1, srcFormat, srcp),
 				 dst(count, 1, 1, dstFormat, destp);
 				 dst(count, 1, 1, dstFormat, destp);
 
 
         bulkPixelConversion(src, dst);
         bulkPixelConversion(src, dst);
     }
     }
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
-    void PixelUtil::bulkPixelConversion(const PixelBox &src, const PixelBox &dst)
+    void PixelUtil::bulkPixelConversion(const PixelData &src, const PixelData &dst)
     {
     {
         assert(src.getWidth() == dst.getWidth() &&
         assert(src.getWidth() == dst.getWidth() &&
 			   src.getHeight() == dst.getHeight() &&
 			   src.getHeight() == dst.getHeight() &&
@@ -1309,7 +1615,7 @@ namespace CamelotEngine {
 		{
 		{
 			// Do the same conversion, with PF_A8R8G8B8, which has a lot of
 			// Do the same conversion, with PF_A8R8G8B8, which has a lot of
 			// optimized conversions
 			// optimized conversions
-			PixelBox tempdst = dst;
+			PixelData tempdst = dst;
 			tempdst.format = dst.format==PF_X8R8G8B8?PF_A8R8G8B8:PF_A8B8G8R8;
 			tempdst.format = dst.format==PF_X8R8G8B8?PF_A8R8G8B8:PF_A8B8G8R8;
 			bulkPixelConversion(src, tempdst);
 			bulkPixelConversion(src, tempdst);
 			return;
 			return;
@@ -1320,7 +1626,7 @@ namespace CamelotEngine {
 		{
 		{
 			// Do the same conversion, with PF_A8R8G8B8, which has a lot of
 			// Do the same conversion, with PF_A8R8G8B8, which has a lot of
 			// optimized conversions
 			// optimized conversions
-			PixelBox tempsrc = src;
+			PixelData tempsrc = src;
 			tempsrc.format = src.format==PF_X8R8G8B8?PF_A8R8G8B8:PF_A8B8G8R8;
 			tempsrc.format = src.format==PF_X8R8G8B8?PF_A8R8G8B8:PF_A8B8G8R8;
 			bulkPixelConversion(tempsrc, dst);
 			bulkPixelConversion(tempsrc, dst);
 			return;
 			return;
@@ -1363,12 +1669,12 @@ namespace CamelotEngine {
         }
         }
     }
     }
 
 
-	void PixelUtil::scale(const PixelBox &src, const PixelBox &scaled, Filter filter)
+	void PixelUtil::scale(const PixelData &src, const PixelData &scaled, Filter filter)
 	{
 	{
 		assert(PixelUtil::isAccessible(src.format));
 		assert(PixelUtil::isAccessible(src.format));
 		assert(PixelUtil::isAccessible(scaled.format));
 		assert(PixelUtil::isAccessible(scaled.format));
 
 
-		PixelBox temp;
+		PixelData temp;
 		switch (filter) 
 		switch (filter) 
 		{
 		{
 		default:
 		default:
@@ -1381,7 +1687,7 @@ namespace CamelotEngine {
 			else
 			else
 			{
 			{
 				// Allocate temporary buffer of destination size in source format 
 				// Allocate temporary buffer of destination size in source format 
-				temp = PixelBox(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
+				temp = PixelData(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
 				temp.data = malloc(temp.getConsecutiveSize());
 				temp.data = malloc(temp.getConsecutiveSize());
 			}
 			}
 			// super-optimized: no conversion
 			// super-optimized: no conversion
@@ -1425,7 +1731,7 @@ namespace CamelotEngine {
 				else
 				else
 				{
 				{
 					// Allocate temp buffer of destination size in source format 
 					// Allocate temp buffer of destination size in source format 
-					temp = PixelBox(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
+					temp = PixelData(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
 					temp.data = malloc(temp.getConsecutiveSize());
 					temp.data = malloc(temp.getConsecutiveSize());
 				}
 				}
 				// super-optimized: byte-oriented math, no conversion
 				// super-optimized: byte-oriented math, no conversion
@@ -1463,7 +1769,7 @@ namespace CamelotEngine {
 		}
 		}
 	}
 	}
 
 
-    Color PixelBox::getColourAt(size_t x, size_t y, size_t z)
+    Color PixelData::getColourAt(size_t x, size_t y, size_t z)
     {
     {
         Color cv;
         Color cv;
 
 
@@ -1474,7 +1780,7 @@ namespace CamelotEngine {
         return cv;
         return cv;
     }
     }
 
 
-    void PixelBox::setColourAt(Color const &cv, size_t x, size_t y, size_t z)
+    void PixelData::setColourAt(Color const &cv, size_t x, size_t y, size_t z)
     {
     {
         unsigned char pixelSize = PixelUtil::getNumElemBytes(format);
         unsigned char pixelSize = PixelUtil::getNumElemBytes(format);
         size_t pixelOffset = pixelSize * (z * slicePitch + y * rowPitch + x);
         size_t pixelOffset = pixelSize * (z * slicePitch + y * rowPitch + x);

+ 8 - 8
CamelotRenderer/CmPixelFormat.h → CamelotRenderer/CmPixelUtil.h

@@ -190,11 +190,11 @@ namespace CamelotEngine {
      	Pixels are stored as a succession of "depth" slices, each containing "height" rows of 
      	Pixels are stored as a succession of "depth" slices, each containing "height" rows of 
      	"width" pixels.
      	"width" pixels.
     */
     */
-    class CM_EXPORT PixelBox: public Box {
+    class CM_EXPORT PixelData: public Box {
     public:
     public:
     	/// Parameter constructor for setting the members manually
     	/// Parameter constructor for setting the members manually
-    	PixelBox() {}
-		~PixelBox() {}
+    	PixelData() {}
+		~PixelData() {}
 		/** Constructor providing extents in the form of a Box object. This constructor
 		/** Constructor providing extents in the form of a Box object. This constructor
     		assumes the pixel data is laid out consecutively in memory. (this
     		assumes the pixel data is laid out consecutively in memory. (this
     		means row after row, slice after slice, with no space in between)
     		means row after row, slice after slice, with no space in between)
@@ -202,7 +202,7 @@ namespace CamelotEngine {
     		@param pixelFormat	Format of this buffer
     		@param pixelFormat	Format of this buffer
     		@param pixelData	Pointer to the actual data
     		@param pixelData	Pointer to the actual data
     	*/
     	*/
-		PixelBox(const Box &extents, PixelFormat pixelFormat, void *pixelData=0):
+		PixelData(const Box &extents, PixelFormat pixelFormat, void *pixelData=0):
 			Box(extents), data(pixelData), format(pixelFormat)
 			Box(extents), data(pixelData), format(pixelFormat)
 		{
 		{
 			setConsecutive();
 			setConsecutive();
@@ -216,7 +216,7 @@ namespace CamelotEngine {
     		@param pixelFormat	Format of this buffer
     		@param pixelFormat	Format of this buffer
     		@param pixelData    Pointer to the actual data
     		@param pixelData    Pointer to the actual data
     	*/
     	*/
-    	PixelBox(size_t width, size_t height, size_t depth, PixelFormat pixelFormat, void *pixelData=0):
+    	PixelData(size_t width, size_t height, size_t depth, PixelFormat pixelFormat, void *pixelData=0):
     		Box(0, 0, 0, width, height, depth),
     		Box(0, 0, 0, width, height, depth),
     		data(pixelData), format(pixelFormat)
     		data(pixelData), format(pixelFormat)
     	{
     	{
@@ -277,7 +277,7 @@ namespace CamelotEngine {
       			the data of object.
       			the data of object.
       		@throws	Exception(ERR_INVALIDPARAMS) if def is not fully contained
       		@throws	Exception(ERR_INVALIDPARAMS) if def is not fully contained
       	*/
       	*/
-      	PixelBox getSubVolume(const Box &def) const;
+      	PixelData getSubVolume(const Box &def) const;
         
         
         /**
         /**
          * Get colour value from a certain location in the PixelBox. The z coordinate
          * Get colour value from a certain location in the PixelBox. The z coordinate
@@ -499,7 +499,7 @@ namespace CamelotEngine {
 		 	@remarks The source and destination boxes must have the same
 		 	@remarks The source and destination boxes must have the same
          	dimensions. In case the source and destination format match, a plain copy is done.
          	dimensions. In case the source and destination format match, a plain copy is done.
         */
         */
-        static void bulkPixelConversion(const PixelBox &src, const PixelBox &dst);
+        static void bulkPixelConversion(const PixelData &src, const PixelData &dst);
 
 
 		enum Filter
 		enum Filter
 		{
 		{
@@ -518,7 +518,7 @@ namespace CamelotEngine {
 			@remarks 	This function can do pixel format conversion in the process.
 			@remarks 	This function can do pixel format conversion in the process.
 			@note	dst and src can point to the same PixelBox object without any problem
 			@note	dst and src can point to the same PixelBox object without any problem
 		*/
 		*/
-		static void scale(const PixelBox &src, const PixelBox &dst, Filter filter = FILTER_BILINEAR);
+		static void scale(const PixelData &src, const PixelData &dst, Filter filter = FILTER_BILINEAR);
     };
     };
 	/** @} */
 	/** @} */
 	/** @} */
 	/** @} */

+ 2 - 2
CamelotRenderer/CmRenderTarget.h

@@ -31,7 +31,7 @@ THE SOFTWARE.
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 
 
 #include "CmString.h"
 #include "CmString.h"
-#include "CmPixelFormat.h"
+#include "CmPixelUtil.h"
 #include "CmViewport.h"
 #include "CmViewport.h"
 
 
 /* Define the number of priority groups for the render system's render targets. */
 /* Define the number of priority groups for the render system's render targets. */
@@ -202,7 +202,7 @@ namespace CamelotEngine {
 			extract into, although you can use whatever format you like and the 
 			extract into, although you can use whatever format you like and the 
 			results will be converted.
 			results will be converted.
 		*/
 		*/
-		virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer = FB_AUTO) = 0;
+		virtual void copyContentsToMemory(const PixelData &dst, FrameBuffer buffer = FB_AUTO) = 0;
 
 
 		/** Suggests a pixel format to use for extracting the data in this target, 
 		/** Suggests a pixel format to use for extracting the data in this target, 
 			when calling copyContentsToMemory.
 			when calling copyContentsToMemory.

+ 2 - 2
CamelotRenderer/CmRenderTexture.cpp

@@ -48,7 +48,7 @@ namespace CamelotEngine
 		mBuffer->_clearSliceRTT(0);
 		mBuffer->_clearSliceRTT(0);
     }
     }
 
 
-	void RenderTexture::copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer)
+	void RenderTexture::copyContentsToMemory(const PixelData &dst, FrameBuffer buffer)
     {
     {
 		if (buffer == FB_AUTO) buffer = FB_FRONT;
 		if (buffer == FB_AUTO) buffer = FB_FRONT;
 		if (buffer != FB_FRONT)
 		if (buffer != FB_FRONT)
@@ -74,7 +74,7 @@ namespace CamelotEngine
 		mWidth = mHeight = 0;
 		mWidth = mHeight = 0;
     }
     }
 	//-----------------------------------------------------------------------------
 	//-----------------------------------------------------------------------------
-	void MultiRenderTarget::copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer)
+	void MultiRenderTarget::copyContentsToMemory(const PixelData &dst, FrameBuffer buffer)
 	{
 	{
 		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
 		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
 					"Cannot get MultiRenderTargets pixels",
 					"Cannot get MultiRenderTargets pixels",

+ 2 - 2
CamelotRenderer/CmRenderTexture.h

@@ -51,7 +51,7 @@ namespace CamelotEngine
         RenderTexture(HardwarePixelBuffer *buffer, size_t zoffset);
         RenderTexture(HardwarePixelBuffer *buffer, size_t zoffset);
         virtual ~RenderTexture();
         virtual ~RenderTexture();
 
 
-		virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer);
+		virtual void copyContentsToMemory(const PixelData &dst, FrameBuffer buffer);
 		PixelFormat suggestPixelFormat() const;
 		PixelFormat suggestPixelFormat() const;
 
 
 	protected:
 	protected:
@@ -106,7 +106,7 @@ namespace CamelotEngine
 		/** Error throwing implementation, it's not possible to write a MultiRenderTarget
 		/** Error throwing implementation, it's not possible to write a MultiRenderTarget
 			to disk. 
 			to disk. 
 		*/
 		*/
-		virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer);
+		virtual void copyContentsToMemory(const PixelData &dst, FrameBuffer buffer);
 
 
 		/// Irrelevant implementation since cannot copy
 		/// Irrelevant implementation since cannot copy
 		PixelFormat suggestPixelFormat() const { return PF_UNKNOWN; }
 		PixelFormat suggestPixelFormat() const { return PF_UNKNOWN; }

+ 1 - 1
CamelotRenderer/CmTexture.h

@@ -30,7 +30,7 @@ THE SOFTWARE.
 
 
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include "CmHardwareBuffer.h"
 #include "CmHardwareBuffer.h"
-#include "CmPixelFormat.h"
+#include "CmPixelUtil.h"
 
 
 namespace CamelotEngine {
 namespace CamelotEngine {
 
 

+ 1 - 1
CamelotRenderer/CmTextureManager.cpp

@@ -27,7 +27,7 @@ THE SOFTWARE.
 */
 */
 #include "CmTextureManager.h"
 #include "CmTextureManager.h"
 #include "CmException.h"
 #include "CmException.h"
-#include "CmPixelFormat.h"
+#include "CmPixelUtil.h"
 
 
 namespace CamelotEngine {
 namespace CamelotEngine {
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------

+ 1 - 1
CamelotRenderer/CmTextureState.h

@@ -32,7 +32,7 @@ THE SOFTWARE.
 #include "CmCommon.h"
 #include "CmCommon.h"
 #include "CmMatrix4.h"
 #include "CmMatrix4.h"
 #include "CmString.h"
 #include "CmString.h"
-#include "CmPixelFormat.h"
+#include "CmPixelUtil.h"
 #include "CmTexture.h"
 #include "CmTexture.h"
 
 
 namespace CamelotEngine {
 namespace CamelotEngine {

+ 9 - 9
CamelotRenderer/RenderSystemGL/Include/CmGLHardwarePixelBuffer.h

@@ -36,14 +36,14 @@ namespace CamelotEngine {
 	{
 	{
 	protected:  
 	protected:  
 		/// Lock a box
 		/// Lock a box
-		PixelBox lockImpl(const Box lockBox,  LockOptions options);
+		PixelData lockImpl(const Box lockBox,  LockOptions options);
 
 
 		/// Unlock a box
 		/// Unlock a box
 		void unlockImpl(void);
 		void unlockImpl(void);
         
         
 		// Internal buffer; either on-card or in system memory, freed/allocated on demand
 		// Internal buffer; either on-card or in system memory, freed/allocated on demand
 		// depending on buffer usage
 		// depending on buffer usage
-		PixelBox mBuffer;
+		PixelData mBuffer;
         GLenum mGLInternalFormat; // GL internal format
         GLenum mGLInternalFormat; // GL internal format
 		LockOptions mCurrentLockOptions;
 		LockOptions mCurrentLockOptions;
 		
 		
@@ -51,9 +51,9 @@ namespace CamelotEngine {
 		void allocateBuffer();
 		void allocateBuffer();
 		void freeBuffer();
 		void freeBuffer();
 		// Upload a box of pixels to this buffer on the card
 		// Upload a box of pixels to this buffer on the card
-		virtual void upload(const PixelBox &data, const Box &dest);
+		virtual void upload(const PixelData &data, const Box &dest);
 		// Download a box of pixels from the card
 		// Download a box of pixels from the card
-		virtual void download(const PixelBox &data);
+		virtual void download(const PixelData &data);
 	public:
 	public:
         /// Should be called by HardwareBufferManager
         /// Should be called by HardwareBufferManager
         GLHardwarePixelBuffer(size_t mWidth, size_t mHeight, size_t mDepth,
         GLHardwarePixelBuffer(size_t mWidth, size_t mHeight, size_t mDepth,
@@ -61,10 +61,10 @@ namespace CamelotEngine {
                 HardwareBuffer::Usage usage);
                 HardwareBuffer::Usage usage);
 		
 		
 		/// @copydoc HardwarePixelBuffer::blitFromMemory
 		/// @copydoc HardwarePixelBuffer::blitFromMemory
-		void blitFromMemory(const PixelBox &src, const Box &dstBox);
+		void blitFromMemory(const PixelData &src, const Box &dstBox);
 		
 		
 		/// @copydoc HardwarePixelBuffer::blitToMemory
 		/// @copydoc HardwarePixelBuffer::blitToMemory
-		void blitToMemory(const Box &srcBox, const PixelBox &dst);
+		void blitToMemory(const Box &srcBox, const PixelData &dst);
 		
 		
 		~GLHardwarePixelBuffer();
 		~GLHardwarePixelBuffer();
         
         
@@ -89,12 +89,12 @@ namespace CamelotEngine {
         /// @copydoc HardwarePixelBuffer::getRenderTarget
         /// @copydoc HardwarePixelBuffer::getRenderTarget
         RenderTexture* getRenderTarget(size_t);
         RenderTexture* getRenderTarget(size_t);
         /// Upload a box of pixels to this buffer on the card
         /// Upload a box of pixels to this buffer on the card
-		virtual void upload(const PixelBox &data, const Box &dest);
+		virtual void upload(const PixelData &data, const Box &dest);
 		// Download a box of pixels from the card
 		// Download a box of pixels from the card
-		virtual void download(const PixelBox &data);
+		virtual void download(const PixelData &data);
   
   
         /// Hardware implementation of blitFromMemory
         /// Hardware implementation of blitFromMemory
-        virtual void blitFromMemory(const PixelBox &src_orig, const Box &dstBox);
+        virtual void blitFromMemory(const PixelData &src_orig, const Box &dstBox);
         
         
         /// Notify TextureBuffer of destruction of render target
         /// Notify TextureBuffer of destruction of render target
         void _clearSliceRTT(size_t zoffset)
         void _clearSliceRTT(size_t zoffset)

+ 1 - 1
CamelotRenderer/RenderSystemGL/Include/CmGLPixelFormat.h

@@ -29,7 +29,7 @@ THE SOFTWARE.
 #define __GLPIXELFORMAT_H__
 #define __GLPIXELFORMAT_H__
 
 
 #include "CmGLPrerequisites.h"
 #include "CmGLPrerequisites.h"
-#include "CmPixelFormat.h"
+#include "CmPixelUtil.h"
 namespace CamelotEngine {
 namespace CamelotEngine {
     
     
 	/**
 	/**

+ 1 - 1
CamelotRenderer/RenderSystemGL/Include/CmWin32Window.h

@@ -51,7 +51,7 @@ namespace CamelotEngine {
         void swapBuffers(bool waitForVSync);
         void swapBuffers(bool waitForVSync);
 
 
 		/** Overridden - see RenderTarget. */
 		/** Overridden - see RenderTarget. */
-		virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer);
+		virtual void copyContentsToMemory(const PixelData &dst, FrameBuffer buffer);
 
 
 		bool requiresTextureFlipping() const { return false; }
 		bool requiresTextureFlipping() const { return false; }
 
 

+ 12 - 12
CamelotRenderer/RenderSystemGL/Source/CmGLHardwarePixelBuffer.cpp

@@ -72,7 +72,7 @@ void GLHardwarePixelBuffer::freeBuffer()
 	}
 	}
 }
 }
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
-PixelBox GLHardwarePixelBuffer::lockImpl(const Box lockBox,  LockOptions options)
+PixelData GLHardwarePixelBuffer::lockImpl(const Box lockBox,  LockOptions options)
 {
 {
 	allocateBuffer();
 	allocateBuffer();
 	if(options != HardwareBuffer::HBL_DISCARD) 
 	if(options != HardwareBuffer::HBL_DISCARD) 
@@ -97,12 +97,12 @@ void GLHardwarePixelBuffer::unlockImpl(void)
 }
 }
 
 
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
-void GLHardwarePixelBuffer::blitFromMemory(const PixelBox &src, const Box &dstBox)
+void GLHardwarePixelBuffer::blitFromMemory(const PixelData &src, const Box &dstBox)
 {
 {
 	if(!mBuffer.contains(dstBox))
 	if(!mBuffer.contains(dstBox))
 		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "destination box out of range",
 		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "destination box out of range",
 		 "GLHardwarePixelBuffer::blitFromMemory");
 		 "GLHardwarePixelBuffer::blitFromMemory");
-	PixelBox scaled;
+	PixelData scaled;
 	
 	
 	if(src.getWidth() != dstBox.getWidth() ||
 	if(src.getWidth() != dstBox.getWidth() ||
 		src.getHeight() != dstBox.getHeight() ||
 		src.getHeight() != dstBox.getHeight() ||
@@ -134,7 +134,7 @@ void GLHardwarePixelBuffer::blitFromMemory(const PixelBox &src, const Box &dstBo
 	freeBuffer();
 	freeBuffer();
 }
 }
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
-void GLHardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelBox &dst)
+void GLHardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst)
 {
 {
 	if(!mBuffer.contains(srcBox))
 	if(!mBuffer.contains(srcBox))
 		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "source box out of range",
 		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "source box out of range",
@@ -173,14 +173,14 @@ void GLHardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelBox &dst)
 	}
 	}
 }
 }
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-void GLHardwarePixelBuffer::upload(const PixelBox &data, const Box &dest)
+void GLHardwarePixelBuffer::upload(const PixelData &data, const Box &dest)
 {
 {
     OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
     OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
 		"Upload not possible for this pixelbuffer type",
 		"Upload not possible for this pixelbuffer type",
         "GLHardwarePixelBuffer::upload");
         "GLHardwarePixelBuffer::upload");
 }
 }
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
-void GLHardwarePixelBuffer::download(const PixelBox &data)
+void GLHardwarePixelBuffer::download(const PixelData &data)
 {
 {
     OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Download not possible for this pixelbuffer type",
     OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Download not possible for this pixelbuffer type",
         "GLHardwarePixelBuffer::download");
         "GLHardwarePixelBuffer::download");
@@ -249,7 +249,7 @@ GLTextureBuffer::GLTextureBuffer(const String &baseName, GLenum target, GLuint i
                 LML_NORMAL, str.str());
                 LML_NORMAL, str.str());
 	*/
 	*/
 	// Set up pixel box
 	// Set up pixel box
-	mBuffer = PixelBox(mWidth, mHeight, mDepth, mFormat);
+	mBuffer = PixelData(mWidth, mHeight, mDepth, mFormat);
 	
 	
     if(mWidth==0 || mHeight==0 || mDepth==0)
     if(mWidth==0 || mHeight==0 || mDepth==0)
         /// We are invalid, do not allocate a buffer
         /// We are invalid, do not allocate a buffer
@@ -288,7 +288,7 @@ GLTextureBuffer::~GLTextureBuffer()
 	}
 	}
 }
 }
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-void GLTextureBuffer::upload(const PixelBox &data, const Box &dest)
+void GLTextureBuffer::upload(const PixelData &data, const Box &dest)
 {
 {
 	glBindTexture( mTarget, mTextureID );
 	glBindTexture( mTarget, mTextureID );
 	if(PixelUtil::isCompressed(data.format))
 	if(PixelUtil::isCompressed(data.format))
@@ -462,7 +462,7 @@ void GLTextureBuffer::upload(const PixelBox &data, const Box &dest)
 	glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
 	glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
 }
 }
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
-void GLTextureBuffer::download(const PixelBox &data)
+void GLTextureBuffer::download(const PixelData &data)
 {
 {
 	if(data.getWidth() != getWidth() ||
 	if(data.getWidth() != getWidth() ||
 		data.getHeight() != getHeight() ||
 		data.getHeight() != getHeight() ||
@@ -777,7 +777,7 @@ void GLTextureBuffer::blitFromTexture(GLTextureBuffer *src, const Box &srcBox, c
 }
 }
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
 /// blitFromMemory doing hardware trilinear scaling
 /// blitFromMemory doing hardware trilinear scaling
-void GLTextureBuffer::blitFromMemory(const PixelBox &src_orig, const Box &dstBox)
+void GLTextureBuffer::blitFromMemory(const PixelData &src_orig, const Box &dstBox)
 {
 {
     /// Fall back to normal GLHardwarePixelBuffer::blitFromMemory in case 
     /// Fall back to normal GLHardwarePixelBuffer::blitFromMemory in case 
     /// - FBO is not supported
     /// - FBO is not supported
@@ -798,14 +798,14 @@ void GLTextureBuffer::blitFromMemory(const PixelBox &src_orig, const Box &dstBox
                     "GLTextureBuffer::blitFromMemory");
                     "GLTextureBuffer::blitFromMemory");
     /// For scoped deletion of conversion buffer
     /// For scoped deletion of conversion buffer
 	void* data = NULL;
 	void* data = NULL;
-    PixelBox src;
+    PixelData src;
     
     
     /// First, convert the srcbox to a OpenGL compatible pixel format
     /// First, convert the srcbox to a OpenGL compatible pixel format
     if(GLPixelUtil::getGLOriginFormat(src_orig.format) == 0)
     if(GLPixelUtil::getGLOriginFormat(src_orig.format) == 0)
     {
     {
         /// Convert to buffer internal format
         /// Convert to buffer internal format
 		data = new void*[PixelUtil::getMemorySize(src.getWidth(), src.getHeight(), src.getDepth(), mFormat)];
 		data = new void*[PixelUtil::getMemorySize(src.getWidth(), src.getHeight(), src.getDepth(), mFormat)];
-        src = PixelBox(src_orig.getWidth(), src_orig.getHeight(), src_orig.getDepth(), mFormat, data);
+        src = PixelData(src_orig.getWidth(), src_orig.getHeight(), src_orig.getDepth(), mFormat, data);
         PixelUtil::bulkPixelConversion(src_orig, src);
         PixelUtil::bulkPixelConversion(src_orig, src);
     }
     }
     else
     else

+ 3 - 4
CamelotRenderer/RenderSystemGL/Source/CmWin32Window.cpp

@@ -218,9 +218,8 @@ namespace CamelotEngine {
 
 
 			size_t devNameLen = strlen(monitorInfoEx.szDevice);
 			size_t devNameLen = strlen(monitorInfoEx.szDevice);
 			mDeviceName = new char[devNameLen + 1];
 			mDeviceName = new char[devNameLen + 1];
-
-			strcpy(mDeviceName, monitorInfoEx.szDevice);			
-
+	
+			strcpy_s(mDeviceName, devNameLen + 1, monitorInfoEx.szDevice);
 
 
 			// No specified top left -> Center the window in the middle of the monitor
 			// No specified top left -> Center the window in the middle of the monitor
 			if (left == -1 || top == -1)
 			if (left == -1 || top == -1)
@@ -702,7 +701,7 @@ namespace CamelotEngine {
 	  }
 	  }
 	}
 	}
 
 
-	void Win32Window::copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer)
+	void Win32Window::copyContentsToMemory(const PixelData &dst, FrameBuffer buffer)
 	{
 	{
 		if ((dst.left < 0) || (dst.right > mWidth) ||
 		if ((dst.left < 0) || (dst.right > mWidth) ||
 			(dst.top < 0) || (dst.bottom > mHeight) ||
 			(dst.top < 0) || (dst.bottom > mHeight) ||

+ 1 - 1
CamelotRenderer/RenderSystemGL/Source/atifs/src/ATI_FS_GLGpuProgram.cpp

@@ -134,7 +134,7 @@ void ATI_FS_GLGpuProgram::loadFromSource(void)
 	{
 	{
 		// an error occured when compiling the ps_1_4 source code
 		// an error occured when compiling the ps_1_4 source code
 		char buff[50];
 		char buff[50];
-        sprintf(buff,"error on line %d in pixel shader source\n", PS1_4Assembler.mCurrentLine);
+        sprintf_s(buff, 50, "error on line %d in pixel shader source\n", PS1_4Assembler.mCurrentLine);
 
 
 		// TODO LOG PORT - Log this somewhere
 		// TODO LOG PORT - Log this somewhere
 		//LogManager::getSingleton().logMessage("Warning: atifs compiler reported the following errors:");
 		//LogManager::getSingleton().logMessage("Warning: atifs compiler reported the following errors:");