class glw::Texture2D — HIRO 0.7.0 documentation

# class glw::Texture2D

## Overview

Two dimensional texture. Used mostly to store color images or results of internal rendering. More…

    #include <Texture.h>

    class Texture2D: public glw::Texture {
    public:
        // construction

        Texture2D(const uint32_t width, const uint32_t height, const gl::GLenum internal_format = gl::GLenum::GL_RGBA8);
        Texture2D(const uint32_t width, const uint32_t height, const uint32_t layer_count, const gl::GLenum internal_format);
        virtual ~Texture2D();

        // methods

        static PTexture2D Create(const uint32_t width, const uint32_t height, const gl::GLenum internal_format = gl::GLenum::GL_RGBA8);
        static PTexture2D CreateLayered(const uint32_t width, const uint32_t height, const uint32_t layer_count, const gl::GLenum internal_format = gl::GLenum::GL_RGBA8);
        static PTexture2D CreateFromFile(const std::string& image_file_name, const bool load_as_float = false);
        uint32_t GetWidth();
        uint32_t GetHeight();
        glm::uvec2 GetResolution();
        uint32_t GetLayerCount();
        void SetData(const gl::GLenum data_format, const gl::GLenum data_type, const void* data_ptr);
        void SetDataLayer(const uint32_t layer, const gl::GLenum data_format, const gl::GLenum data_type, const void* data_ptr);
        bool SaveToFile(const std::string& image_file_name);

    protected:
        // methods

        virtual gl::GLenum GetTarget();
        virtual void ReserveMemory();
    };

### Inherited Members

    public:
        // methods

        void Initialize(const gl::GLenum internal_format);
        void Enable();
        void Disable();
        void Unbind();
        void Bind();
        void Bind(const uint8_t binding_unit);
        gl::GLuint GetID();
        gl::GLenum GetInternalFormat();
        void SetFiltering(const Filtering mag_min);
        virtual void SetFiltering(const Filtering mag, const Filtering min);
        void SetWrapping(const Wrapping wrap_st);
        virtual void SetWrapping(const Wrapping wrap_s, const Wrapping wrap_t);
        virtual void SetParameteri(const gl::GLenum pname, const gl::GLint param);
        void SetParameterfv(const gl::GLenum pname, const gl::GLfloat* param);

    protected:
        // methods

        virtual gl::GLenum GetTarget() = 0;
        virtual void ReserveMemory() = 0;

## Detailed Documentation

Two dimensional texture. Used mostly to store color images or results of internal rendering.

### Construction

    Texture2D(const uint32_t width, const uint32_t height, const gl::GLenum internal_format = gl::GLenum::GL_RGBA8)

Creates a single 2D texture.

    Texture2D(const uint32_t width, const uint32_t height, const uint32_t layer_count, const gl::GLenum internal_format)

Creates array of 2D textures, represented as layers.