Files
b_engine/src/Texture.h

36 lines
868 B
C
Raw Normal View History

//
// Created by lbmas on 4/29/2026.
//
#ifndef B_ENGINE_TEXTURE_H
#define B_ENGINE_TEXTURE_H
#include <string_view>
#include <string>
2026-05-02 21:24:21 -04:00
#include <glad/gl.h>
class Texture
{
public:
2026-05-02 21:24:21 -04:00
Texture(unsigned int id, std::string_view filePath, int width, int height, int channels)
: id(id), filePath(filePath), width(width), height(height), channels(channels) {}
2026-05-02 21:24:21 -04:00
~Texture() { glDeleteTextures(1, &id); }
2026-05-02 21:24:21 -04:00
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