| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- /*
- -----------------------------------------------------------------------------
- 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.
- -----------------------------------------------------------------------------
- */
- #include "OgreTextureState.h"
- #include "OgreException.h"
- namespace Ogre {
- //-----------------------------------------------------------------------
- TextureState::TextureState(TextureType type)
- : mTextureType(type)
- , mDesiredFormat(PF_UNKNOWN)
- , mTextureSrcMipmaps(MIP_DEFAULT)
- , mIsAlpha(false)
- , mHwGamma(false)
- , mMinFilter(FO_LINEAR)
- , mMagFilter(FO_LINEAR)
- , mMipFilter(FO_POINT)
- , mMaxAniso(0)
- , mMipmapBias(0)
- , mIsDefaultAniso(true)
- , mIsDefaultFiltering(true)
- , mBindingType(BT_FRAGMENT)
- {
- setTextureAddressingMode(TAM_WRAP);
- }
- //-----------------------------------------------------------------------
- TextureState::TextureState(const TextureState& oth )
- {
- *this = oth;
- }
- //-----------------------------------------------------------------------
- TextureState::~TextureState()
- {
- }
- //-----------------------------------------------------------------------
- TextureState & TextureState::operator = (
- const TextureState &oth )
- {
- return *this;
- }
- //-----------------------------------------------------------------------
- void TextureState::setBindingType(TextureState::BindingType bt)
- {
- mBindingType = bt;
- }
- //-----------------------------------------------------------------------
- TextureState::BindingType TextureState::getBindingType(void) const
- {
- return mBindingType;
- }
- //-----------------------------------------------------------------------
- bool TextureState::isCubic(void) const
- {
- return mTextureType == TEX_TYPE_CUBE_MAP;
- }
- //-----------------------------------------------------------------------
- bool TextureState::is3D(void) const
- {
- return mTextureType == TEX_TYPE_3D;
- }
- //-----------------------------------------------------------------------
- TextureType TextureState::getTextureType(void) const
- {
- return mTextureType;
- }
- //-----------------------------------------------------------------------
- void TextureState::setDesiredFormat(PixelFormat desiredFormat)
- {
- mDesiredFormat = desiredFormat;
- }
- //-----------------------------------------------------------------------
- PixelFormat TextureState::getDesiredFormat(void) const
- {
- return mDesiredFormat;
- }
- //-----------------------------------------------------------------------
- void TextureState::setNumMipmaps(int numMipmaps)
- {
- mTextureSrcMipmaps = numMipmaps;
- }
- //-----------------------------------------------------------------------
- int TextureState::getNumMipmaps(void) const
- {
- return mTextureSrcMipmaps;
- }
- //-----------------------------------------------------------------------
- void TextureState::setIsAlpha(bool isAlpha)
- {
- mIsAlpha = isAlpha;
- }
- //-----------------------------------------------------------------------
- bool TextureState::getIsAlpha(void) const
- {
- return mIsAlpha;
- }
- //-----------------------------------------------------------------------
- void TextureState::setHardwareGammaEnabled(bool g)
- {
- mHwGamma = g;
- }
- //-----------------------------------------------------------------------
- bool TextureState::isHardwareGammaEnabled() const
- {
- return mHwGamma;
- }
- //-----------------------------------------------------------------------
- const TextureState::UVWAddressingMode&
- TextureState::getTextureAddressingMode(void) const
- {
- return mAddressMode;
- }
- //-----------------------------------------------------------------------
- void TextureState::setTextureAddressingMode(
- TextureState::TextureAddressingMode tam)
- {
- mAddressMode.u = tam;
- mAddressMode.v = tam;
- mAddressMode.w = tam;
- }
- //-----------------------------------------------------------------------
- void TextureState::setTextureAddressingMode(
- TextureState::TextureAddressingMode u,
- TextureState::TextureAddressingMode v,
- TextureState::TextureAddressingMode w)
- {
- mAddressMode.u = u;
- mAddressMode.v = v;
- mAddressMode.w = w;
- }
- //-----------------------------------------------------------------------
- void TextureState::setTextureAddressingMode(
- const TextureState::UVWAddressingMode& uvw)
- {
- mAddressMode = uvw;
- }
- //-----------------------------------------------------------------------
- void TextureState::setTextureFiltering(TextureFilterOptions filterType)
- {
- switch (filterType)
- {
- case TFO_NONE:
- setTextureFiltering(FO_POINT, FO_POINT, FO_NONE);
- break;
- case TFO_BILINEAR:
- setTextureFiltering(FO_LINEAR, FO_LINEAR, FO_POINT);
- break;
- case TFO_TRILINEAR:
- setTextureFiltering(FO_LINEAR, FO_LINEAR, FO_LINEAR);
- break;
- case TFO_ANISOTROPIC:
- setTextureFiltering(FO_ANISOTROPIC, FO_ANISOTROPIC, FO_LINEAR);
- break;
- }
- mIsDefaultFiltering = false;
- }
- //-----------------------------------------------------------------------
- void TextureState::setTextureFiltering(FilterType ft, FilterOptions fo)
- {
- switch (ft)
- {
- case FT_MIN:
- mMinFilter = fo;
- break;
- case FT_MAG:
- mMagFilter = fo;
- break;
- case FT_MIP:
- mMipFilter = fo;
- break;
- }
- mIsDefaultFiltering = false;
- }
- //-----------------------------------------------------------------------
- void TextureState::setTextureFiltering(FilterOptions minFilter,
- FilterOptions magFilter, FilterOptions mipFilter)
- {
- mMinFilter = minFilter;
- mMagFilter = magFilter;
- mMipFilter = mipFilter;
- mIsDefaultFiltering = false;
- }
- //-----------------------------------------------------------------------
- FilterOptions TextureState::getTextureFiltering(FilterType ft) const
- {
- switch (ft)
- {
- case FT_MIN:
- return mMinFilter;
- case FT_MAG:
- return mMagFilter;
- case FT_MIP:
- return mMipFilter;
- }
- // to keep compiler happy
- return mMinFilter;
- }
- //-----------------------------------------------------------------------
- void TextureState::setTextureAnisotropy(unsigned int maxAniso)
- {
- mMaxAniso = maxAniso;
- mIsDefaultAniso = false;
- }
- //-----------------------------------------------------------------------
- unsigned int TextureState::getTextureAnisotropy() const
- {
- return mMaxAniso;
- }
- }
|