OGRE  2.0
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  {
57  TU_AUTOMIPMAP = 0x10,
63  };
64 
68  {
69  TA_READ = 0x01,
70  TA_WRITE = 0x10,
72  };
73 
77  {
90  };
91 
95  {
97  MIP_UNLIMITED = 0x7FFFFFFF,
100  };
101 
111  class _OgreExport Texture : public Resource
112  {
113  public:
114  Texture(ResourceManager* creator, const String& name, ResourceHandle handle,
115  const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
116 
117  virtual ~Texture() {}
118 
121  virtual void setTextureType(TextureType ttype ) { mTextureType = ttype; }
122 
125  virtual TextureType getTextureType(void) const { return mTextureType; }
126 
129  virtual uint8 getNumMipmaps(void) const {return mNumMipmaps;}
130 
135  virtual void setNumMipmaps(uint8 num) {mNumRequestedMipmaps = mNumMipmaps = num;}
136 
141  virtual bool getMipmapsHardwareGenerated(void) const { return mMipmapsHardwareGenerated; }
142 
145  virtual float getGamma(void) const { return mGamma; }
146 
155  virtual void setGamma(float g) { mGamma = g; }
156 
175  virtual void setHardwareGammaEnabled(bool enabled) { mHwGamma = enabled; }
176 
180  virtual bool isHardwareGammaEnabled() const { return mHwGamma; }
181 
190  virtual void setFSAA(uint fsaa, const String& fsaaHint, bool explicitResolve)
191  { mFSAA = fsaa; mFSAAHint = fsaaHint; mFsaaExplicitResolve = explicitResolve; }
192 
196  virtual uint getFSAA() const { return mFSAA; }
197 
200  virtual const String& getFSAAHint() const { return mFSAAHint; }
201 
204  virtual uint32 getHeight(void) const { return mHeight; }
205 
208  virtual uint32 getWidth(void) const { return mWidth; }
209 
212  virtual uint32 getDepth(void) const { return mDepth; }
213 
216  virtual uint32 getSrcHeight(void) const { return mSrcHeight; }
217 
220  virtual uint32 getSrcWidth(void) const { return mSrcWidth; }
221 
224  virtual uint32 getSrcDepth(void) const { return mSrcDepth; }
225 
228  virtual void setHeight(uint32 h) { mHeight = mSrcHeight = h; }
229 
232  virtual void setWidth(uint32 w) { mWidth = mSrcWidth = w; }
233 
237  virtual void setDepth(uint32 d) { mDepth = mSrcDepth = d; }
238 
241  virtual int getUsage() const
242  {
243  return mUsage;
244  }
245 
253  virtual void setUsage(int u) { mUsage = u; }
254 
266  virtual void createInternalResources(void);
267 
270  virtual void freeInternalResources(void);
271 
274  virtual void copyToTexture( TexturePtr& target );
275 
282  virtual void loadImage( const Image &img );
283 
294  virtual void loadRawData( DataStreamPtr& stream,
295  ushort uWidth, ushort uHeight, PixelFormat eFormat);
296 
302  virtual void _loadImages( const ConstImagePtrList& images );
303 
305  virtual PixelFormat getFormat() const
306  {
307  return mFormat;
308  }
309 
311  virtual PixelFormat getDesiredFormat(void) const
312  {
313  return mDesiredFormat;
314  }
315 
319  virtual PixelFormat getSrcFormat(void) const
320  {
321  return mSrcFormat;
322  }
323 
325  virtual void setFormat(PixelFormat pf);
326 
328  virtual bool hasAlpha(void) const;
329 
335  virtual void setDesiredIntegerBitDepth(ushort bits);
336 
339  virtual ushort getDesiredIntegerBitDepth(void) const;
340 
346  virtual void setDesiredFloatBitDepth(ushort bits);
347 
350  virtual ushort getDesiredFloatBitDepth(void) const;
351 
354  virtual void setDesiredBitDepths(ushort integerBits, ushort floatBits);
355 
358  virtual void setTreatLuminanceAsAlpha(bool asAlpha);
359 
362  virtual bool getTreatLuminanceAsAlpha(void) const;
363 
367  virtual size_t getNumFaces() const;
368 
381  virtual HardwarePixelBufferSharedPtr getBuffer(size_t face=0, size_t mipmap=0) = 0;
382 
383 
388  virtual void convertToImage(Image& destImage, bool includeMipMaps = false);
389 
395  virtual void getCustomAttribute(const String& name, void* pData) {}
396 
397 
405  virtual void createShaderAccessPoint(uint bindPoint, TextureAccess access = TA_READ_WRITE,
406  int mipmapLevel = 0, int textureArrayIndex = 0,
407  PixelFormat* format = NULL) {}
408 
409 
410  protected:
414 
418  float mGamma;
419  bool mHwGamma;
423 
426  int mUsage;
427 
429  uint32 mSrcWidth, mSrcHeight, mSrcDepth;
430 
432  unsigned short mDesiredIntegerBitDepth;
433  unsigned short mDesiredFloatBitDepth;
435 
437 
439  size_t calculateSize(void) const;
440 
441 
444  virtual void createInternalResourcesImpl(void) = 0;
445 
448  virtual void freeInternalResourcesImpl(void) = 0;
449 
451  void unloadImpl(void);
452 
456  String getSourceFileType() const;
457 
458  };
462 }
463 
464 #include "OgreHeaderSuffix.h"
465 
466 #endif
unsigned char uint8
Definition: OgrePlatform.h:422
TextureType mTextureType
Definition: OgreTexture.h:424
virtual uint32 getSrcWidth(void) const
Returns the width of the original input texture (may differ due to hardware requirements).
Definition: OgreTexture.h:220
This texture will be a render target, i.e.
Definition: OgreTexture.h:60
uint32 mHeight
Definition: OgreTexture.h:411
virtual void getCustomAttribute(const String &name, void *pData)
Retrieve a platform or API-specific piece of information from this texture.
Definition: OgreTexture.h:395
uint8 mNumMipmaps
Definition: OgreTexture.h:416
unsigned int uint32
Definition: OgrePlatform.h:420
TextureMipmap
Enum identifying special mipmap numbers.
Definition: OgreTexture.h:94
#define _OgreExport
Definition: OgrePlatform.h:255
virtual void setGamma(float g)
Sets the gamma adjustment factor applied to this texture on loading the data.
Definition: OgreTexture.h:155
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:237
uint32 mSrcWidth
Definition: OgreTexture.h:429
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:311
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:319
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:428
vector< const Image * >::type ConstImagePtrList
Definition: OgreImage.h:502
Interface describing a manual resource loader.
Definition: OgreResource.h:498
virtual int getUsage() const
Returns the TextureUsage identifier for this Texture.
Definition: OgreTexture.h:241
virtual uint32 getWidth(void) const
Returns the width of the texture.
Definition: OgreTexture.h:208
Combination of HBU_DYNAMIC, HBU_WRITE_ONLY and HBU_DISCARDABLE.
bool mMipmapsHardwareGenerated
Definition: OgreTexture.h:417
unsigned short mDesiredIntegerBitDepth
Definition: OgreTexture.h:432
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:204
Static buffer which the application rarely modifies once created.
1D texture, used in combination with 1D texture coordinates
Definition: OgreTexture.h:79
uint8 mNumRequestedMipmaps
Definition: OgreTexture.h:415
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:232
virtual ~Texture()
Definition: OgreTexture.h:117
Combination of HBU_DYNAMIC and HBU_WRITE_ONLY.
virtual void setFSAA(uint fsaa, const String &fsaaHint, bool explicitResolve)
Set the level of multisample AA to be used if this texture is a rendertarget.
Definition: OgreTexture.h:190
bool mInternalResourcesCreated
Definition: OgreTexture.h:436
virtual void createShaderAccessPoint(uint bindPoint, TextureAccess access=TA_READ_WRITE, int mipmapLevel=0, int textureArrayIndex=0, PixelFormat *format=NULL)
Enable read and/or write privileges to the texture from shaders.
Definition: OgreTexture.h:405
2D non-square texture, used in combination with 2D texture coordinates
Definition: OgreTexture.h:89
virtual uint32 getSrcDepth(void) const
Returns the original depth of the input texture (only applicable for 3D textures).
Definition: OgreTexture.h:224
virtual uint getFSAA() const
Get the level of multisample AA to be used if this texture is a rendertarget.
Definition: OgreTexture.h:196
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:180
Class representing an image file.
Definition: OgreImage.h:60
unsigned short ushort
virtual void setUsage(int u)
Sets the TextureUsage identifier for this Texture; only useful before load()
Definition: OgreTexture.h:253
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:77
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
virtual uint32 getDepth(void) const
Returns the depth of the texture (only applicable for 3D textures).
Definition: OgreTexture.h:212
TextureAccess
Enum identifying the texture access privilege.
Definition: OgreTexture.h:67
bool mTreatLuminanceAsAlpha
Definition: OgreTexture.h:434
virtual void setHeight(uint32 h)
Set the height of the texture; can only do this before load();.
Definition: OgreTexture.h:228
virtual uint8 getNumMipmaps(void) const
Gets the number of mipmaps to be used for this texture.
Definition: OgreTexture.h:129
virtual void setTextureType(TextureType ttype)
Sets the type of texture; can only be changed before load()
Definition: OgreTexture.h:121
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:175
bool mFsaaExplicitResolve
Definition: OgreTexture.h:422
virtual float getGamma(void) const
Returns the gamma adjustment factor applied to this texture on loading.
Definition: OgreTexture.h:145
TextureType
Enum identifying the texture type.
Definition: OgreTexture.h:76
Defines a generic resource handler.
unsigned short mDesiredFloatBitDepth
Definition: OgreTexture.h:433
2D texture, used in combination with 2D texture coordinates (default)
Definition: OgreTexture.h:81
PixelFormat mDesiredFormat
Definition: OgreTexture.h:431
_StringBase String
Definition: OgreCommon.h:53
Use TextureManager default.
Definition: OgreTexture.h:99
virtual const String & getFSAAHint() const
Get the multisample AA hint if this texture is a rendertarget.
Definition: OgreTexture.h:200
PixelFormat mFormat
Definition: OgreTexture.h:425
Default to automatic mipmap generation static textures.
Definition: OgreTexture.h:62
3D volume texture, used in combination with 3D texture coordinates
Definition: OgreTexture.h:83
virtual bool getMipmapsHardwareGenerated(void) const
Are mipmaps hardware generated?
Definition: OgreTexture.h:141
Generate mipmaps up to 1x1.
Definition: OgreTexture.h:97
Abstract class representing a Texture resource.
Definition: OgreTexture.h:111
virtual PixelFormat getFormat() const
Returns the pixel format for the texture surface.
Definition: OgreTexture.h:305
2D texture array
Definition: OgreTexture.h:87
String mFSAAHint
Definition: OgreTexture.h:421
3D cube map, used in combination with 3D texture coordinates
Definition: OgreTexture.h:85
virtual uint32 getSrcHeight(void) const
Returns the height of the original input texture (may differ due to hardware requirements).
Definition: OgreTexture.h:216
unsigned int uint
virtual TextureType getTextureType(void) const
Gets the type of texture.
Definition: OgreTexture.h:125
virtual void setNumMipmaps(uint8 num)
Sets the number of mipmaps to be used for this texture.
Definition: OgreTexture.h:135
TextureUsage
Enum identifying the texture usage.
Definition: OgreTexture.h:47