OGRE  1.9.0
OgreTextureManager.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE 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
39namespace Ogre {
40
60 class _OgreExport TextureManager : public ResourceManager, public Singleton<TextureManager>
61 {
62 public:
63
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
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
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
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
369
377 virtual void setPreferredFloatBitDepth(ushort bits, bool reloadTextures = true);
378
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
514
515 protected:
516
520 };
523}// Namespace
524
525#endif
#define _OgreExport
Definition: OgrePlatform.h:260
Class representing an image file.
Definition: OgreImage.h:62
Interface describing a manual resource loader.
Definition: OgreResource.h:515
Defines a generic resource handler.
std::pair< ResourcePtr, bool > ResourceCreateOrRetrieveResult
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:65
Class for loading & managing textures.
virtual TexturePtr createManual(const String &name, const String &group, TextureType texType, uint width, uint height, uint depth, int numMipmaps, 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 specified width, height and depth (not loaded from a file).
virtual ~TextureManager()
virtual bool isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage, bool preciseFormatOnly=false)=0
Returns whether this render system has hardware filtering supported for the texture format requested ...
virtual TexturePtr load(const String &name, const String &group, TextureType texType=TEX_TYPE_2D, int numMipmaps=MIP_DEFAULT, Real gamma=1.0f, bool isAlpha=false, PixelFormat desiredFormat=PF_UNKNOWN, bool hwGammaCorrection=false)
Loads a texture from a file.
virtual ushort getPreferredFloatBitDepth(void) const
Gets preferred bit depth for float pixel format textures.
virtual TexturePtr loadRawData(const String &name, const String &group, DataStreamPtr &stream, ushort width, ushort height, PixelFormat format, TextureType texType=TEX_TYPE_2D, int numMipmaps=MIP_DEFAULT, Real gamma=1.0f, bool hwGammaCorrection=false)
Loads a texture from a raw data stream.
virtual ResourceCreateOrRetrieveResult createOrRetrieve(const String &name, const String &group, bool isManual=false, ManualResourceLoader *loader=0, const NameValuePairList *createParams=0, TextureType texType=TEX_TYPE_2D, int numMipmaps=MIP_DEFAULT, Real gamma=1.0f, bool isAlpha=false, PixelFormat desiredFormat=PF_UNKNOWN, bool hwGammaCorrection=false)
Create a new texture, or retrieve an existing one with the same name if it already exists.
virtual size_t getDefaultNumMipmaps()
Gets the default number of mipmaps to be used for loaded textures.
static TextureManager * getSingletonPtr(void)
Override standard Singleton retrieval.
virtual TexturePtr prepare(const String &name, const String &group, TextureType texType=TEX_TYPE_2D, int numMipmaps=MIP_DEFAULT, Real gamma=1.0f, bool isAlpha=false, PixelFormat desiredFormat=PF_UNKNOWN, bool hwGammaCorrection=false)
Prepares to loads a texture from a file.
virtual ushort getPreferredIntegerBitDepth(void) const
Gets preferred bit depth for integer pixel format textures.
virtual bool isFormatSupported(TextureType ttype, PixelFormat format, int usage)
Returns whether this render system can natively support the precise texture format requested with the...
virtual void setPreferredFloatBitDepth(ushort bits, bool reloadTextures=true)
Sets preferred bit depth for float pixel format textures.
static TextureManager & getSingleton(void)
Override standard Singleton retrieval.
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=StringUtil::BLANK)
Create a manual texture with a depth of 1 (not loaded from a file).
virtual void setPreferredIntegerBitDepth(ushort bits, bool reloadTextures=true)
Sets preferred bit depth for integer pixel format textures.
virtual TexturePtr loadImage(const String &name, const String &group, const Image &img, TextureType texType=TEX_TYPE_2D, int numMipmaps=MIP_DEFAULT, Real gamma=1.0f, bool isAlpha=false, PixelFormat desiredFormat=PF_UNKNOWN, bool hwGammaCorrection=false)
Loads a texture from an Image object.
virtual void setDefaultNumMipmaps(size_t num)
Sets the default number of mipmaps to be used for loaded textures, for when textures are loaded autom...
virtual bool isEquivalentFormatSupported(TextureType ttype, PixelFormat format, int usage)
Returns whether this render system can support the texture format requested with the given usage opti...
virtual PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage)=0
Gets the format which will be natively used for a requested format given the constraints of the curre...
TexturePtr create(const String &name, const String &group, bool isManual=false, ManualResourceLoader *loader=0, const NameValuePairList *createParams=0)
Create a new texture.
virtual void setPreferredBitDepths(ushort integerBits, ushort floatBits, bool reloadTextures=true)
Sets preferred bit depth for integer and float pixel format.
TexturePtr getByName(const String &name, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
Get a resource by name.
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
PixelFormat
The pixel format used for images, textures, and render surfaces.
TextureType
Enum identifying the texture type.
Definition: OgreTexture.h:68
float Real
Software floating point type.
unsigned int uint
_StringBase String
unsigned short ushort