fishbowl/engine/src/textureldr.cc
2026-06-06 01:04:35 +09:00

23 lines
492 B
C++

#include <fishbone/foundation.h>
#include <iostream>
fishbone::TextureData::TextureData(fishbone::File* f) {
unsigned char* buf = new unsigned char[f->size];
int ch;
f->read(buf, f->size);
this->rgba = stbi_load_from_memory(buf, f->size, &this->width, &this->height, &ch, 4);
delete[] buf;
}
fishbone::TextureData::~TextureData() {
if(this->rgba != nullptr) free(this->rgba);
}
bool fishbone::TextureData::good() {
if(this->rgba == nullptr) return false;
return true;
}