57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <frostbite2D/graphics/types.h>
|
|
#include <frostbite2D/types/type_alias.h>
|
|
#include <frostbite2D/base/RefObject.h>
|
|
#include <string>
|
|
#include <memory>
|
|
|
|
namespace frostbite2D {
|
|
|
|
enum class TextureSampling {
|
|
Linear,
|
|
PixelArt
|
|
};
|
|
|
|
class Texture : public RefObject {
|
|
public:
|
|
static Ptr<Texture> loadFromFile(const std::string& path);
|
|
static Ptr<Texture> createFromMemory(const uint8* data, int width, int height, int channels);
|
|
static Ptr<Texture> createEmpty(int width, int height);
|
|
|
|
~Texture();
|
|
|
|
void bind(uint32_t slot = 0, bool preferPixelArtSampling = false);
|
|
void unbind();
|
|
|
|
void setWrapMode(uint32_t wrapS, uint32_t wrapT);
|
|
void setFilterMode(uint32_t minFilter, uint32_t magFilter);
|
|
void setSampling(TextureSampling sampling);
|
|
TextureSampling getSampling() const { return sampling_; }
|
|
|
|
int getWidth() const { return width_; }
|
|
int getHeight() const { return height_; }
|
|
uint32_t getID() const { return textureID_; }
|
|
const std::string& getPath() const { return path_; }
|
|
|
|
private:
|
|
Texture(int width, int height, uint32_t id);
|
|
void applyFilter(uint32_t minFilter, uint32_t magFilter);
|
|
void applySampling(bool preferPixelArtSampling);
|
|
|
|
uint32_t textureID_ = 0;
|
|
int width_ = 0;
|
|
int height_ = 0;
|
|
int channels_ = 0;
|
|
std::string path_;
|
|
TextureSampling sampling_ = TextureSampling::Linear;
|
|
uint32_t appliedMinFilter_ = 0;
|
|
uint32_t appliedMagFilter_ = 0;
|
|
|
|
Texture() = default;
|
|
Texture(const Texture&) = delete;
|
|
Texture& operator=(const Texture&) = delete;
|
|
};
|
|
|
|
}
|