Files
vb01/imageReader.cpp
devZoGok f457c69d36 factored out texture GPU data loading
improved texture buffer and layer retrieval
using draw commands 1:1 with meshes
2026-07-08 12:08:03 +03:00

29 lines
698 B
C++

#include "imageReader.h"
#include "root.h"
#include "stb_image.h"
using namespace std;
namespace vb01{
ImageReader *imageReader = nullptr;
ImageReader* ImageReader::getSingleton(){
if(!imageReader)
imageReader = new ImageReader();
return imageReader;
}
Asset* ImageReader::readAsset(string path){
stbi_set_flip_vertically_on_load(flip);
int width, height, numChannels, bufferId, layerId;
u8 *data = stbi_load(path.c_str(), &width, &height, &numChannels, 0);
if(loadToGpu)
Root::getSingleton()->initTextureDataOnGpu(data, width, height, bufferId, layerId, sceneImage);
return new ImageAsset(path, data, width, height, numChannels, bufferId, layerId, loadToGpu);
}
}