OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreTexture.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 _Texture_H__
29 #define _Texture_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreHardwareBuffer.h"
33 #include "OgreResource.h"
34 #include "OgreImage.h"
35 #include "OgreHeaderPrefix.h"
36 
37 namespace Ogre {
38 
48  {
63  };
64 
68  {
81  };
82 
86  {
88  MIP_UNLIMITED = 0x7FFFFFFF,
91  };
92 
102  class _OgreExport Texture : public Resource
103  {
104  public:
105  Texture(ResourceManager* creator, const String& name, ResourceHandle handle,
106  const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
107 
108  virtual ~Texture() {}
109 
112  virtual void setTextureType(TextureType ttype ) { mTextureType = ttype; }
113 
116  virtual TextureType getTextureType(void) const { return mTextureType; }
117 
120  virtual uint8 getNumMipmaps(void) const {return mNumMipmaps;}
121 
126  virtual void setNumMipmaps(uint8 num) {mNumRequestedMipmaps = mNumMipmaps = num;}
127 
132  virtual bool getMipmapsHardwareGenerated(void) const { return mMipmapsHardwareGenerated; }
133 
136  virtual float getGamma(void) const { return mGamma; }
137 
146  virtual void setGamma(float g) { mGamma = g; }
147 
166  virtual void setHardwareGammaEnabled(bool enabled) { mHwGamma = enabled; }
167 
171  virtual bool isHardwareGammaEnabled() const { return mHwGamma; }
172 
180  virtual void setFSAA(uint fsaa, const String& fsaaHint) { mFSAA = fsaa; mFSAAHint = fsaaHint; }
181 
185  virtual uint getFSAA() const { return mFSAA; }
186 
189  virtual const String& getFSAAHint() const { return mFSAAHint; }
190 
193  virtual uint32 getHeight(void) const { return mHeight; }
194 
197  virtual uint32 getWidth(void) const { return mWidth; }
198 
201  virtual uint32 getDepth(void) const { return mDepth; }
202 
205  virtual uint32 getSrcHeight(void) const { return mSrcHeight; }
206 
209  virtual uint32 getSrcWidth(void) const { return mSrcWidth; }
210 
213  virtual uint32 getSrcDepth(void) const { return mSrcDepth; }
214 
217  virtual void setHeight(uint32 h) { mHeight = mSrcHeight = h; }
218 
221  virtual void setWidth(uint32 w) { mWidth = mSrcWidth = w; }
222 
226  virtual void setDepth(uint32 d) { mDepth = mSrcDepth = d; }
227 
230  virtual int getUsage() const
231  {
232  return mUsage;
233  }
234 
242  virtual void setUsage(int u) { mUsage = u; }
243 
255  virtual void createInternalResources(void);
256 
259  virtual void freeInternalResources(void);
260 
263  virtual void copyToTexture( TexturePtr& target );
264 
271  virtual void loadImage( const Image &img );
272 
283  virtual void loadRawData( DataStreamPtr& stream,
284  ushort uWidth, ushort uHeight, PixelFormat eFormat);
285 
291  virtual void _loadImages( const ConstImagePtrList& images );
292 
294  virtual PixelFormat getFormat() const
295  {
296  return mFormat;
297  }
298 
300  virtual PixelFormat getDesiredFormat(void) const
301  {
302  return mDesiredFormat;
303  }
304 
308  virtual PixelFormat getSrcFormat(void) const
309  {
310  return mSrcFormat;
311  }
312 
314  virtual void setFormat(PixelFormat pf);
315 
317  virtual bool hasAlpha(void) const;
318 
324  virtual void setDesiredIntegerBitDepth(ushort bits);
325 
328  virtual ushort getDesiredIntegerBitDepth(void) const;
329 
335  virtual void setDesiredFloatBitDepth(ushort bits);
336 
339  virtual ushort getDesiredFloatBitDepth(void) const;
340 
343  virtual void setDesiredBitDepths(ushort integerBits, ushort floatBits);
344 
347  virtual void setTreatLuminanceAsAlpha(bool asAlpha);
348 
351  virtual bool getTreatLuminanceAsAlpha(void) const;
352 
356  virtual size_t getNumFaces() const;
357 
370  virtual HardwarePixelBufferSharedPtr getBuffer(size_t face=0, size_t mipmap=0) = 0;
371 
372 
377  virtual void convertToImage(Image& destImage, bool includeMipMaps = false);
378 
384  virtual void getCustomAttribute(const String& name, void* pData) {}
385 
386 
387 
388  protected:
392 
396  float mGamma;
397  bool mHwGamma;
400 
403  int mUsage;
404 
406  uint32 mSrcWidth, mSrcHeight, mSrcDepth;
407 
409  unsigned short mDesiredIntegerBitDepth;
410  unsigned short mDesiredFloatBitDepth;
412 
414 
416  size_t calculateSize(void) const;
417 
418 
421  virtual void createInternalResourcesImpl(void) = 0;
422 
425  virtual void freeInternalResourcesImpl(void) = 0;
426 
428  void unloadImpl(void);
429 
433  String getSourceFileType() const;
434 
435  };
439 }
440 
441 #include "OgreHeaderSuffix.h"
442 
443 #endif
unsigned char uint8
Definition: OgrePlatform.h:346
TextureType mTextureType
Definition: OgreTexture.h:401
virtual uint32 getSrcWidth(void) const
Returns the width of the original input texture (may differ due to hardware requirements).
Definition: OgreTexture.h:209
This texture will be a render target, i.e.
Definition: OgreTexture.h:60
uint32 mHeight
Definition: OgreTexture.h:389
virtual void getCustomAttribute(const String &name, void *pData)
Retrieve a platform or API-specific piece of information from this texture.
Definition: OgreTexture.h:384
uint8 mNumMipmaps
Definition: OgreTexture.h:394
unsigned int uint32
Definition: OgrePlatform.h:344
TextureMipmap
Enum identifying special mipmap numbers.
Definition: OgreTexture.h:85
#define _OgreExport
Definition: OgrePlatform.h:260
virtual void setGamma(float g)
Sets the gamma adjustment factor applied to this texture on loading the data.
Definition: OgreTexture.h:146
virtual void setDepth(uint32 d)
Set the depth of the texture (only applicable for 3D textures); can only do this before load();...
Definition: OgreTexture.h:226
uint32 mSrcWidth
Definition: OgreTexture.h:406
Combination of HBU_STATIC and HBU_WRITE_ONLY.
virtual PixelFormat getDesiredFormat(void) const
Returns the desired pixel format for the texture surface.
Definition: OgreTexture.h:300
Mipmaps will be automatically generated for this texture.
Definition: OgreTexture.h:57
virtual PixelFormat getSrcFormat(void) const
Returns the pixel format of the original input texture (may differ due to hardware requirements and p...
Definition: OgreTexture.h:308
Indicates the application will never read the contents of the buffer back, it will only ever write da...
PixelFormat mSrcFormat
Bit field, so this can't be TextureUsage.
Definition: OgreTexture.h:405
vector< const Image * >::type ConstImagePtrList
Definition: OgreImage.h:503
Interface describing a manual resource loader.
Definition: OgreResource.h:514
virtual int getUsage() const
Returns the TextureUsage identifier for this Texture.
Definition: OgreTexture.h:230
virtual uint32 getWidth(void) const
Returns the width of the texture.
Definition: OgreTexture.h:197
Combination of HBU_DYNAMIC, HBU_WRITE_ONLY and HBU_DISCARDABLE.
bool mMipmapsHardwareGenerated
Definition: OgreTexture.h:395
unsigned short mDesiredIntegerBitDepth
Definition: OgreTexture.h:409
Indicates the application would like to modify this buffer with the CPU fairly often.
virtual uint32 getHeight(void) const
Returns the height of the texture.
Definition: OgreTexture.h:193
virtual void setFSAA(uint fsaa, const String &fsaaHint)
Set the level of multisample AA to be used if this texture is a rendertarget.
Definition: OgreTexture.h:180
Static buffer which the application rarely modifies once created.
1D texture, used in combination with 1D texture coordinates
Definition: OgreTexture.h:70
uint8 mNumRequestedMipmaps
Definition: OgreTexture.h:393
PixelFormat
The pixel format used for images, textures, and render surfaces.
Enums describing buffer usage; not mutually exclusive.
Definition: OgreTexture.h:50
virtual void setWidth(uint32 w)
Set the width of the texture; can only do this before load();.
Definition: OgreTexture.h:221
virtual ~Texture()
Definition: OgreTexture.h:108
Combination of HBU_DYNAMIC and HBU_WRITE_ONLY.
bool mInternalResourcesCreated
Definition: OgreTexture.h:413
2D non-square texture, used in combination with 2D texture coordinates
Definition: OgreTexture.h:80
virtual uint32 getSrcDepth(void) const
Returns the original depth of the input texture (only applicable for 3D textures).
Definition: OgreTexture.h:213
virtual uint getFSAA() const
Get the level of multisample AA to be used if this texture is a rendertarget.
Definition: OgreTexture.h:185
Shared pointer implementation used to share pixel buffers.
virtual bool isHardwareGammaEnabled() const
Gets whether this texture will be set up so that on sampling it, hardware gamma correction is applied...
Definition: OgreTexture.h:171
Class representing an image file.
Definition: OgreImage.h:61
unsigned short ushort
virtual void setUsage(int u)
Sets the TextureUsage identifier for this Texture; only useful before load()
Definition: OgreTexture.h:242
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:79
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
virtual uint32 getDepth(void) const
Returns the depth of the texture (only applicable for 3D textures).
Definition: OgreTexture.h:201
bool mTreatLuminanceAsAlpha
Definition: OgreTexture.h:411
virtual void setHeight(uint32 h)
Set the height of the texture; can only do this before load();.
Definition: OgreTexture.h:217
virtual uint8 getNumMipmaps(void) const
Gets the number of mipmaps to be used for this texture.
Definition: OgreTexture.h:120
virtual void setTextureType(TextureType ttype)
Sets the type of texture; can only be changed before load()
Definition: OgreTexture.h:112
virtual void setHardwareGammaEnabled(bool enabled)
Sets whether this texture will be set up so that on sampling it, hardware gamma correction is applied...
Definition: OgreTexture.h:166
virtual float getGamma(void) const
Returns the gamma adjustment factor applied to this texture on loading.
Definition: OgreTexture.h:136
TextureType
Enum identifying the texture type.
Definition: OgreTexture.h:67
Defines a generic resource handler.
unsigned short mDesiredFloatBitDepth
Definition: OgreTexture.h:410
2D texture, used in combination with 2D texture coordinates (default)
Definition: OgreTexture.h:72
PixelFormat mDesiredFormat
Definition: OgreTexture.h:408
_StringBase String
Use TextureManager default.
Definition: OgreTexture.h:90
virtual const String & getFSAAHint() const
Get the multisample AA hint if this texture is a rendertarget.
Definition: OgreTexture.h:189
PixelFormat mFormat
Definition: OgreTexture.h:402
Default to automatic mipmap generation static textures.
Definition: OgreTexture.h:62
3D volume texture, used in combination with 3D texture coordinates
Definition: OgreTexture.h:74
virtual bool getMipmapsHardwareGenerated(void) const
Are mipmaps hardware generated?
Definition: OgreTexture.h:132
Generate mipmaps up to 1x1.
Definition: OgreTexture.h:88
Abstract class representing a Texture resource.
Definition: OgreTexture.h:102
virtual PixelFormat getFormat() const
Returns the pixel format for the texture surface.
Definition: OgreTexture.h:294
2D texture array
Definition: OgreTexture.h:78
String mFSAAHint
Definition: OgreTexture.h:399
3D cube map, used in combination with 3D texture coordinates
Definition: OgreTexture.h:76
virtual uint32 getSrcHeight(void) const
Returns the height of the original input texture (may differ due to hardware requirements).
Definition: OgreTexture.h:205
unsigned int uint
virtual TextureType getTextureType(void) const
Gets the type of texture.
Definition: OgreTexture.h:116
virtual void setNumMipmaps(uint8 num)
Sets the number of mipmaps to be used for this texture.
Definition: OgreTexture.h:126
TextureUsage
Enum identifying the texture usage.
Definition: OgreTexture.h:47