GL-related refactor

This commit is contained in:
MihailRis
2024-03-07 13:09:58 +03:00
parent f8e02e1b3b
commit 87edb1d45e
16 changed files with 224 additions and 111 deletions
+18 -4
View File
@@ -5,17 +5,19 @@
#include "ImageData.h"
Texture::Texture(uint id, int width, int height)
Texture::Texture(uint id, uint width, uint height)
: id(id), width(width), height(height) {
}
Texture::Texture(ubyte* data, int width, int height, uint format)
Texture::Texture(ubyte* data, uint width, uint height, uint format)
: width(width), height(height) {
glGenTextures(1, &id);
glBindTexture(GL_TEXTURE_2D, id);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0,
format, GL_UNSIGNED_BYTE, (GLvoid *) data);
glTexImage2D(
GL_TEXTURE_2D, 0, format, width, height, 0,
format, GL_UNSIGNED_BYTE, (GLvoid *) data
);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glGenerateMipmap(GL_TEXTURE_2D);
@@ -66,3 +68,15 @@ Texture* Texture::from(const ImageData* image) {
}
return new Texture((ubyte*)data, width, height, format);
}
uint Texture::getWidth() const {
return width;
}
uint Texture::getHeight() const {
return height;
}
uint Texture::getId() const {
return id;
}