39 lines
956 B
C++
39 lines
956 B
C++
//
|
|
// Created by lbmas on 4/29/2026.
|
|
//
|
|
|
|
#ifndef B_ENGINE_TEXTURE_H
|
|
#define B_ENGINE_TEXTURE_H
|
|
|
|
#include <string_view>
|
|
#include <string>
|
|
|
|
#include <glad/gl.h>
|
|
|
|
class Texture
|
|
{
|
|
public:
|
|
Texture(unsigned int id, std::string_view filePath, int width, int height, int channels)
|
|
: id(id), filePath(filePath), width(width), height(height), channels(channels) {}
|
|
|
|
Texture(const Texture&) = delete;
|
|
Texture& operator=(const Texture&) = delete;
|
|
|
|
~Texture() { glDeleteTextures(1, &id); }
|
|
|
|
void bind() const {glBindTexture(GL_TEXTURE_2D, id);}
|
|
static void unbind() {glBindTexture(GL_TEXTURE_2D, 0);}
|
|
|
|
[[nodiscard]] int get_width() const { return width; }
|
|
[[nodiscard]] int get_height() const { return height; }
|
|
[[nodiscard]] int get_channels() const { return channels; }
|
|
private:
|
|
unsigned int id = 0;
|
|
std::string filePath;
|
|
int width = 0;
|
|
int height = 0;
|
|
int channels = 0;
|
|
};
|
|
|
|
|
|
#endif //B_ENGINE_TEXTURE_H
|