Program Listing for File Texture.hpp

Return to documentation for file (gui/Demeter/Renderer/Texture.hpp)

#pragma once

#include <memory>

#include "SDL2.hpp"

struct Texture {
private:
  std::unique_ptr<SDL_Surface> surface = nullptr;
  GLenum format;
  GLuint texture = 0;

  void GenGLTexture();

public:
  Texture() = default;
  Texture(const Texture &) = delete;
  Texture &operator=(const Texture &) = delete;
  ~Texture();

  bool Init(SDL2 &sdl, const std::string &path);

  [[nodiscard]] GLuint GetGL() const
  {
    return texture;
  }

  [[nodiscard]] GLsizei GetWidth() const
  {
    return surface->w;
  }

  [[nodiscard]] GLsizei GetHeight() const
  {
    return surface->h;
  }

  [[nodiscard]] const void *GetPixels() const
  {
    return surface->pixels;
  }

  [[nodiscard]] GLenum GetFormat() const
  {
    return format;
  }
};