assets-related refactor

This commit is contained in:
MihailRis
2024-04-10 17:44:17 +03:00
parent 216e38e411
commit befc9cf09c
14 changed files with 242 additions and 202 deletions
+1 -1
View File
@@ -81,7 +81,7 @@ inline void source_line(std::stringstream& ss, uint linenum) {
ss << "#line " << linenum << "\n";
}
const std::string GLSLExtension::process(const fs::path file, const std::string& source) {
const std::string GLSLExtension::process(const fs::path& file, const std::string& source) {
std::stringstream ss;
size_t pos = 0;
uint linenum = 1;
+4 -1
View File
@@ -29,7 +29,10 @@ public:
bool hasHeader(const std::string& name) const;
bool hasDefine(const std::string& name) const;
const std::string process(const std::filesystem::path file, const std::string& source);
const std::string process(
const std::filesystem::path& file,
const std::string& source
);
};
#endif // CODERS_GLSL_EXTESION_H_
+3 -8
View File
@@ -343,18 +343,13 @@ ImageData* _png_load(const char* file){
ImageData* png::load_image(std::string filename) {
ImageData* image (_png_load(filename.c_str()));
if (image == nullptr) {
std::cerr << "Could not load image " << filename << std::endl;
return nullptr;
throw std::runtime_error("could not load image "+filename);
}
return image;
}
Texture* png::load_texture(std::string filename) {
std::unique_ptr<ImageData> image (_png_load(filename.c_str()));
if (image == nullptr){
std::cerr << "Could not load texture " << filename << std::endl;
return nullptr;
}
std::unique_ptr<ImageData> image (load_image(filename));
auto texture = Texture::from(image.get());
texture->setNearestFilter();
return texture;
@@ -362,4 +357,4 @@ Texture* png::load_texture(std::string filename) {
void png::write_image(std::string filename, const ImageData* image) {
_png_write(filename.c_str(), image->getWidth(), image->getHeight(), (const ubyte*)image->getData(), image->getFormat() == ImageFormat::rgba8888);
}
}