mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
GL-related refactor
This commit is contained in:
parent
f8e02e1b3b
commit
87edb1d45e
16 changed files with 224 additions and 111 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue