revamped resource system

This commit is contained in:
2026-05-02 21:24:21 -04:00
parent f9010eea81
commit 782bbcbadc
16 changed files with 374 additions and 177 deletions

View File

@@ -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; }