# class hiro::draw::ImageRenderer

## Overview

Image image which can have individual pixels set. More…

    #include <ImageRenderer.h>

    class ImageRenderer: public hiro::draw::Renderer {
    public:
        // construction

        ImageRenderer();
        ImageRenderer(const glw::PTexture2D& image_texture);
        ImageRenderer(const std::string& image_file);

        // methods

        void SetImage(const glw::PTexture2D& image_texture);
        void LoadImageFile(const std::string& image_file);
        glw::PTexture2D GetTexture() const;
        virtual glm::uvec2 GetResolution() const;
        glm::mat4 GetImageToPixelTransform(const ImageStyle& style, const hiro::draw::ProjectionParams& params) const;
        glm::mat4 GetImageToViewportPixelTransform(const ImageStyle& style, const hiro::draw::ProjectionParams& params) const;

    protected:
        // fields

        glw::PTexture2D texture_buffer_ { nullptr };

        // methods

        virtual void Render2D(const std::string& program);
        virtual bool IsCompatibileWithStyle(const Style* style);
        virtual void LoadRequiredShaderPrograms(glw::ProgramList* programs);
        virtual void FillTextRenderer(hiro::draw::TextRenderer* t_renderer);
        void SetupFiltering();
    };

### Inherited Members

    public:
        // methods

        virtual bool IsCompatibileWithStyle(const hiro::draw::Style* style) = 0;

    protected:
        // methods

        virtual void LoadRequiredShaderPrograms(glw::ProgramList* programs);
        virtual void Render(const std::string& program);
        virtual void OnRenderSimple();
        virtual void Render2D(const std::string& program);
        virtual void OnRenderSimple2D();
        virtual void FillTextRenderer(hiro::draw::TextRenderer* t_renderer);

        template <typename StyleType>
        const StyleType* GetStyle() const;

        const Scene* GetScene() const;

## Detailed Documentation

Image image which can have individual pixels set.

Default resolution is 1x1, the default pixel color is black. If one of the dimensions provided to resolution is 0, nothing is rendered.

Internally the renderer uses two buffers - texture buffer and work buffer. Texture buffer is used for rendering and it is located in the video memory. Work buffer is stored in RAM. When user manipulates with the pixels/resolution, the work buffer is changed and texture buffer invalidated. Before the rendering, if a texture buffer is invalid, the changes from work buffer are automatically introduced to the texture buffer.

### Fields

    glw::PTexture2D texture_buffer_ { nullptr }

Texture buffer for the Image.

### Methods

    virtual glm::uvec2 GetResolution() const

Returns the current Image resolution.

    glm::mat4 GetImageToPixelTransform(const ImageStyle& style, const hiro::draw::ProjectionParams& params) const

Returns transformation from image texels to screen pixels.

    glm::mat4 GetImageToViewportPixelTransform(const ImageStyle& style, const hiro::draw::ProjectionParams& params) const

Returns transformation from image texels to viewport screen pixels.

    virtual void Render2D(const std::string& program)

Describes rendering behavior in 2D rendering pass.

    virtual bool IsCompatibileWithStyle(const Style* style)

Test whether specified style is compatible with object.

    virtual void LoadRequiredShaderPrograms(glw::ProgramList* programs)

Loads shader programs required by this renderer.

    virtual void FillTextRenderer(hiro::draw::TextRenderer* t_renderer)

Override this method to define texts to be rendered.

    void SetupFiltering()

Sets the texture filtering based on the style preference.