OGRE  1.8
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-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 
92  virtual ResourceCreateOrRetrieveResult createOrRetrieve(
93  const String &name, const String& group, bool isManual = false,
94  ManualResourceLoader* loader = 0, const NameValuePairList* createParams = 0,
95  TextureType texType = TEX_TYPE_2D, int numMipmaps = MIP_DEFAULT,
96  Real gamma = 1.0f, bool isAlpha = false,
97  PixelFormat desiredFormat = PF_UNKNOWN, bool hwGammaCorrection = false);
98 
126  virtual TexturePtr prepare(
127  const String& name, const String& group,
128  TextureType texType = TEX_TYPE_2D, int numMipmaps = MIP_DEFAULT,
129  Real gamma = 1.0f, bool isAlpha = false,
130  PixelFormat desiredFormat = PF_UNKNOWN, bool hwGammaCorrection = false);
131 
161  virtual TexturePtr load(
162  const String& name, const String& group,
163  TextureType texType = TEX_TYPE_2D, int numMipmaps = MIP_DEFAULT,
164  Real gamma = 1.0f, bool isAlpha = false,
165  PixelFormat desiredFormat = PF_UNKNOWN,
166  bool hwGammaCorrection = false);
167 
199  virtual TexturePtr loadImage(
200  const String &name, const String& group, const Image &img,
201  TextureType texType = TEX_TYPE_2D,
202  int iNumMipmaps = MIP_DEFAULT, Real gamma = 1.0f, bool isAlpha = false,
203  PixelFormat desiredFormat = PF_UNKNOWN, bool hwGammaCorrection = false);
204 
237  virtual TexturePtr loadRawData(const String &name, const String& group,
238  DataStreamPtr& stream, ushort uWidth, ushort uHeight,
239  PixelFormat format, TextureType texType = TEX_TYPE_2D,
240  int iNumMipmaps = MIP_DEFAULT, Real gamma = 1.0f, bool hwGammaCorrection = false);
241 
284  virtual TexturePtr createManual(const String & name, const String& group,
285  TextureType texType, uint width, uint height, uint depth,
286  int num_mips, PixelFormat format, int usage = TU_DEFAULT, ManualResourceLoader* loader = 0,
287  bool hwGammaCorrection = false, uint fsaa = 0, const String& fsaaHint = StringUtil::BLANK);
288 
331  TexturePtr createManual(const String & name, const String& group,
332  TextureType texType, uint width, uint height, int num_mips,
333  PixelFormat format, int usage = TU_DEFAULT, ManualResourceLoader* loader = 0,
334  bool hwGammaCorrection = false, uint fsaa = 0, const String& fsaaHint = StringUtil::BLANK)
335  {
336  return createManual(name, group, texType, width, height, 1,
337  num_mips, format, usage, loader, hwGammaCorrection, fsaa, fsaaHint);
338  }
339 
347  virtual void setPreferredIntegerBitDepth(ushort bits, bool reloadTextures = true);
348 
351  virtual ushort getPreferredIntegerBitDepth(void) const;
352 
360  virtual void setPreferredFloatBitDepth(ushort bits, bool reloadTextures = true);
361 
364  virtual ushort getPreferredFloatBitDepth(void) const;
365 
376  virtual void setPreferredBitDepths(ushort integerBits, ushort floatBits, bool reloadTextures = true);
377 
394  virtual bool isFormatSupported(TextureType ttype, PixelFormat format, int usage);
395 
399  virtual bool isEquivalentFormatSupported(TextureType ttype, PixelFormat format, int usage);
400 
404  virtual PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage) = 0;
405 
445  virtual bool isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage,
446  bool preciseFormatOnly = false) = 0;
447 
456  virtual void setDefaultNumMipmaps(size_t num);
457 
460  virtual size_t getDefaultNumMipmaps()
461  {
462  return mDefaultNumMipmaps;
463  }
464 
480  static TextureManager& getSingleton(void);
496  static TextureManager* getSingletonPtr(void);
497 
498  protected:
499 
503  };
506 }// Namespace
507 
508 #endif
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:233
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:553
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
Class for loading & managing textures.
Interface describing a manual resource loader.
Definition: OgreResource.h:513
Unknown pixel format.
PixelFormat
The pixel format used for images, textures, and render surfaces.
TexturePtr createManual(const String &name, const String &group, TextureType texType, uint width, uint height, int num_mips, PixelFormat format, int usage=TU_DEFAULT, ManualResourceLoader *loader=0, bool hwGammaCorrection=false, uint fsaa=0, const String &fsaaHint=StringUtil::BLANK)
Create a manual texture with a depth of 1 (not loaded from a file).
std::pair< ResourcePtr, bool > ResourceCreateOrRetrieveResult
Specialisation of SharedPtr to allow SharedPtr to be assigned to TexturePtr.
Definition: OgreTexture.h:443
Class representing an image file.
Definition: OgreImage.h:61
unsigned short ushort
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
TextureType
Enum identifying the texture type.
Definition: OgreTexture.h:68
Defines a generic resource handler.
2D texture, used in combination with 2D texture coordinates (default)
Definition: OgreTexture.h:73
_StringBase String
Use TextureManager default.
Definition: OgreTexture.h:89
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.