# struct hiro::draw::GeometryStyle

## Overview

Stylization of the rendered geometry. More…

    #include <GeometryRenderer.h>

    struct GeometryStyle: public hiro::draw::Style {
        // enums

        enum PresetType;
        enum RenderMode;

        // fields

        hiro::draw::GeometryStyle::RenderMode render_mode = hiro::draw::GeometryStyle::RenderMode::faces;
        hiro::shader::Material material;
        bool back_face_culling { false };
        float point_size { 10.0f };
        hiro::draw::ColorSource color_source { hiro::draw::ColorSource::material };
        glw::PTexture2D albedo_texture { nullptr };
        hiro::draw::FacesStyle::NormalSource normal_source { hiro::draw::FacesStyle::NormalSource::flat_normals };
        glw::PTexture2D normal_texture { nullptr };
        bool display_normals { false };
        cogs::Color3f normal_color { cogs::color::BLACK };
        float normal_length { 0.1f };
        cogs::Color3f edge_color { cogs::color::BLACK };
        float edge_width { 1.0f };
        bool use_matcap { false };
        glw::PTexture2D matcap_sampler { nullptr };
        uint32_t object_id { 0u };

        // methods

        static hiro::draw::GeometryStyle GetPreset(hiro::draw::GeometryStyle::PresetType type);
        virtual bool ReadFromStream(std::istream& str);
        virtual void WriteToStream(std::ostream& str);
    };

### Inherited Members

    public:
        // fields

        bool visible = true;
        cogs::Transform transform;

        // methods

        virtual bool ReadFromStream(std::istream& str);
        virtual void WriteToStream(std::ostream& str);

    protected:
        // methods

        bool ReadVersion(std::istream& str, const uint32_t expected_version);

## Detailed Documentation

Stylization of the rendered geometry.

### Fields

    hiro::draw::GeometryStyle::RenderMode render_mode = hiro::draw::GeometryStyle::RenderMode::faces

Mode currently used for rendering geometry.

    hiro::shader::Material material

Material setting for the faces or points (depending on a selected render mode).

    bool back_face_culling { false }

When enabled, faces and edges with normal vector turned away from the camera are hidden.

    float point_size { 10.0f }

Size of point in screen pixels. Used only for render modes that include points.

    hiro::draw::ColorSource color_source { hiro::draw::ColorSource::material }

Color source used to colorize faces and points.

    glw::PTexture2D albedo_texture { nullptr }

Albedo texture. To use, set color source to ColorSource::albedo_map.

    hiro::draw::FacesStyle::NormalSource normal_source { hiro::draw::FacesStyle::NormalSource::flat_normals }

Normal source used to calculate the lighting.

    glw::PTexture2D normal_texture { nullptr }

Normal texture. To use, set normal source to NormalSource::normal_map.

    bool display_normals { false }

When enabled, normal vector for every point is rendered.

    cogs::Color3f normal_color { cogs::color::BLACK }

Color of normal vector tips. Used only when normals are displayed.

    float normal_length { 0.1f }

Length of normal vectors. Used only when normals are displayed.

    cogs::Color3f edge_color { cogs::color::BLACK }

Color of the edges. Used only for render modes that include edges.

    float edge_width { 1.0f }

Width of the edges. Used only for render modes that include edges.

    bool use_matcap { false }

When enabled, color and lighting is picked from matcap sampler texture.

    glw::PTexture2D matcap_sampler { nullptr }

Matcap sampler. Used only when matcap rendering is enabled.

    uint32_t object_id { 0u }

Enables shaders to distinguish between various geometrical objects and instances.

### Methods

    static hiro::draw::GeometryStyle GetPreset(hiro::draw::GeometryStyle::PresetType type)

Creates a new geometry style from the defined preset.

    virtual bool ReadFromStream(std::istream& str)

Imports state from stream.

    virtual void WriteToStream(std::ostream& str)

Exports state to stream.