Program Listing for File Texture.ixx

Program Listing for File Texture.ixx#

Return to documentation for file (Src/GraphicsEngineOpenGL/scene/texture/Texture.ixx)

module;

#include <glad/glad.h>
#include <stb_image.h>
#include <cstring>

#include <memory>
#include <string>

#include "host_device/GlobalValues.hpp"

export module kataglyphis.opengl.texture;

import kataglyphis.opengl.texture_wrapping_mode;
import kataglyphis.opengl.repeat_mode;
import kataglyphis.opengl.clamp_to_edge_mode;

export class Texture
{
  public:
    Texture();
    Texture(const char *file_loc, std::unique_ptr<TextureWrappingMode> wrapping_mode);

    Texture(const Texture &) = delete;
    Texture &operator=(const Texture &) = delete;
    Texture(Texture &&) = delete;
    Texture &operator=(Texture &&) = delete;

    bool load_texture_without_alpha_channel();
    bool load_texture_with_alpha_channel();

    bool load_SRGB_texture_without_alpha_channel();
    bool load_SRGB_texture_with_alpha_channel();

    std::string get_filename() const;
    GLuint get_id() const;

    void use_texture(unsigned int index) const;
    static void unbind_texture(unsigned int index);

    void clear_texture_context();

    ~Texture();

  private:
    GLuint texture_id;
    int width, height, bit_depth;

    std::unique_ptr<TextureWrappingMode> wrapping_mode;

    std::string file_location;
};