OgreTexture.h
Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2013 Torus Knot Software Ltd
00008 
00009 Permission is hereby granted, free of charge, to any person obtaining a copy
00010 of this software and associated documentation files (the "Software"), to deal
00011 in the Software without restriction, including without limitation the rights
00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013 copies of the Software, and to permit persons to whom the Software is
00014 furnished to do so, subject to the following conditions:
00015 
00016 The above copyright notice and this permission notice shall be included in
00017 all copies or substantial portions of the Software.
00018 
00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025 THE SOFTWARE.
00026 -----------------------------------------------------------------------------
00027 */
00028 #ifndef _Texture_H__
00029 #define _Texture_H__
00030 
00031 #include "OgrePrerequisites.h"
00032 #include "OgreHardwareBuffer.h"
00033 #include "OgreResource.h"
00034 #include "OgreImage.h"
00035 #include "OgreHeaderPrefix.h"
00036 
00037 namespace Ogre {
00038 
00047     enum TextureUsage
00048     {
00050         TU_STATIC = HardwareBuffer::HBU_STATIC,
00051         TU_DYNAMIC = HardwareBuffer::HBU_DYNAMIC,
00052         TU_WRITE_ONLY = HardwareBuffer::HBU_WRITE_ONLY,
00053         TU_STATIC_WRITE_ONLY = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00054         TU_DYNAMIC_WRITE_ONLY = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
00055         TU_DYNAMIC_WRITE_ONLY_DISCARDABLE = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
00057         TU_AUTOMIPMAP = 16,
00060         TU_RENDERTARGET = 32,
00062         TU_DEFAULT = TU_AUTOMIPMAP | TU_STATIC_WRITE_ONLY
00063     };
00064 
00067     enum TextureType
00068     {
00070         TEX_TYPE_1D = 1,
00072         TEX_TYPE_2D = 2,
00074         TEX_TYPE_3D = 3,
00076         TEX_TYPE_CUBE_MAP = 4,
00078         TEX_TYPE_2D_ARRAY = 5,
00080         TEX_TYPE_2D_RECT = 6
00081     };
00082 
00085     enum TextureMipmap
00086     {
00088         MIP_UNLIMITED = 0x7FFFFFFF,
00090         MIP_DEFAULT = -1
00091     };
00092 
00102     class _OgreExport Texture : public Resource
00103     {
00104     public:
00105         Texture(ResourceManager* creator, const String& name, ResourceHandle handle,
00106             const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
00107 
00108         virtual ~Texture() {}
00109         
00112         virtual void setTextureType(TextureType ttype ) { mTextureType = ttype; }
00113 
00116         virtual TextureType getTextureType(void) const { return mTextureType; }
00117 
00120         virtual uint8 getNumMipmaps(void) const {return mNumMipmaps;}
00121 
00126         virtual void setNumMipmaps(uint8 num) {mNumRequestedMipmaps = mNumMipmaps = num;}
00127 
00132         virtual bool getMipmapsHardwareGenerated(void) const { return mMipmapsHardwareGenerated; }
00133 
00136         virtual float getGamma(void) const { return mGamma; }
00137 
00146         virtual void setGamma(float g) { mGamma = g; }
00147 
00166         virtual void setHardwareGammaEnabled(bool enabled) { mHwGamma = enabled; }
00167 
00171         virtual bool isHardwareGammaEnabled() const { return mHwGamma; }
00172 
00180         virtual void setFSAA(uint fsaa, const String& fsaaHint) { mFSAA = fsaa; mFSAAHint = fsaaHint; }
00181 
00185         virtual uint getFSAA() const { return mFSAA; }
00186 
00189         virtual const String& getFSAAHint() const { return mFSAAHint; }
00190 
00193         virtual uint32 getHeight(void) const { return mHeight; }
00194 
00197         virtual uint32 getWidth(void) const { return mWidth; }
00198 
00201         virtual uint32 getDepth(void) const { return mDepth; }
00202 
00205         virtual uint32 getSrcHeight(void) const { return mSrcHeight; }
00206 
00209         virtual uint32 getSrcWidth(void) const { return mSrcWidth; }
00210 
00213         virtual uint32 getSrcDepth(void) const { return mSrcDepth; }
00214 
00217         virtual void setHeight(uint32 h) { mHeight = mSrcHeight = h; }
00218 
00221         virtual void setWidth(uint32 w) { mWidth = mSrcWidth = w; }
00222 
00226         virtual void setDepth(uint32 d)  { mDepth = mSrcDepth = d; }
00227 
00230         virtual int getUsage() const
00231         {
00232             return mUsage;
00233         }
00234 
00242         virtual void setUsage(int u) { mUsage = u; }
00243 
00255         virtual void createInternalResources(void);
00256 
00259         virtual void freeInternalResources(void);
00260         
00263         virtual void copyToTexture( TexturePtr& target );
00264 
00271         virtual void loadImage( const Image &img );
00272             
00283         virtual void loadRawData( DataStreamPtr& stream, 
00284             ushort uWidth, ushort uHeight, PixelFormat eFormat);
00285 
00291         virtual void _loadImages( const ConstImagePtrList& images );
00292 
00294         virtual PixelFormat getFormat() const
00295         {
00296             return mFormat;
00297         }
00298 
00300         virtual PixelFormat getDesiredFormat(void) const
00301         {
00302             return mDesiredFormat;
00303         }
00304 
00308         virtual PixelFormat getSrcFormat(void) const
00309         {
00310             return mSrcFormat;
00311         }
00312 
00314         virtual void setFormat(PixelFormat pf);
00315 
00317         virtual bool hasAlpha(void) const;
00318 
00324         virtual void setDesiredIntegerBitDepth(ushort bits);
00325 
00328         virtual ushort getDesiredIntegerBitDepth(void) const;
00329 
00335         virtual void setDesiredFloatBitDepth(ushort bits);
00336 
00339         virtual ushort getDesiredFloatBitDepth(void) const;
00340 
00343         virtual void setDesiredBitDepths(ushort integerBits, ushort floatBits);
00344 
00347         virtual void setTreatLuminanceAsAlpha(bool asAlpha);
00348 
00351         virtual bool getTreatLuminanceAsAlpha(void) const;
00352 
00356         virtual size_t getNumFaces() const;
00357 
00370         virtual HardwarePixelBufferSharedPtr getBuffer(size_t face=0, size_t mipmap=0) = 0;
00371 
00372 
00377         virtual void convertToImage(Image& destImage, bool includeMipMaps = false);
00378         
00384         virtual void getCustomAttribute(const String& name, void* pData) {}
00385         
00386 
00387 
00388     protected:
00389         uint32 mHeight;
00390         uint32 mWidth;
00391         uint32 mDepth;
00392 
00393         uint8 mNumRequestedMipmaps;
00394         uint8 mNumMipmaps;
00395         bool mMipmapsHardwareGenerated;
00396         float mGamma;
00397         bool mHwGamma;
00398         uint mFSAA;
00399         String mFSAAHint;
00400 
00401         TextureType mTextureType;
00402         PixelFormat mFormat;
00403         int mUsage; 
00404 
00405         PixelFormat mSrcFormat;
00406         uint32 mSrcWidth, mSrcHeight, mSrcDepth;
00407 
00408         PixelFormat mDesiredFormat;
00409         unsigned short mDesiredIntegerBitDepth;
00410         unsigned short mDesiredFloatBitDepth;
00411         bool mTreatLuminanceAsAlpha;
00412 
00413         bool mInternalResourcesCreated;
00414 
00416         size_t calculateSize(void) const;
00417         
00418 
00421         virtual void createInternalResourcesImpl(void) = 0;
00422 
00425         virtual void freeInternalResourcesImpl(void) = 0;
00426 
00428         void unloadImpl(void);
00429 
00433         String getSourceFileType() const;
00434 
00435     };
00439 }
00440 
00441 #include "OgreHeaderSuffix.h"
00442 
00443 #endif

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:48