OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-2014 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 
302  virtual TexturePtr createManual(const String & name, const String& group,
303  TextureType texType, uint width, uint height, uint depth,
304  int numMipmaps, PixelFormat format, int usage = TU_DEFAULT, ManualResourceLoader* loader = 0,
305  bool hwGammaCorrection = false, uint fsaa = 0, const String& fsaaHint = BLANKSTRING,
306  bool explicitResolve = false);
307 
355  TexturePtr createManual(const String & name, const String& group,
356  TextureType texType, uint width, uint height, int numMipmaps,
357  PixelFormat format, int usage = TU_DEFAULT, ManualResourceLoader* loader = 0,
358  bool hwGammaCorrection = false, uint fsaa = 0, const String& fsaaHint = BLANKSTRING,
359  bool explicitResolve = false)
360  {
361  return createManual(name, group, texType, width, height, 1,
362  numMipmaps, format, usage, loader, hwGammaCorrection, fsaa, fsaaHint, explicitResolve);
363  }
364 
372  virtual void setPreferredIntegerBitDepth(ushort bits, bool reloadTextures = true);
373 
376  virtual ushort getPreferredIntegerBitDepth(void) const;
377 
385  virtual void setPreferredFloatBitDepth(ushort bits, bool reloadTextures = true);
386 
389  virtual ushort getPreferredFloatBitDepth(void) const;
390 
401  virtual void setPreferredBitDepths(ushort integerBits, ushort floatBits, bool reloadTextures = true);
402 
419  virtual bool isFormatSupported(TextureType ttype, PixelFormat format, int usage);
420 
424  virtual bool isEquivalentFormatSupported(TextureType ttype, PixelFormat format, int usage);
425 
429  virtual PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage) = 0;
430 
470  virtual bool isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage,
471  bool preciseFormatOnly = false) = 0;
472 
481  virtual void setDefaultNumMipmaps(size_t num);
482 
485  virtual size_t getDefaultNumMipmaps()
486  {
487  return mDefaultNumMipmaps;
488  }
489 
505  static TextureManager& getSingleton(void);
521  static TextureManager* getSingletonPtr(void);
522 
523  protected:
524 
528  };
531 }// Namespace
532 
533 #endif
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:255
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:580
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
Class for loading & managing textures.
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
Interface describing a manual resource loader.
Definition: OgreResource.h:498
const String BLANKSTRING
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreCommon.h:574
Unknown pixel format.
PixelFormat
The pixel format used for images, textures, and render surfaces.
std::pair< ResourcePtr, bool > ResourceCreateOrRetrieveResult
Class representing an image file.
Definition: OgreImage.h:60
unsigned short ushort
TexturePtr createManual(const String &name, const String &group, TextureType texType, uint width, uint height, int numMipmaps, PixelFormat format, int usage=TU_DEFAULT, ManualResourceLoader *loader=0, bool hwGammaCorrection=false, uint fsaa=0, const String &fsaaHint=BLANKSTRING, bool explicitResolve=false)
Create a manual texture with a depth of 1 (not loaded from a file).
TextureType
Enum identifying the texture type.
Definition: OgreTexture.h:76
Defines a generic resource handler.
2D texture, used in combination with 2D texture coordinates (default)
Definition: OgreTexture.h:81
_StringBase String
Definition: OgreCommon.h:53
Use TextureManager default.
Definition: OgreTexture.h:99
Default to automatic mipmap generation static textures.
Definition: OgreTexture.h:62
unsigned int uint
virtual size_t getDefaultNumMipmaps()
Gets the default number of mipmaps to be used for loaded textures.