00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright (c) 2000-2013 Torus Knot Software Ltd 00008 00009 Permission is hereby granted, free of charge, to any person obtaining a copy 00010 of this software and associated documentation files (the "Software"), to deal 00011 in the Software without restriction, including without limitation the rights 00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 copies of the Software, and to permit persons to whom the Software is 00014 furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in 00017 all copies or substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 THE SOFTWARE. 00026 ----------------------------------------------------------------------------- 00027 */ 00028 #ifndef _TextureManager_H__ 00029 #define _TextureManager_H__ 00030 00031 00032 #include "OgrePrerequisites.h" 00033 00034 #include "OgreResourceManager.h" 00035 #include "OgreTexture.h" 00036 #include "OgreSingleton.h" 00037 00038 00039 namespace Ogre { 00040 00060 class _OgreExport TextureManager : public ResourceManager, public Singleton<TextureManager> 00061 { 00062 public: 00063 00064 TextureManager(void); 00065 virtual ~TextureManager(); 00066 00067 00070 TexturePtr create (const String& name, const String& group, 00071 bool isManual = false, ManualResourceLoader* loader = 0, 00072 const NameValuePairList* createParams = 0); 00075 TexturePtr getByName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME); 00076 00102 virtual ResourceCreateOrRetrieveResult createOrRetrieve( 00103 const String &name, const String& group, bool isManual = false, 00104 ManualResourceLoader* loader = 0, const NameValuePairList* createParams = 0, 00105 TextureType texType = TEX_TYPE_2D, int numMipmaps = MIP_DEFAULT, 00106 Real gamma = 1.0f, bool isAlpha = false, 00107 PixelFormat desiredFormat = PF_UNKNOWN, bool hwGammaCorrection = false); 00108 00136 virtual TexturePtr prepare( 00137 const String& name, const String& group, 00138 TextureType texType = TEX_TYPE_2D, int numMipmaps = MIP_DEFAULT, 00139 Real gamma = 1.0f, bool isAlpha = false, 00140 PixelFormat desiredFormat = PF_UNKNOWN, bool hwGammaCorrection = false); 00141 00171 virtual TexturePtr load( 00172 const String& name, const String& group, 00173 TextureType texType = TEX_TYPE_2D, int numMipmaps = MIP_DEFAULT, 00174 Real gamma = 1.0f, bool isAlpha = false, 00175 PixelFormat desiredFormat = PF_UNKNOWN, 00176 bool hwGammaCorrection = false); 00177 00209 virtual TexturePtr loadImage( 00210 const String &name, const String& group, const Image &img, 00211 TextureType texType = TEX_TYPE_2D, 00212 int numMipmaps = MIP_DEFAULT, Real gamma = 1.0f, bool isAlpha = false, 00213 PixelFormat desiredFormat = PF_UNKNOWN, bool hwGammaCorrection = false); 00214 00248 virtual TexturePtr loadRawData(const String &name, const String& group, 00249 DataStreamPtr& stream, ushort width, ushort height, 00250 PixelFormat format, TextureType texType = TEX_TYPE_2D, 00251 int numMipmaps = MIP_DEFAULT, Real gamma = 1.0f, bool hwGammaCorrection = false); 00252 00299 virtual TexturePtr createManual(const String & name, const String& group, 00300 TextureType texType, uint width, uint height, uint depth, 00301 int numMipmaps, PixelFormat format, int usage = TU_DEFAULT, ManualResourceLoader* loader = 0, 00302 bool hwGammaCorrection = false, uint fsaa = 0, const String& fsaaHint = StringUtil::BLANK); 00303 00348 TexturePtr createManual(const String & name, const String& group, 00349 TextureType texType, uint width, uint height, int numMipmaps, 00350 PixelFormat format, int usage = TU_DEFAULT, ManualResourceLoader* loader = 0, 00351 bool hwGammaCorrection = false, uint fsaa = 0, const String& fsaaHint = StringUtil::BLANK) 00352 { 00353 return createManual(name, group, texType, width, height, 1, 00354 numMipmaps, format, usage, loader, hwGammaCorrection, fsaa, fsaaHint); 00355 } 00356 00364 virtual void setPreferredIntegerBitDepth(ushort bits, bool reloadTextures = true); 00365 00368 virtual ushort getPreferredIntegerBitDepth(void) const; 00369 00377 virtual void setPreferredFloatBitDepth(ushort bits, bool reloadTextures = true); 00378 00381 virtual ushort getPreferredFloatBitDepth(void) const; 00382 00393 virtual void setPreferredBitDepths(ushort integerBits, ushort floatBits, bool reloadTextures = true); 00394 00411 virtual bool isFormatSupported(TextureType ttype, PixelFormat format, int usage); 00412 00416 virtual bool isEquivalentFormatSupported(TextureType ttype, PixelFormat format, int usage); 00417 00421 virtual PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage) = 0; 00422 00462 virtual bool isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage, 00463 bool preciseFormatOnly = false) = 0; 00464 00473 virtual void setDefaultNumMipmaps(size_t num); 00474 00477 virtual size_t getDefaultNumMipmaps() 00478 { 00479 return mDefaultNumMipmaps; 00480 } 00481 00497 static TextureManager& getSingleton(void); 00513 static TextureManager* getSingletonPtr(void); 00514 00515 protected: 00516 00517 ushort mPreferredIntegerBitDepth; 00518 ushort mPreferredFloatBitDepth; 00519 size_t mDefaultNumMipmaps; 00520 }; 00523 }// Namespace 00524 00525 #endif
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:48