OgreTextureManager.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef _TextureManager_H__
29 #define _TextureManager_H__
30 
31 
32 #include "OgrePrerequisites.h"
33 
34 #include "OgreResourceManager.h"
35 #include "OgreTexture.h"
36 #include "OgreSingleton.h"
37 
38 
39 namespace Ogre {
40 
60  class _OgreExport TextureManager : public ResourceManager, public Singleton<TextureManager>
61  {
62  public:
63 
64  TextureManager(void);
65  virtual ~TextureManager();
66 
67 
70  TexturePtr create (const String& name, const String& group,
71  bool isManual = false, ManualResourceLoader* loader = 0,
72  const NameValuePairList* createParams = 0);
75  TexturePtr getByName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
76 
102  virtual ResourceCreateOrRetrieveResult createOrRetrieve(
103  const String &name, const String& group, bool isManual = false,
104  ManualResourceLoader* loader = 0, const NameValuePairList* createParams = 0,
105  TextureType texType = TEX_TYPE_2D, int numMipmaps = MIP_DEFAULT,
106  Real gamma = 1.0f, bool isAlpha = false,
107  PixelFormat desiredFormat = PF_UNKNOWN, bool hwGammaCorrection = false);
108 
136  virtual TexturePtr prepare(
137  const String& name, const String& group,
138  TextureType texType = TEX_TYPE_2D, int numMipmaps = MIP_DEFAULT,
139  Real gamma = 1.0f, bool isAlpha = false,
140  PixelFormat desiredFormat = PF_UNKNOWN, bool hwGammaCorrection = false);
141 
171  virtual TexturePtr load(
172  const String& name, const String& group,
173  TextureType texType = TEX_TYPE_2D, int numMipmaps = MIP_DEFAULT,
174  Real gamma = 1.0f, bool isAlpha = false,
175  PixelFormat desiredFormat = PF_UNKNOWN,
176  bool hwGammaCorrection = false);
177 
209  virtual TexturePtr loadImage(
210  const String &name, const String& group, const Image &img,
211  TextureType texType = TEX_TYPE_2D,
212  int numMipmaps = MIP_DEFAULT, Real gamma = 1.0f, bool isAlpha = false,
213  PixelFormat desiredFormat = PF_UNKNOWN, bool hwGammaCorrection = false);
214 
248  virtual TexturePtr loadRawData(const String &name, const String& group,
249  DataStreamPtr& stream, ushort width, ushort height,
250  PixelFormat format, TextureType texType = TEX_TYPE_2D,
251  int numMipmaps = MIP_DEFAULT, Real gamma = 1.0f, bool hwGammaCorrection = false);
252 
299  virtual TexturePtr createManual(const String & name, const String& group,
300  TextureType texType, uint width, uint height, uint depth,
301  int numMipmaps, PixelFormat format, int usage = TU_DEFAULT, ManualResourceLoader* loader = 0,
302  bool hwGammaCorrection = false, uint fsaa = 0, const String& fsaaHint = StringUtil::BLANK);
303 
348  TexturePtr createManual(const String & name, const String& group,
349  TextureType texType, uint width, uint height, int numMipmaps,
350  PixelFormat format, int usage = TU_DEFAULT, ManualResourceLoader* loader = 0,
351  bool hwGammaCorrection = false, uint fsaa = 0, const String& fsaaHint = StringUtil::BLANK)
352  {
353  return createManual(name, group, texType, width, height, 1,
354  numMipmaps, format, usage, loader, hwGammaCorrection, fsaa, fsaaHint);
355  }
356 
364  virtual void setPreferredIntegerBitDepth(ushort bits, bool reloadTextures = true);
365 
368  virtual ushort getPreferredIntegerBitDepth(void) const;
369 
377  virtual void setPreferredFloatBitDepth(ushort bits, bool reloadTextures = true);
378 
381  virtual ushort getPreferredFloatBitDepth(void) const;
382 
393  virtual void setPreferredBitDepths(ushort integerBits, ushort floatBits, bool reloadTextures = true);
394 
411  virtual bool isFormatSupported(TextureType ttype, PixelFormat format, int usage);
412 
416  virtual bool isEquivalentFormatSupported(TextureType ttype, PixelFormat format, int usage);
417 
421  virtual PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage) = 0;
422 
462  virtual bool isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage,
463  bool preciseFormatOnly = false) = 0;
464 
473  virtual void setDefaultNumMipmaps(size_t num);
474 
477  virtual size_t getDefaultNumMipmaps()
478  {
479  return mDefaultNumMipmaps;
480  }
481 
497  static TextureManager& getSingleton(void);
513  static TextureManager* getSingletonPtr(void);
514 
515  protected:
516 
520  };
523 }// Namespace
524 
525 #endif

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 23 2013 06:57:26