# class hiro::draw::RasterRenderer

## Overview

Raster image which can have individual pixels set. More…

    #include <RasterRenderer.h>

    class RasterRenderer: public hiro::draw::ImageRenderer {
    public:
        // methods

        virtual glm::uvec2 GetResolution() const;
        void SetResolution(const glm::uvec2& resolution, const cogs::Color3b& clearcolor = cogs::color::BLACK);
        const cogs::Color3b& GetPixel(size_t x, size_t y) const;
        void SetPixel(size_t x, size_t y, const cogs::Color3b& color);
        void Clear(const cogs::Color3b& color = cogs::color::BLACK);
        void SyncRastersIfNeeded();

    protected:
        // methods

        virtual void Render2D(const std::string& program);
        virtual bool IsCompatibileWithStyle(const hiro::draw::Style* style);
    };

### Inherited Members

    public:
        // methods

        virtual bool IsCompatibileWithStyle(const hiro::draw::Style* style) = 0;
        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 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;
        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();

## Detailed Documentation

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

### Methods

    virtual glm::uvec2 GetResolution() const

Sets current raster dimensions.

    void SetResolution(const glm::uvec2& resolution, const cogs::Color3b& clearcolor = cogs::color::BLACK)

Sets the raster dimensions and clear it to the clearcolor.

    const cogs::Color3b& GetPixel(size_t x, size_t y) const

Gets the pixel at given pixel coordinates.

    void SetPixel(size_t x, size_t y, const cogs::Color3b& color)

Sets a pixel in a working buffer at a given position to the given color.

    void Clear(const cogs::Color3b& color = cogs::color::BLACK)

Clears the working pixel buffer to the defined color.

    void SyncRastersIfNeeded()

When sync flag is set, copies data from working to display raster and resets the flag.

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

Describes rendering behavior in 2D rendering pass.

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

Test whether specified style is compatible with object.