OgreTexture.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef _Texture_H__
#define _Texture_H__
#include "OgrePrerequisites.h"
#include "OgreHardwareBuffer.h"
#include "OgreResource.h"
#include "OgreImage.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
enum TextureUsage
{
TU_STATIC = HardwareBuffer::HBU_STATIC,
TU_DYNAMIC = HardwareBuffer::HBU_DYNAMIC,
TU_WRITE_ONLY = HardwareBuffer::HBU_WRITE_ONLY,
TU_STATIC_WRITE_ONLY = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
TU_DYNAMIC_WRITE_ONLY = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
TU_DYNAMIC_WRITE_ONLY_DISCARDABLE = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
TU_AUTOMIPMAP = 16,
TU_RENDERTARGET = 32,
TU_DEFAULT = TU_AUTOMIPMAP | TU_STATIC_WRITE_ONLY
};
enum TextureType
{
TEX_TYPE_1D = 1,
TEX_TYPE_2D = 2,
TEX_TYPE_3D = 3,
TEX_TYPE_CUBE_MAP = 4,
TEX_TYPE_2D_ARRAY = 5,
TEX_TYPE_2D_RECT = 6
};
enum TextureMipmap
{
MIP_UNLIMITED = 0x7FFFFFFF,
MIP_DEFAULT = -1
};
class _OgreExport Texture : public Resource
{
public:
Texture(ResourceManager* creator, const String& name, ResourceHandle handle,
const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
virtual ~Texture() {}
virtual void setTextureType(TextureType ttype ) { mTextureType = ttype; }
virtual TextureType getTextureType(void) const { return mTextureType; }
virtual uint8 getNumMipmaps(void) const {return mNumMipmaps;}
virtual void setNumMipmaps(uint8 num) {mNumRequestedMipmaps = mNumMipmaps = num;}
virtual bool getMipmapsHardwareGenerated(void) const { return mMipmapsHardwareGenerated; }
virtual float getGamma(void) const { return mGamma; }
virtual void setGamma(float g) { mGamma = g; }
virtual void setHardwareGammaEnabled(bool enabled) { mHwGamma = enabled; }
virtual bool isHardwareGammaEnabled() const { return mHwGamma; }
virtual void setFSAA(uint fsaa, const String& fsaaHint) { mFSAA = fsaa; mFSAAHint = fsaaHint; }
virtual uint getFSAA() const { return mFSAA; }
virtual const String& getFSAAHint() const { return mFSAAHint; }
virtual uint32 getHeight(void) const { return mHeight; }
virtual uint32 getWidth(void) const { return mWidth; }
virtual uint32 getDepth(void) const { return mDepth; }
virtual uint32 getSrcHeight(void) const { return mSrcHeight; }
virtual uint32 getSrcWidth(void) const { return mSrcWidth; }
virtual uint32 getSrcDepth(void) const { return mSrcDepth; }
virtual void setHeight(uint32 h) { mHeight = mSrcHeight = h; }
virtual void setWidth(uint32 w) { mWidth = mSrcWidth = w; }
virtual void setDepth(uint32 d) { mDepth = mSrcDepth = d; }
virtual int getUsage() const
{
return mUsage;
}
virtual void setUsage(int u) { mUsage = u; }
virtual void createInternalResources(void);
virtual void freeInternalResources(void);
virtual void copyToTexture( TexturePtr& target );
virtual void loadImage( const Image &img );
virtual void loadRawData( DataStreamPtr& stream,
ushort uWidth, ushort uHeight, PixelFormat eFormat);
virtual void _loadImages( const ConstImagePtrList& images );
virtual PixelFormat getFormat() const
{
return mFormat;
}
virtual PixelFormat getDesiredFormat(void) const
{
return mDesiredFormat;
}
virtual PixelFormat getSrcFormat(void) const
{
return mSrcFormat;
}
virtual void setFormat(PixelFormat pf);
virtual bool hasAlpha(void) const;
virtual void setDesiredIntegerBitDepth(ushort bits);
virtual ushort getDesiredIntegerBitDepth(void) const;
virtual void setDesiredFloatBitDepth(ushort bits);
virtual ushort getDesiredFloatBitDepth(void) const;
virtual void setDesiredBitDepths(ushort integerBits, ushort floatBits);
virtual void setTreatLuminanceAsAlpha(bool asAlpha);
virtual bool getTreatLuminanceAsAlpha(void) const;
virtual size_t getNumFaces() const;
virtual HardwarePixelBufferSharedPtr getBuffer(size_t face=0, size_t mipmap=0) = 0;
virtual void convertToImage(Image& destImage, bool includeMipMaps = false);
virtual void getCustomAttribute(const String& name, void* pData) {}
protected:
uint32 mHeight;
uint32 mWidth;
uint32 mDepth;
uint8 mNumRequestedMipmaps;
uint8 mNumMipmaps;
bool mMipmapsHardwareGenerated;
float mGamma;
bool mHwGamma;
uint mFSAA;
String mFSAAHint;
TextureType mTextureType;
PixelFormat mFormat;
int mUsage;
PixelFormat mSrcFormat;
uint32 mSrcWidth, mSrcHeight, mSrcDepth;
PixelFormat mDesiredFormat;
unsigned short mDesiredIntegerBitDepth;
unsigned short mDesiredFloatBitDepth;
bool mTreatLuminanceAsAlpha;
bool mInternalResourcesCreated;
size_t calculateSize(void) const;
virtual void createInternalResourcesImpl(void) = 0;
virtual void freeInternalResourcesImpl(void) = 0;
void unloadImpl(void);
String getSourceFileType() const;
};
}
#include "OgreHeaderSuffix.h"
#endif
Ogre::Texture::mUsage
int mUsage
Definition: OgreTexture.h:403
Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY
Combination of HBU_STATIC and HBU_WRITE_ONLY.
Definition: OgreHardwareBuffer.h:108
Ogre::Texture::getUsage
virtual int getUsage() const
Returns the TextureUsage identifier for this Texture.
Definition: OgreTexture.h:230
Ogre::Texture::~Texture
virtual ~Texture()
Definition: OgreTexture.h:108
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Texture::mSrcWidth
uint32 mSrcWidth
Definition: OgreTexture.h:406
Ogre::Texture::getSrcFormat
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
Ogre::uint
unsigned int uint
Definition: OgrePrerequisites.h:114
Ogre::TU_AUTOMIPMAP
Mipmaps will be automatically generated for this texture.
Definition: OgreTexture.h:57
OgreResource.h
Ogre::Texture::mNumRequestedMipmaps
uint8 mNumRequestedMipmaps
Definition: OgreTexture.h:393
OgreImage.h
Ogre::Texture::mDesiredFormat
PixelFormat mDesiredFormat
Definition: OgreTexture.h:408
Ogre::TU_WRITE_ONLY
Definition: OgreTexture.h:52
Ogre::Texture::getFormat
virtual PixelFormat getFormat() const
Returns the pixel format for the texture surface.
Definition: OgreTexture.h:294
Ogre::Texture::setNumMipmaps
virtual void setNumMipmaps(uint8 num)
Sets the number of mipmaps to be used for this texture.
Definition: OgreTexture.h:126
Ogre::HardwareBuffer::HBU_STATIC
Static buffer which the application rarely modifies once created.
Definition: OgreHardwareBuffer.h:84
Ogre::HardwareBuffer::HBU_WRITE_ONLY
Indicates the application will never read the contents of the buffer back, it will only ever write da...
Definition: OgreHardwareBuffer.h:97
Ogre::TEX_TYPE_2D
2D texture, used in combination with 2D texture coordinates (default)
Definition: OgreTexture.h:72
Ogre::TEX_TYPE_2D_ARRAY
2D texture array
Definition: OgreTexture.h:78
Ogre::Texture::mDepth
uint32 mDepth
Definition: OgreTexture.h:391
Ogre::TEX_TYPE_2D_RECT
2D non-square texture, used in combination with 2D texture coordinates
Definition: OgreTexture.h:80
Ogre::HardwareBuffer::HBU_DYNAMIC
Indicates the application would like to modify this buffer with the CPU fairly often.
Definition: OgreHardwareBuffer.h:90
Ogre::PixelFormat
PixelFormat
The pixel format used for images, textures, and render surfaces.
Definition: OgrePixelFormat.h:43
Ogre::Resource
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:79
Ogre::Texture::getDesiredFormat
virtual PixelFormat getDesiredFormat(void) const
Returns the desired pixel format for the texture surface.
Definition: OgreTexture.h:300
Ogre::ManualResourceLoader
Interface describing a manual resource loader.
Definition: OgreResource.h:514
Ogre::Texture
Abstract class representing a Texture resource.
Definition: OgreTexture.h:102
Ogre::TU_STATIC
Enums describing buffer usage; not mutually exclusive.
Definition: OgreTexture.h:50
Ogre::ResourceHandle
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
Ogre::Texture::getNumMipmaps
virtual uint8 getNumMipmaps(void) const
Gets the number of mipmaps to be used for this texture.
Definition: OgreTexture.h:120
Ogre::TextureUsage
TextureUsage
Enum identifying the texture usage.
Definition: OgreTexture.h:47
Ogre::Texture::mFSAA
uint mFSAA
Definition: OgreTexture.h:398
Ogre::Texture::getFSAAHint
virtual const String & getFSAAHint() const
Get the multisample AA hint if this texture is a rendertarget.
Definition: OgreTexture.h:189
Ogre::Texture::setGamma
virtual void setGamma(float g)
Sets the gamma adjustment factor applied to this texture on loading the data.
Definition: OgreTexture.h:146
Ogre::MIP_UNLIMITED
Generate mipmaps up to 1x1.
Definition: OgreTexture.h:88
Ogre::Texture::mHwGamma
bool mHwGamma
Definition: OgreTexture.h:397
Ogre::Texture::mSrcFormat
PixelFormat mSrcFormat
Bit field, so this can&#39;t be TextureUsage.
Definition: OgreTexture.h:405
Ogre::TextureMipmap
TextureMipmap
Enum identifying special mipmap numbers.
Definition: OgreTexture.h:85
Ogre::Texture::getGamma
virtual float getGamma(void) const
Returns the gamma adjustment factor applied to this texture on loading.
Definition: OgreTexture.h:136
Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE
Combination of HBU_DYNAMIC, HBU_WRITE_ONLY and HBU_DISCARDABLE.
Definition: OgreHardwareBuffer.h:116
Ogre::Texture::getSrcWidth
virtual uint32 getSrcWidth(void) const
Returns the width of the original input texture (may differ due to hardware requirements).
Definition: OgreTexture.h:209
OgrePrerequisites.h
Ogre::TU_DEFAULT
Default to automatic mipmap generation static textures.
Definition: OgreTexture.h:62
Ogre::TEX_TYPE_3D
3D volume texture, used in combination with 3D texture coordinates
Definition: OgreTexture.h:74
Ogre::Texture::getSrcDepth
virtual uint32 getSrcDepth(void) const
Returns the original depth of the input texture (only applicable for 3D textures).
Definition: OgreTexture.h:213
Ogre::Texture::mWidth
uint32 mWidth
Definition: OgreTexture.h:390
Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY
Combination of HBU_DYNAMIC and HBU_WRITE_ONLY.
Definition: OgreHardwareBuffer.h:114
Ogre::Texture::getHeight
virtual uint32 getHeight(void) const
Returns the height of the texture.
Definition: OgreTexture.h:193
Ogre::Texture::mFSAAHint
String mFSAAHint
Definition: OgreTexture.h:399
Ogre::uint8
unsigned char uint8
Definition: OgrePlatform.h:361
Ogre::TextureType
TextureType
Enum identifying the texture type.
Definition: OgreTexture.h:67
Ogre::TU_STATIC_WRITE_ONLY
Definition: OgreTexture.h:53
Ogre::Texture::setHeight
virtual void setHeight(uint32 h)
Set the height of the texture; can only do this before load();.
Definition: OgreTexture.h:217
Ogre::Texture::isHardwareGammaEnabled
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
Ogre::TU_DYNAMIC
Definition: OgreTexture.h:51
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::HardwarePixelBufferSharedPtr
Shared pointer implementation used to share pixel buffers.
Definition: OgreHardwarePixelBuffer.h:193
Ogre::Texture::mMipmapsHardwareGenerated
bool mMipmapsHardwareGenerated
Definition: OgreTexture.h:395
Ogre::Texture::getWidth
virtual uint32 getWidth(void) const
Returns the width of the texture.
Definition: OgreTexture.h:197
Ogre::TEX_TYPE_1D
1D texture, used in combination with 1D texture coordinates
Definition: OgreTexture.h:70
Ogre::Texture::getTextureType
virtual TextureType getTextureType(void) const
Gets the type of texture.
Definition: OgreTexture.h:116
Ogre::Texture::mNumMipmaps
uint8 mNumMipmaps
Definition: OgreTexture.h:394
Ogre::Texture::mDesiredIntegerBitDepth
unsigned short mDesiredIntegerBitDepth
Definition: OgreTexture.h:409
OgreHeaderSuffix.h
Ogre::Texture::setHardwareGammaEnabled
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
Ogre::Texture::setTextureType
virtual void setTextureType(TextureType ttype)
Sets the type of texture; can only be changed before load()
Definition: OgreTexture.h:112
Ogre::TU_RENDERTARGET
This texture will be a render target, i.e.
Definition: OgreTexture.h:60
Ogre::Texture::getCustomAttribute
virtual void getCustomAttribute(const String &name, void *pData)
Retrieve a platform or API-specific piece of information from this texture.
Definition: OgreTexture.h:384
Ogre::ResourceManager
Defines a generic resource handler.
Definition: OgreResourceManager.h:122
Ogre::TU_DYNAMIC_WRITE_ONLY
Definition: OgreTexture.h:54
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::Image
Class representing an image file.
Definition: OgreImage.h:61
Ogre
Definition: OgreAndroidLogListener.h:34
OgreHardwareBuffer.h
Ogre::Texture::mDesiredFloatBitDepth
unsigned short mDesiredFloatBitDepth
Definition: OgreTexture.h:410
Ogre::Texture::mHeight
uint32 mHeight
Definition: OgreTexture.h:389
Ogre::SharedPtr< Texture >
OgreHeaderPrefix.h
Ogre::Texture::setDepth
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
Ogre::ConstImagePtrList
vector< const Image * >::type ConstImagePtrList
Definition: OgreImage.h:503
Ogre::Texture::setWidth
virtual void setWidth(uint32 w)
Set the width of the texture; can only do this before load();.
Definition: OgreTexture.h:221
Ogre::Texture::mTextureType
TextureType mTextureType
Definition: OgreTexture.h:401
Ogre::ushort
unsigned short ushort
Definition: OgrePrerequisites.h:113
Ogre::Texture::setFSAA
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
Ogre::MIP_DEFAULT
Use TextureManager default.
Definition: OgreTexture.h:90
Ogre::Texture::mInternalResourcesCreated
bool mInternalResourcesCreated
Definition: OgreTexture.h:413
Ogre::Texture::getDepth
virtual uint32 getDepth(void) const
Returns the depth of the texture (only applicable for 3D textures).
Definition: OgreTexture.h:201
Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE
Definition: OgreTexture.h:55
Ogre::TEX_TYPE_CUBE_MAP
3D cube map, used in combination with 3D texture coordinates
Definition: OgreTexture.h:76
Ogre::Texture::mFormat
PixelFormat mFormat
Definition: OgreTexture.h:402
Ogre::Texture::getSrcHeight
virtual uint32 getSrcHeight(void) const
Returns the height of the original input texture (may differ due to hardware requirements).
Definition: OgreTexture.h:205
Ogre::Texture::mGamma
float mGamma
Definition: OgreTexture.h:396
Ogre::Texture::getFSAA
virtual uint getFSAA() const
Get the level of multisample AA to be used if this texture is a rendertarget.
Definition: OgreTexture.h:185
Ogre::Texture::getMipmapsHardwareGenerated
virtual bool getMipmapsHardwareGenerated(void) const
Are mipmaps hardware generated?
Definition: OgreTexture.h:132
Ogre::Texture::mTreatLuminanceAsAlpha
bool mTreatLuminanceAsAlpha
Definition: OgreTexture.h:411
Ogre::Texture::setUsage
virtual void setUsage(int u)
Sets the TextureUsage identifier for this Texture; only useful before load()
Definition: OgreTexture.h:242

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.