mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 05:21:49 +00:00
refactor textures access
This commit is contained in:
parent
673f235ff9
commit
4f377b2056
13 changed files with 74 additions and 49 deletions
|
|
@ -75,7 +75,7 @@ void Batch2D::vertex(
|
|||
buffer[index++] = a;
|
||||
}
|
||||
|
||||
void Batch2D::texture(Texture* new_texture){
|
||||
void Batch2D::texture(const Texture* new_texture){
|
||||
if (currentTexture == new_texture) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class Batch2D : public Flushable {
|
|||
std::unique_ptr<Texture> blank;
|
||||
size_t index;
|
||||
glm::vec4 color;
|
||||
Texture* currentTexture;
|
||||
const Texture* currentTexture;
|
||||
DrawPrimitive primitive = DrawPrimitive::triangle;
|
||||
UVRegion region {0.0f, 0.0f, 1.0f, 1.0f};
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public:
|
|||
~Batch2D();
|
||||
|
||||
void begin();
|
||||
void texture(Texture* texture);
|
||||
void texture(const Texture* texture);
|
||||
void untexture();
|
||||
void setRegion(UVRegion region);
|
||||
void sprite(float x, float y, float w, float h, const UVRegion& region, glm::vec4 tint);
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ Cubemap::Cubemap(uint width, uint height, ImageFormat imageFormat)
|
|||
}
|
||||
}
|
||||
|
||||
void Cubemap::bind(){
|
||||
void Cubemap::bind() const {
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, id);
|
||||
}
|
||||
|
||||
void Cubemap::unbind() {
|
||||
void Cubemap::unbind() const {
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ class Cubemap : public GLTexture {
|
|||
public:
|
||||
Cubemap(uint width, uint height, ImageFormat format);
|
||||
|
||||
virtual void bind() override;
|
||||
virtual void unbind() override;
|
||||
virtual void bind() const override;
|
||||
virtual void unbind() const override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ GLTexture::~GLTexture() {
|
|||
glDeleteTextures(1, &id);
|
||||
}
|
||||
|
||||
void GLTexture::bind(){
|
||||
void GLTexture::bind() const {
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
}
|
||||
|
||||
void GLTexture::unbind() {
|
||||
void GLTexture::unbind() const {
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ public:
|
|||
GLTexture(const ubyte* data, uint width, uint height, ImageFormat format);
|
||||
virtual ~GLTexture();
|
||||
|
||||
virtual void bind() override;
|
||||
virtual void unbind() override;
|
||||
virtual void bind() const override;
|
||||
virtual void unbind() const override;
|
||||
virtual void reload(const ubyte* data);
|
||||
|
||||
void setNearestFilter();
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ public:
|
|||
|
||||
virtual ~Texture() {}
|
||||
|
||||
virtual void bind() = 0;
|
||||
virtual void unbind() = 0;
|
||||
virtual void bind() const = 0;
|
||||
virtual void unbind() const = 0;
|
||||
|
||||
virtual void reload(const ImageData& image) = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue