Objects::Components::Texture2D

Textures in Unified Engine

The Unified Engine offers efficient handling of textures, combining multiple images into one to reduce the number of draw calls in a graphics engine. This is achieved through the use of a texture atlas. The engine also provides individual 2D texture handling, allowing users to manage and utilize individual images.

Texture UVs and Identifiers

Utility structures that help in defining and tracking textures within the atlas.

struct TextureUVs{
    glm::vec2 UV[4];
};

struct Atlas_Space_Identifier
{
    uint32_t x;
    uint32_t y;
    uint32_t w;
    uint32_t h;
};

struct Atlas_Texture_Identifier
{
    uint32_t x;
    uint32_t y;
    uint32_t w;
    uint32_t h;
    Texture2D* Texture;
};

struct Atlas_Image_Location
{
    glm::ivec2 pos;
    GLuint Dest;
    int index;
};

Texture Atlas

A TextureAtlas class represents a collection of textures, minimizing the need for multiple texture binds when rendering.

class TextureAtlas{
    friend Texture2D;
    ...
    TextureAtlas();
    ~TextureAtlas();

    int AddImage(Texture2D* image);
    int RemoveImage(Texture2D* image);
    int Toggle(Texture2D* image);
};
extern TextureAtlas* __GLOBAL_ATLAS;

Texture2D

The Texture2D class provides functionality to manage individual 2D textures. These textures can be loaded from file paths or directly from data.

class Texture2D{
    friend TextureAtlas;
    ...
    Texture2D(std::string FilePath);
    Texture2D(uint8_t* Data, int width, int height);
    ~Texture2D();

    int UpdateTeture(std::string FilePath);
    int Bind();
    int Unbind();
    void operator=(TextureAtlas* Atlas);
};

Last updated