ITexture



Describes texture(image). It is a renderer resource and could be used only when renderer is defined. It means it could be used only when owner of the texture belongs to the form. It couldn't be used to draw on the form whose renderer is different. It shouldn't be used by control when control was removed from form. If you want store images without any restrictions, use Image instead(then, you can create texture from it and draw the texture with help of renderer).

You can find more information in comments below.

class ITexture : public virtual IReleasable
{
public:
    class IData : public virtual IReleasable
    {
    protected:
        int m_iLevel;
        int m_iWidth;
        int m_iHeight;
        bool m_bPrecomputed;
    public:
        const int &Level;
        const int &Width;
        const int &Height;
        const bool &Precomputed;

        virtual Color getColor(const int x, const int y) const = 0;
        virtual void getColor(const int x, const int y, unsigned char &red, unsigned char &green, unsigned char &blue, unsigned char &alpha) = 0;
        virtual void getColor(const int x, const int y, float &red, float &green, float &blue, float &alpha) = 0;
        virtual float getDepth(const int x, const int y) const = 0;
        virtual unsigned char getStencil(const int x, const int y) const = 0;
        virtual unsigned char *getData() = 0;

        virtual void setColor(const int x, const int y, const Color &color) = 0;
        virtual void setColor(const int x, const int y, const float red, const float green, const float blue, const float alpha) = 0;
        virtual void setDepth(const int x, const int y, const float value) = 0;
        virtual void setStencil(const int x, const int y, const unsigned char value) = 0;
    };
protected:
    bool m_bCreated;
    PlatformHandle m_hHandle;
    String m_sFilename;
    TextureFormat m_eFormat;
    int m_iRequiredLevelCount;
    int m_iActualLevelCount;
    bool m_bPrecomputed;
    nitisa::Rect m_sRect;
    RectF m_sRectf;
    nitisa::Rect m_sInvalidRect;
    TextureMinFilter m_eMinFilter;
    TextureMagFilter m_eMagFilter;
    TextureDepthStencilMode m_eDepthStencilMode;
    int m_iBaseLevel;
    float m_fMinLOD;
    float m_fMaxLOD;
    TextureWrap m_eWrapS;
    TextureWrap m_eWrapT;
    TextureWrap m_eWrapR;
    Color m_sBorderColor;
    TextureCompareMode m_eCompareMode;
    TextureCompareFunction m_eCompareFunction;
    float m_fLODBias;
    int m_iMaxLevel;
    TextureSwizzle m_eSwizzleR;
    TextureSwizzle m_eSwizzleG;
    TextureSwizzle m_eSwizzleB;
    TextureSwizzle m_eSwizzleA;
public:
    bool const &Created;
    PlatformHandle const &Handle;
    String const &Filename;
    TextureFormat const &Format;
    int const &RequiredLevelCount; // How much layers texture should have. 0 - maximum allowed. If specified to big value, maximum allowed level count will be created 
    int const &ActualLevelCount; // How many levels texture really has 
    bool const &Precomputed; // Whether color values are multiplied by alpha(for RGBA textures only). Used to facilitate blending 
    int const &Width;
    float const &Widthf;
    int const &Height;
    float const &Heightf;
    Point const &Size;
    PointF const &Sizef;
    nitisa::Rect const &Rect;
    RectF const &Rectf;
    nitisa::Rect const &InvalidRect;
    TextureMinFilter const &MinFilter;
    TextureMagFilter const &MagFilter;
    TextureDepthStencilMode const &DepthStencilMode;
    int const &BaseLevel; // Starting level to generate mipmaps 
    float const &MinLOD;
    float const &MaxLOD;
    TextureWrap const &WrapS;
    TextureWrap const &WrapT;
    TextureWrap const &WrapR;
    Color const &BorderColor;
    TextureCompareMode const &CompareMode;
    TextureCompareFunction const &CompareFunction;
    float const &LODBias;
    int const &MaxLevel; // Max level to generate mipmaps 
    TextureSwizzle const &SwizzleR;
    TextureSwizzle const &SwizzleG;
    TextureSwizzle const &SwizzleB;
    TextureSwizzle const &SwizzleA;

    virtual bool isValid() const = 0; // Return true only if invalid rect value is invalid 

    virtual bool setFormat(const TextureFormat value) = 0;
    virtual bool setRequiredLevelCount(const int value) = 0;
    virtual bool setSize(const int width, const int height) = 0; // Resize 
    virtual bool setValid(const bool value) = 0;
    virtual bool setInvalidRect(const nitisa::Rect &value) = 0;
    virtual bool setDepthStencilMode(const TextureDepthStencilMode value) = 0;
    virtual bool setBaseLevel(const int value) = 0;
    virtual bool setMinFilter(const TextureMinFilter value) = 0; // Set minifying mode 
    virtual bool setMagFilter(const TextureMagFilter value) = 0; // Set magnification mode 
    virtual bool setMinLOD(const float value, const float relative_tolerance = ntl::RelativeTolerance<float>) = 0;
    virtual bool setMaxLOD(const float value, const float relative_tolerance = ntl::RelativeTolerance<float>) = 0;
    virtual bool setWrapS(const TextureWrap value) = 0;
    virtual bool setWrapT(const TextureWrap value) = 0;
    virtual bool setWrapR(const TextureWrap value) = 0;
    virtual bool setBorderColor(const Color &value) = 0;
    virtual bool setCompareMode(const TextureCompareMode value) = 0;
    virtual bool setCompareFunction(const TextureCompareFunction value) = 0;
    virtual bool setLODBias(const float value, const float relative_tolerance = ntl::RelativeTolerance<float>) = 0;
    virtual bool setMaxLevel(const int value) = 0;
    virtual bool setSwizzleR(const TextureSwizzle value) = 0;
    virtual bool setSwizzleG(const TextureSwizzle value) = 0;
    virtual bool setSwizzleB(const TextureSwizzle value) = 0;
    virtual bool setSwizzleA(const TextureSwizzle value) = 0;
    virtual bool setSwizzleRGBA(const TextureSwizzle value) = 0;

    virtual IData *Lock(const TextureFormat format, const int level, const bool read_only) = 0; // Return data which could be accessed directly and changed. DepthStencil format is not allowed, use separately Depth and Stencil instead 
};
Namespace: nitisa
Include: Nitisa/Interfaces/ITexture.h