Image class reference


Widget that displays an image that uses a loaded texture. Example:

 Window window(nullptr, "Image test", { {250,100}, {980,620}, WindowFlags::AutoInvokeRender});
 Texture texture("path.png");
 Image image(&window, {{500, 250}, {0, 0}, ImageFlags::DetectSize}, ImageTheme(), &texture);

Functions documentation

Image(
Window* window,
const Widget2DProps& props = Widget2DProps({ 0,0 }, { 0,0 }, Anchor::Left | Anchor::Bottom | ImageFlags::DetectSize),
const ImageTheme& spriteProps = ImageTheme(),
Texture* texture = nullptr
);

Default constructor. Specifying a nullptr value as a texture is prohibited.


Image(Window* window, const Widget2DProps& props, const Theme& theme, Texture* texture);

Delegating constructor with theme application.


Image(const Image& copy);

Copy constructor.


virtual ~Image();

Destructor.


Image& operator=(Image rhs);

Assignment operator.


friend void swap(Image& first, Image& second) noexcept;

Swap function.


Image* Clone() const override;

Clones the object (usefull while making copy of object that is casted to its base).


const Color& GetColor() const;

Returns the color of the widget.


void SetColor(Color color);

Sets the color of the widget.


const Color& GetBorderColor() const;

Returns the border color of the widget.


void SetBorderColor(Color color);

Sets the border color of the widget.


const Dimension<int>& GetBorderSize() const;

Returns the border size of the widget.


void SetBorderSize(Dimension<int> newBorderSize);

Sets the widget border size.


void SetTexture(Texture* newTexture);

Sets a new texture. New texture should not be nullptr. The widget will recalculate its dimensions according to flags.


const Texture* GetTexture() const;

Returns a pointer to the used texture.


void Render() override;

Renders the widget.


void CreateBuffers();

Creates OpenGL VAO and VBO.


void BindBuffers() override;

Binds the filled-in data arrays that are used in the rendering process.


void Cleanup();

Deletes OpenGL VAO and VBO.


Variables documentation

ImageTheme m_ImageTheme;

Stores information about widget theme.


GLuint m_VertexArrayId;

OpenGL Vertex Array object.


GLuint m_VertexBufferId;

OpenGL Vertex Buffer object.


GLuint m_UvBufferId;

OpenGL UV Buffer object.


Texture* m_UsedTexture;

Texture used by the Image widget.