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 Bitmap instead(then, you can create texture from it and draw the texture with help of renderer).

In implementaions avoid calculating values on the fly in getWidthf(), getHeightf(), getSize(), getSizef(), getRect(), getRectf() methods. Instead use stored precalculated value which is only calculated when texture size is being changed. Rect and RectF types are the best choise for storing texture size information. For example, the size can be get directly as RightBottom property.

You can find more information in comments below.

class ITexture
{
public:
    enum CLAMP // Clamping types 
    {
        clEdge, // If coordinates are outside of texture, the closest border pixel value will be used 
        clBorder // If coordinates are outside of texture, the border color, which is { 0, 0, 0, 0 }, will be used. Default option 
        // Since 7.0.0 
        clRepeat, // If coordinates are outside of texture, texture will be repeated 
        clRepeatMirrored // If coordinates are outside of texture, texture will be repeated and mirrored 
    };
public:
    virtual int getWidth() const = 0; // Return width 
    virtual int getHeight() const = 0; // Return height 
    virtual Rect getInvalidRect() const = 0; // Return invalid rectangle. Invalid rect means no valid area exists 
    virtual bool isValid() const = 0; // Return true only if invalid rect value is invalid 
    virtual CLAMP getClamp() const = 0; // Return clamp 
    // Since 8.0.0 
    virtual Point getSize() const = 0; // Return size in form of Point 
    virtual Rect getRect() const = 0; // Return rectangle having Left = Top = 0 and Right is equal to width and Bottom is equal to height 
    virtual float getWidthf() const = 0; // Return floating point version of width 
    virtual float getHeightf() const = 0; // Return floating point version of height 
    virtual PointF getSizef() const = 0; // Return floating point version of size 
    virtual RectF getRectf() const = 0; // Return floating point version of rectangle 

    virtual bool setSize(const int width, const int height) = 0; // Resize 
    virtual bool setClamp(const CLAMP value) = 0; // Set clamp 

    virtual void Release() = 0; // Destroy instance 
    virtual ITextureData *Lock(const bool readonly) = 0; // Return data which could be accessed directly and changed 
    virtual void Invalidate() = 0; // Set invalid rect to be equal to entire texture 
    virtual void Invalidate(const Rect &rect) = 0; // Just set invalid rect, no validation. If invalid rect is set, it means the texture becomes valid 
    virtual void Validate() = 0; // Set invalid rect to invalid one 
    // Since 1.3.0 
    virtual bool Activate(const int index) = 0; // Activate texture for rendering. Optional feature, availability depends on renderer. Some indices may be used in renderer drawing operations like drawing gradient and image and another textures could be active after calling those operations. For the list of used indices please refer to particular renderer documentation page 
};
Namespace: nitisa
Include: Nitisa/Interfaces/ITexture.h