mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
feat: canvas from texture atlas element
This commit is contained in:
parent
497160a5b9
commit
d9f2d54bf0
10 changed files with 126 additions and 28 deletions
|
|
@ -54,6 +54,12 @@ void Texture::reload(const ubyte* data) {
|
|||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
void Texture::reloadPartial(const ImageData& image, uint x, uint y, uint w, uint h) {
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, image.getData());
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
std::unique_ptr<ImageData> Texture::readData() {
|
||||
auto data = std::make_unique<ubyte[]>(width * height * 4);
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue