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 
        clRepeat, // If coordinates are outside of texture, texture will be repeated 
        clRepeatMirrored // If coordinates are outside of texture, texture will be repeated and mirrored 
    };

    enum MIN_FILTER // Texture minifying filtering mode 
    {
        fminNearest, // Returns the value of the texture element that is nearest (in Manhattan distance) to the specified texture coordinates 
        fminLinear, // Returns the weighted average of the four texture elements that are closest to the specified texture coordinates 
        fminNearestMipmapNearest, // Chooses the mipmap that most closely matches the size of the pixel being textured and uses the fminNearest criterion (the texture element closest to the specified texture coordinates) to produce a texture value 
        fminLinearMipmapNearest, // Chooses the mipmap that most closely matches the size of the pixel being textured and uses the fminLinear criterion (a weighted average of the four texture elements that are closest to the specified texture coordinates) to produce a texture value 
        fminNearestMipmapLinear, // Chooses the two mipmaps that most closely match the size of the pixel being textured and uses the fminNearest criterion (the texture element closest to the specified texture coordinates ) to produce a texture value from each mipmap. The final texture value is a weighted average of those two values 
        fminLinearMipmapLinear // Chooses the two mipmaps that most closely match the size of the pixel being textured and uses the fminLinear criterion (a weighted average of the texture elements that are closest to the specified texture coordinates) to produce a texture value from each mipmap. The final texture value is a weighted average of those two values 
    };

    enum MAG_FILTER // Texture magnification filtering mode 
    {
        fmagNearest, // Returns the value of the texture element that is nearest (in Manhattan distance) to the specified texture coordinates 
        fmagLinear // Returns the weighted average of the texture elements that are closest to the specified texture coordinates 
    };
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 
    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 MIN_FILTER getMinFilter() const = 0; // Return active minifying mode. gminLinear by default. Can be changed temporary by renderer if texture is used as render target 
    virtual MAG_FILTER getMagFilter() const = 0; // Return active magnification mode. gmagLinear by default. Can be changed temporary by renderer if texture is used as render target 

    virtual bool setSize(const int width, const int height) = 0; // Resize 
    virtual bool setClamp(const CLAMP value) = 0; // Set clamp 
    virtual bool setMinFilter(const MIN_FILTER value) = 0; // Set minifying mode 
    virtual bool setMagFilter(const MAG_FILTER value) = 0; // Set magnification mode 

    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 
    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