Irrlicht 3D Engine: ITexture.h Source File

| Irrlicht 3D Engine |

ITexture.h
Go to the documentation of this file.

    00001 // Copyright (C) 2002-2012 Nikolaus Gebhardt
    00002 // This file is part of the "Irrlicht Engine".
    00003 // For conditions of distribution and use, see copyright notice in irrlicht.h
    00004
    00005 #ifndef __I_TEXTURE_H_INCLUDED__
    00006 #define __I_TEXTURE_H_INCLUDED__
    00007
    00008 #include "IReferenceCounted.h"
    00009 #include "IImage.h"
    00010 #include "dimension2d.h"
    00011 #include "EDriverTypes.h"
    00012 #include "path.h"
    00013 #include "matrix4.h"
    00014
    00015 namespace irr
    00016 {
    00017 namespace video
    00018 {
    00019
    00020
    00022 enum E_TEXTURE_CREATION_FLAG
    00023 {
    00032     ETCF_ALWAYS_16_BIT = 0x00000001,
    00033
    00041     ETCF_ALWAYS_32_BIT = 0x00000002,
    00042
    00049     ETCF_OPTIMIZED_FOR_QUALITY = 0x00000004,
    00050
    00056     ETCF_OPTIMIZED_FOR_SPEED = 0x00000008,
    00057
    00059     ETCF_CREATE_MIP_MAPS = 0x00000010,
    00060
    00062     ETCF_NO_ALPHA_CHANNEL = 0x00000020,
    00063
    00065
    00066     ETCF_ALLOW_NON_POWER_2 = 0x00000040,
    00067
    00070     ETCF_FORCE_32_BIT_DO_NOT_USE = 0x7fffffff
    00071 };
    00072
    00074 enum E_TEXTURE_LOCK_MODE
    00075 {
    00077     ETLM_READ_WRITE = 0,
    00078
    00080
    00081     ETLM_READ_ONLY,
    00082
    00084
    00086     ETLM_WRITE_ONLY
    00087 };
    00088
    00090
    00098 class ITexture : public virtual IReferenceCounted
    00099 {
    00100 public:
    00101
    00103     ITexture(const io::path& name) : NamedPath(name)
    00104     {
    00105     }
    00106
    00108
    00127     virtual void* lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0) = 0;
    00128
    00130
    00132     virtual void unlock() = 0;
    00133
    00135
    00142     virtual const core::dimension2d<u32>& getOriginalSize() const = 0;
    00143
    00145
    00146     virtual const core::dimension2d<u32>& getSize() const = 0;
    00147
    00149
    00153     virtual E_DRIVER_TYPE getDriverType() const = 0;
    00154
    00156
    00157     virtual ECOLOR_FORMAT getColorFormat() const = 0;
    00158
    00160
    00163     virtual u32 getPitch() const = 0;
    00164
    00166
    00167     virtual bool hasMipMaps() const { return false; }
    00168
    00170     virtual bool hasAlpha() const {
    00171         return getColorFormat () == video::ECF_A8R8G8B8 || getColorFormat () == video::ECF_A1R5G5B5;
    00172     }
    00173
    00175
    00181     virtual void regenerateMipMapLevels(void* mipmapData=0) = 0;
    00182
    00184
    00188     virtual bool isRenderTarget() const { return false; }
    00189
    00191     const io::SNamedPath& getName() const { return NamedPath; }
    00192
    00193 protected:
    00194
    00196
    00198     inline E_TEXTURE_CREATION_FLAG getTextureFormatFromFlags(u32 flags)
    00199     {
    00200         if (flags & ETCF_OPTIMIZED_FOR_SPEED)
    00201             return ETCF_OPTIMIZED_FOR_SPEED;
    00202         if (flags & ETCF_ALWAYS_16_BIT)
    00203             return ETCF_ALWAYS_16_BIT;
    00204         if (flags & ETCF_ALWAYS_32_BIT)
    00205             return ETCF_ALWAYS_32_BIT;
    00206         if (flags & ETCF_OPTIMIZED_FOR_QUALITY)
    00207             return ETCF_OPTIMIZED_FOR_QUALITY;
    00208         return ETCF_OPTIMIZED_FOR_SPEED;
    00209     }
    00210
    00211     io::SNamedPath NamedPath;
    00212 };
    00213
    00214
    00215 } // end namespace video
    00216 } // end namespace irr
    00217
    00218 #endif
    00219