revamped resource system
This commit is contained in:
@@ -5,21 +5,21 @@
|
||||
#ifndef B_ENGINE_TEXTURE_H
|
||||
#define B_ENGINE_TEXTURE_H
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <string>
|
||||
|
||||
#include <glad/gl.h>
|
||||
|
||||
class Texture
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<Texture> load_from_file(std::string_view filePath);
|
||||
static std::shared_ptr<Texture> load_from_data(unsigned char* data, int width, int height, int channels);
|
||||
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() = default;
|
||||
~Texture();
|
||||
~Texture() { glDeleteTextures(1, &id); }
|
||||
|
||||
void bind(unsigned int slot);
|
||||
void unbind();
|
||||
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; }
|
||||
|
||||
Reference in New Issue
Block a user