Browse Source

Renamed texture unit state to texture state

Marko Pintera 13 years ago
parent
commit
0bdb45b2b6

+ 2 - 2
CamelotRenderer/CamelotRenderer.vcxproj

@@ -169,7 +169,7 @@
     <ClInclude Include="OgreStringConverter.h" />
     <ClInclude Include="OgreTexture.h" />
     <ClInclude Include="OgreTextureManager.h" />
-    <ClInclude Include="OgreTextureUnitState.h" />
+    <ClInclude Include="OgreTextureState.h" />
     <ClInclude Include="OgreThreadDefines.h" />
     <ClInclude Include="OgreVector2.h" />
     <ClInclude Include="OgreVector3.h" />
@@ -298,7 +298,7 @@
     <ClCompile Include="OgreStringConverter.cpp" />
     <ClCompile Include="OgreTexture.cpp" />
     <ClCompile Include="OgreTextureManager.cpp" />
-    <ClCompile Include="OgreTextureUnitState.cpp" />
+    <ClCompile Include="OgreTextureState.cpp" />
     <ClCompile Include="OgreVector2.cpp" />
     <ClCompile Include="OgreVector3.cpp" />
     <ClCompile Include="OgreVector4.cpp" />

+ 6 - 6
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -220,9 +220,6 @@
     <ClInclude Include="OgreRenderSystem.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="OgreTextureUnitState.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="OgreTexture.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -508,6 +505,9 @@
     <ClInclude Include="OgreConfigOptionMap.h">
       <Filter>Header Files\ForRemoval</Filter>
     </ClInclude>
+    <ClInclude Include="OgreTextureState.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="stdafx.cpp">
@@ -612,9 +612,6 @@
     <ClCompile Include="OgreRenderSystem.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="OgreTextureUnitState.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="OgreTexture.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -891,5 +888,8 @@
     <ClCompile Include="OgreTextureManager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="OgreTextureState.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 2 - 0
CamelotRenderer/OgreD3D9DeviceManager.cpp

@@ -439,6 +439,8 @@ namespace Ogre
 				return currDriver;				
 			}
 		}
+
+		return nullptr;
 	}
 
 	//-----------------------------------------------------------------------

+ 5 - 5
CamelotRenderer/OgreD3D9Mappings.cpp

@@ -85,17 +85,17 @@ namespace Ogre
 		return 0;
 	}
 	//---------------------------------------------------------------------
-	D3DTEXTUREADDRESS D3D9Mappings::get(TextureUnitState::TextureAddressingMode tam, const D3DCAPS9& devCaps)
+	D3DTEXTUREADDRESS D3D9Mappings::get(TextureState::TextureAddressingMode tam, const D3DCAPS9& devCaps)
 	{
 		switch( tam )
 		{
-		case TextureUnitState::TAM_WRAP:
+		case TextureState::TAM_WRAP:
 			return D3DTADDRESS_WRAP;
-		case TextureUnitState::TAM_MIRROR:
+		case TextureState::TAM_MIRROR:
 			return D3DTADDRESS_MIRROR;
-		case TextureUnitState::TAM_CLAMP:
+		case TextureState::TAM_CLAMP:
 			return D3DTADDRESS_CLAMP;
-        case TextureUnitState::TAM_BORDER:
+        case TextureState::TAM_BORDER:
             if (devCaps.TextureAddressCaps & D3DPTADDRESSCAPS_BORDER)
                 return D3DTADDRESS_BORDER;
             else

+ 1 - 1
CamelotRenderer/OgreD3D9Mappings.h

@@ -68,7 +68,7 @@ namespace Ogre
 		/// return a D3D9 equivalent for a Ogre TexCoordCalsMethod value
 		static DWORD get(TexCoordCalcMethod m, const D3DCAPS9& caps);
 		/// return a D3D9 equivalent for a Ogre TextureAddressingMode value
-		static D3DTEXTUREADDRESS get(TextureUnitState::TextureAddressingMode tam, const D3DCAPS9& devCaps);
+		static D3DTEXTUREADDRESS get(TextureState::TextureAddressingMode tam, const D3DCAPS9& devCaps);
 		/// return a D3D9 equivalent for a Ogre LayerBlendType value
 		static D3DTEXTURESTAGESTATETYPE get(LayerBlendType lbt);
 		/// return a D3D9 equivalent for a Ogre LayerBlendOperationEx value

+ 1 - 1
CamelotRenderer/OgreD3D9RenderSystem.cpp

@@ -2043,7 +2043,7 @@ namespace Ogre
 	}
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setTextureAddressingMode( size_t stage, 
-		const TextureUnitState::UVWAddressingMode& uvw )
+		const TextureState::UVWAddressingMode& uvw )
 	{
 		HRESULT hr;
 		if( FAILED( hr = __SetSamplerState( static_cast<DWORD>(stage), D3DSAMP_ADDRESSU, D3D9Mappings::get(uvw.u, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps()) ) ) )

+ 1 - 1
CamelotRenderer/OgreD3D9RenderSystem.h

@@ -245,7 +245,7 @@ namespace Ogre
         void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m, 
             const Frustum* frustum = 0);
 		void _setTextureBlendMode( size_t unit, const LayerBlendModeEx& bm );
-        void _setTextureAddressingMode(size_t stage, const TextureUnitState::UVWAddressingMode& uvw);
+        void _setTextureAddressingMode(size_t stage, const TextureState::UVWAddressingMode& uvw);
         void _setTextureBorderColour(size_t stage, const ColourValue& colour);
 		void _setTextureMipmapBias(size_t unit, float bias);
 		void _setTextureMatrix( size_t unit, const Matrix4 &xform );

+ 1 - 1
CamelotRenderer/OgrePrerequisites.h

@@ -154,7 +154,7 @@ namespace Ogre {
     class Sphere;
     class StringConverter;
     class StringInterface;
-    class TextureUnitState;
+    class TextureState;
     class Texture;
     class TextureManager;
     class Vector2;

+ 3 - 3
CamelotRenderer/OgreRenderSystem.cpp

@@ -281,7 +281,7 @@ namespace Ogre {
         return mActiveViewport;
     }
     //-----------------------------------------------------------------------
-    void RenderSystem::_setTextureUnitSettings(size_t texUnit, const TexturePtr& tex, TextureUnitState& tl)
+    void RenderSystem::_setTextureUnitSettings(size_t texUnit, const TexturePtr& tex, TextureState& tl)
     {
         // This method is only ever called to set a texture unit to valid details
         // The method _disableTextureUnit is called to turn a unit off
@@ -290,7 +290,7 @@ namespace Ogre {
 		if (mCurrentCapabilities->hasCapability(RSC_VERTEX_TEXTURE_FETCH) &&
 			!mCurrentCapabilities->getVertexTextureUnitsShared())
 		{
-			if (tl.getBindingType() == TextureUnitState::BT_VERTEX)
+			if (tl.getBindingType() == TextureState::BT_VERTEX)
 			{
 				// Bind vertex texture
 				_setVertexTexture(texUnit, tex);
@@ -325,7 +325,7 @@ namespace Ogre {
 		_setTextureMipmapBias(texUnit, tl.getTextureMipmapBias());
 
         // Texture addressing mode
-        const TextureUnitState::UVWAddressingMode& uvw = tl.getTextureAddressingMode();
+        const TextureState::UVWAddressingMode& uvw = tl.getTextureAddressingMode();
         _setTextureAddressingMode(texUnit, uvw);
     }
 	//-----------------------------------------------------------------------

+ 3 - 3
CamelotRenderer/OgreRenderSystem.h

@@ -35,7 +35,7 @@ THE SOFTWARE.
 
 #include "OgreString.h"
 
-#include "OgreTextureUnitState.h"
+#include "OgreTextureState.h"
 #include "OgreCommon.h"
 
 #include "OgreRenderOperation.h"
@@ -545,7 +545,7 @@ namespace Ogre
 		only sets those settings which are different from the current settings for this
 		unit, thus minimising render state changes.
 		*/
-		virtual void _setTextureUnitSettings(size_t texUnit, const TexturePtr& texture, TextureUnitState& tl);
+		virtual void _setTextureUnitSettings(size_t texUnit, const TexturePtr& texture, TextureState& tl);
 		/** Turns off a texture unit. */
 		virtual void _disableTextureUnit(size_t texUnit);
 		/** Disables all texture units from the given unit upwards */
@@ -684,7 +684,7 @@ namespace Ogre
 		virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0;
 
 		/** Sets the texture addressing mode for a texture unit.*/
-		virtual void _setTextureAddressingMode(size_t unit, const TextureUnitState::UVWAddressingMode& uvw) = 0;
+		virtual void _setTextureAddressingMode(size_t unit, const TextureState::UVWAddressingMode& uvw) = 0;
 
 		/** Sets the texture border colour for a texture unit.*/
 		virtual void _setTextureBorderColour(size_t unit, const ColourValue& colour) = 0;

+ 35 - 35
CamelotRenderer/OgreTextureUnitState.cpp → CamelotRenderer/OgreTextureState.cpp

@@ -25,13 +25,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 -----------------------------------------------------------------------------
 */
-#include "OgreTextureUnitState.h"
+#include "OgreTextureState.h"
 #include "OgreException.h"
 
 namespace Ogre {
 
     //-----------------------------------------------------------------------
-    TextureUnitState::TextureUnitState(TextureType type)
+    TextureState::TextureState(TextureType type)
 		: mTextureType(type)
         , mDesiredFormat(PF_UNKNOWN)
 		, mTextureSrcMipmaps(MIP_DEFAULT)
@@ -50,119 +50,119 @@ namespace Ogre {
     }
 
     //-----------------------------------------------------------------------
-    TextureUnitState::TextureUnitState(const TextureUnitState& oth )
+    TextureState::TextureState(const TextureState& oth )
     {
         *this = oth;
     }
 
     //-----------------------------------------------------------------------
-    TextureUnitState::~TextureUnitState()
+    TextureState::~TextureState()
     {
     }
     //-----------------------------------------------------------------------
-    TextureUnitState & TextureUnitState::operator = ( 
-        const TextureUnitState &oth )
+    TextureState & TextureState::operator = ( 
+        const TextureState &oth )
     {
         return *this;
     }
 	//-----------------------------------------------------------------------
-	void TextureUnitState::setBindingType(TextureUnitState::BindingType bt)
+	void TextureState::setBindingType(TextureState::BindingType bt)
 	{
 		mBindingType = bt;
 
 	}
 	//-----------------------------------------------------------------------
-	TextureUnitState::BindingType TextureUnitState::getBindingType(void) const
+	TextureState::BindingType TextureState::getBindingType(void) const
 	{
 		return mBindingType;
 	}
     //-----------------------------------------------------------------------
-    bool TextureUnitState::isCubic(void) const
+    bool TextureState::isCubic(void) const
     {
         return mTextureType == TEX_TYPE_CUBE_MAP;
     }
     //-----------------------------------------------------------------------
-    bool TextureUnitState::is3D(void) const
+    bool TextureState::is3D(void) const
     {
         return mTextureType == TEX_TYPE_3D;
     }
     //-----------------------------------------------------------------------
-    TextureType TextureUnitState::getTextureType(void) const
+    TextureType TextureState::getTextureType(void) const
     {
         return mTextureType;
 	}
     //-----------------------------------------------------------------------
-    void TextureUnitState::setDesiredFormat(PixelFormat desiredFormat)
+    void TextureState::setDesiredFormat(PixelFormat desiredFormat)
     {
         mDesiredFormat = desiredFormat;
     }
     //-----------------------------------------------------------------------
-    PixelFormat TextureUnitState::getDesiredFormat(void) const
+    PixelFormat TextureState::getDesiredFormat(void) const
     {
         return mDesiredFormat;
     }
     //-----------------------------------------------------------------------
-    void TextureUnitState::setNumMipmaps(int numMipmaps)
+    void TextureState::setNumMipmaps(int numMipmaps)
     {
         mTextureSrcMipmaps = numMipmaps;
     }
     //-----------------------------------------------------------------------
-    int TextureUnitState::getNumMipmaps(void) const
+    int TextureState::getNumMipmaps(void) const
     {
         return mTextureSrcMipmaps;
     }
     //-----------------------------------------------------------------------
-    void TextureUnitState::setIsAlpha(bool isAlpha)
+    void TextureState::setIsAlpha(bool isAlpha)
     {
         mIsAlpha = isAlpha;
     }
     //-----------------------------------------------------------------------
-    bool TextureUnitState::getIsAlpha(void) const
+    bool TextureState::getIsAlpha(void) const
     {
         return mIsAlpha;
     }
 	//-----------------------------------------------------------------------
-	void TextureUnitState::setHardwareGammaEnabled(bool g)
+	void TextureState::setHardwareGammaEnabled(bool g)
 	{
 		mHwGamma = g;
 	}
 	//-----------------------------------------------------------------------
-	bool TextureUnitState::isHardwareGammaEnabled() const
+	bool TextureState::isHardwareGammaEnabled() const
 	{
 		return mHwGamma;
 	}
     //-----------------------------------------------------------------------
-    const TextureUnitState::UVWAddressingMode& 
-	TextureUnitState::getTextureAddressingMode(void) const
+    const TextureState::UVWAddressingMode& 
+	TextureState::getTextureAddressingMode(void) const
     {
         return mAddressMode;
     }
     //-----------------------------------------------------------------------
-    void TextureUnitState::setTextureAddressingMode(
-		TextureUnitState::TextureAddressingMode tam)
+    void TextureState::setTextureAddressingMode(
+		TextureState::TextureAddressingMode tam)
     {
         mAddressMode.u = tam;
         mAddressMode.v = tam;
         mAddressMode.w = tam;
     }
     //-----------------------------------------------------------------------
-    void TextureUnitState::setTextureAddressingMode(
-		TextureUnitState::TextureAddressingMode u, 
-		TextureUnitState::TextureAddressingMode v,
-		TextureUnitState::TextureAddressingMode w)
+    void TextureState::setTextureAddressingMode(
+		TextureState::TextureAddressingMode u, 
+		TextureState::TextureAddressingMode v,
+		TextureState::TextureAddressingMode w)
     {
         mAddressMode.u = u;
         mAddressMode.v = v;
         mAddressMode.w = w;
     }
     //-----------------------------------------------------------------------
-    void TextureUnitState::setTextureAddressingMode(
-		const TextureUnitState::UVWAddressingMode& uvw)
+    void TextureState::setTextureAddressingMode(
+		const TextureState::UVWAddressingMode& uvw)
     {
         mAddressMode = uvw;
     }
 	//-----------------------------------------------------------------------
-	void TextureUnitState::setTextureFiltering(TextureFilterOptions filterType)
+	void TextureState::setTextureFiltering(TextureFilterOptions filterType)
 	{
         switch (filterType)
         {
@@ -182,7 +182,7 @@ namespace Ogre {
         mIsDefaultFiltering = false;
 	}
 	//-----------------------------------------------------------------------
-    void TextureUnitState::setTextureFiltering(FilterType ft, FilterOptions fo)
+    void TextureState::setTextureFiltering(FilterType ft, FilterOptions fo)
     {
         switch (ft)
         {
@@ -199,7 +199,7 @@ namespace Ogre {
         mIsDefaultFiltering = false;
     }
 	//-----------------------------------------------------------------------
-    void TextureUnitState::setTextureFiltering(FilterOptions minFilter, 
+    void TextureState::setTextureFiltering(FilterOptions minFilter, 
         FilterOptions magFilter, FilterOptions mipFilter)
     {
         mMinFilter = minFilter;
@@ -208,7 +208,7 @@ namespace Ogre {
         mIsDefaultFiltering = false;
     }
 	//-----------------------------------------------------------------------
-	FilterOptions TextureUnitState::getTextureFiltering(FilterType ft) const
+	FilterOptions TextureState::getTextureFiltering(FilterType ft) const
 	{
         switch (ft)
         {
@@ -224,13 +224,13 @@ namespace Ogre {
 	}
 
 	//-----------------------------------------------------------------------
-	void TextureUnitState::setTextureAnisotropy(unsigned int maxAniso)
+	void TextureState::setTextureAnisotropy(unsigned int maxAniso)
 	{
 		mMaxAniso = maxAniso;
         mIsDefaultAniso = false;
 	}
 	//-----------------------------------------------------------------------
-	unsigned int TextureUnitState::getTextureAnisotropy() const
+	unsigned int TextureState::getTextureAnisotropy() const
 	{
         return mMaxAniso;
 	}

+ 7 - 8
CamelotRenderer/OgreTextureUnitState.h → CamelotRenderer/OgreTextureState.h

@@ -25,8 +25,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 -----------------------------------------------------------------------------
 */
-#ifndef __TextureUnitState_H__
-#define __TextureUnitState_H__
+#ifndef __TextureState_H__
+#define __TextureState_H__
 
 #include "OgrePrerequisites.h"
 #include "OgreCommon.h"
@@ -58,9 +58,8 @@ namespace Ogre {
         where you do not use vertex or fragment programs (shaders). Programmable 
         pipeline means that for this pass you are using vertex or fragment programs.
     */
-	class _OgreExport TextureUnitState
+	class _OgreExport TextureState
     {
-        friend class RenderSystem;
     public:
 
         /** Texture addressing modes - default is TAM_WRAP.
@@ -100,15 +99,15 @@ namespace Ogre {
 
         /** Default constructor.
         */
-        TextureUnitState(TextureType type);
+        TextureState(TextureType type);
 
-        TextureUnitState(const TextureUnitState& oth );
+        TextureState(const TextureState& oth );
 
-        TextureUnitState & operator = ( const TextureUnitState& oth );
+        TextureState & operator = ( const TextureState& oth );
 
         /** Default destructor.
         */
-        ~TextureUnitState();
+        ~TextureState();
 
 		/** The type of unit to bind the texture settings to. */
 		enum BindingType

+ 2 - 2
CamelotRenderer/RenderSystemGL/Include/OgreGLRenderSystem.h

@@ -78,7 +78,7 @@ namespace Ogre {
         void makeGLMatrix(GLfloat gl_matrix[16], const Matrix4& m);
  
         GLint getBlendMode(SceneBlendFactor ogreBlend) const;
-		GLint getTextureAddressingMode(TextureUnitState::TextureAddressingMode tam) const;
+		GLint getTextureAddressingMode(TextureState::TextureAddressingMode tam) const;
 				void initialiseContext(RenderWindow* primary);
 
         void setLights();
@@ -284,7 +284,7 @@ namespace Ogre {
         /** See
           RenderSystem
          */
-        void _setTextureAddressingMode(size_t stage, const TextureUnitState::UVWAddressingMode& uvw);
+        void _setTextureAddressingMode(size_t stage, const TextureState::UVWAddressingMode& uvw);
         /** See
           RenderSystem
          */

+ 8 - 8
CamelotRenderer/RenderSystemGL/Source/OgreGLRenderSystem.cpp

@@ -1242,7 +1242,7 @@ namespace Ogre {
 			
 			// XXX: why do I need this for results to be consistent with D3D?
 			// Equations are supposedly the same once you factor in vp height
-			Real correction = 0.005;
+			Real correction = 0.005f;
 			// scaling required
 			val[0] = constant;
 			val[1] = linear * correction;
@@ -1527,24 +1527,24 @@ namespace Ogre {
 	}
 	//-----------------------------------------------------------------------------
 	GLint GLRenderSystem::getTextureAddressingMode(
-		TextureUnitState::TextureAddressingMode tam) const
+		TextureState::TextureAddressingMode tam) const
 	{
 		switch(tam)
 		{
 		default:
-		case TextureUnitState::TAM_WRAP:
+		case TextureState::TAM_WRAP:
 			return GL_REPEAT;
-		case TextureUnitState::TAM_MIRROR:
+		case TextureState::TAM_MIRROR:
 			return GL_MIRRORED_REPEAT;
-		case TextureUnitState::TAM_CLAMP:
+		case TextureState::TAM_CLAMP:
 			return GL_CLAMP_TO_EDGE;
-		case TextureUnitState::TAM_BORDER:
+		case TextureState::TAM_BORDER:
 			return GL_CLAMP_TO_BORDER;
 		}
 
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setTextureAddressingMode(size_t stage, const TextureUnitState::UVWAddressingMode& uvw)
+	void GLRenderSystem::_setTextureAddressingMode(size_t stage, const TextureState::UVWAddressingMode& uvw)
 	{
 		if (!activateGLTextureUnit(stage))
 			return;
@@ -2348,7 +2348,7 @@ namespace Ogre {
 			maxAnisotropy = largest_supported_anisotropy ? 
 			static_cast<uint>(largest_supported_anisotropy) : 1;
 		if (_getCurrentAnisotropy(unit) != maxAnisotropy)
-			glTexParameterf(mTextureTypes[unit], GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy);
+			glTexParameterf(mTextureTypes[unit], GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)maxAnisotropy);
 
 		activateGLTextureUnit(0);
 	}

+ 4 - 4
CamelotRenderer/RenderSystemGL/Source/OgreWin32Window.cpp

@@ -233,8 +233,8 @@ namespace Ogre {
 				adjustWindow(width, height, &winWidth, &winHeight);
 
 				// clamp window dimensions to screen size
-				int outerw = (winWidth < screenw)? winWidth : screenw;
-				int outerh = (winHeight < screenh)? winHeight : screenh;
+				int outerw = (int(winWidth) < screenw)? int(winWidth) : screenw;
+				int outerh = (int(winHeight) < screenh)? int(winHeight) : screenh;
 
 				if (left == -1)
 					left = monitorInfoEx.rcWork.left + (screenw - outerw) / 2;
@@ -573,8 +573,8 @@ namespace Ogre {
 				LONG screenh = monitorInfo.rcWork.bottom - monitorInfo.rcWork.top;
 
 
-				int left = screenw > winWidth ? ((screenw - winWidth) / 2) : 0;
-				int top = screenh > winHeight ? ((screenh - winHeight) / 2) : 0;
+				int left = screenw > int(winWidth) ? ((screenw - int(winWidth)) / 2) : 0;
+				int top = screenh > int(winHeight) ? ((screenh - int(winHeight)) / 2) : 0;
 
 				SetWindowLong(mHWnd, GWL_STYLE, dwStyle);
 				SetWindowPos(mHWnd, HWND_NOTOPMOST, left, top, winWidth, winHeight,

+ 2 - 4
CamelotRenderer/TODO.txt

@@ -65,10 +65,8 @@ RenderWindow - Everything OK
 Texture
  - mTreatLuminanceAsAlpha and corresponding methods - I dont think I need that or that it's used
 
-TextureUnitState - Try to remove this class completely
- - Texture transform and effect stuff should be removed completely
- - Texture addressing mode/vert,frag binding/anisotropy/mipbias/min,mag,mip filters, should be specified per-material
- - Move the rest somewhere else (Needs further study)
+TextureState - PARSED!
+ - This is just an utility class representing texture state
 
 VertexIndexData - Just data structures
  - VertexCacheProfiler is a weird one, but I think I don't have to remove it as it might come in handy