14 #define STB_IMAGE_IMPLEMENTATION 15 #include <stb_image.h> 32 for (map<string, ShaderModule*>::iterator it =
objects.begin(); it !=
objects.end(); it++) {
43 ifstream fileStream(path, ios::ate | ios::binary);
44 if (fileStream.is_open()) {
46 size_t fileSize = fileStream.tellg();
47 vector<uint8_t> fileBuffer(fileSize);
51 fileStream.read(reinterpret_cast<char*> (fileBuffer.data()), fileSize);
60 put(name, shaderModule);
79 for (map<string, TextureImage*>::iterator it =
objects.begin(); it !=
objects.end(); it++) {
90 stbi_set_flip_vertically_on_load(
true);
91 int32_t width, height, components;
92 stbi_uc* pixels = stbi_load(path.c_str(), &width, &height, &components, 0);
98 textureImage->upload(vector<uint8_t>(pixels, pixels + components * width * height));
99 stbi_image_free(pixels);
102 put(name, textureImage);
std::map< std::string, ShaderModule * > objects
Contains the objects to manage.
ShaderModule * loadShaderModule(std::string path, std::string name, ShaderStageBit stageBit)
Loads a shader module from a binary file and stores it.
void remove(std::string name) override
Removes and disposes a shader module from the storage.
static void logError(std::string message)
Logs an error string to cerr.
void clear() override
Removes all texture images and disposes them.
Generic namespace for the SimpleGL framework.
void remove(std::string name) override
Removes and disposes a texture image from the storage.
void put(std::string name, ShaderModule *value)
Stores a object with specified name.
virtual void clear()
Removes all objects and disposes them.
This class wraps a Vulkan texture image.
virtual void remove(std::string name)
Removes and disposes an object from the storage.
ShaderStageBit
This enum stores supported shader stage flag bit.
TextureImage * load(std::string path, std::string name)
Loads a texture from file and stores it.
This class wraps a Vulkan shader module.
void clear() override
Removes all shader modules and disposes them.