Shader loading error text fix

This commit is contained in:
MihailRis
2023-12-02 17:53:53 +03:00
parent 8c261efbd4
commit 54178eafc1
4 changed files with 50 additions and 58 deletions
+18 -9
View File
@@ -2,6 +2,7 @@
#include <iostream>
#include "Assets.h"
#include "../files/files.h"
#include "../coders/png.h"
#include "../graphics/Shader.h"
#include "../graphics/Texture.h"
@@ -17,8 +18,8 @@ using std::filesystem::path;
namespace fs = std::filesystem;
bool assetload::texture(Assets* assets,
const path& filename,
const string& name) {
const path filename,
const string name) {
Texture* texture = png::load_texture(filename.string());
if (texture == nullptr) {
std::cerr << "failed to load texture '" << name << "'" << std::endl;
@@ -29,10 +30,18 @@ bool assetload::texture(Assets* assets,
}
bool assetload::shader(Assets* assets,
const path& filename,
const path filename,
const string& name) {
Shader* shader = Shader::loadShader(filename.string() + ".glslv",
filename.string() + ".glslf");
path vertexFile = filename;
path fragmentFile = filename;
vertexFile.append(".glslv");
fragmentFile.append(".glslf");
string vertexSource = files::read_string(vertexFile);
string fragmentSource = files::read_string(fragmentFile);
Shader* shader = Shader::loadShader(vertexFile, fragmentFile,
vertexSource, fragmentSource);
if (shader == nullptr) {
std::cerr << "failed to load shader '" << name << "'" << std::endl;
return false;
@@ -42,8 +51,8 @@ bool assetload::shader(Assets* assets,
}
bool assetload::atlas(Assets* assets,
const path& directory,
const string& name) {
const path directory,
const string name) {
AtlasBuilder builder;
for (const auto& entry : fs::directory_iterator(directory)) {
path file = entry.path();
@@ -60,8 +69,8 @@ bool assetload::atlas(Assets* assets,
}
bool assetload::font(Assets* assets,
const path& filename,
const string& name) {
const path filename,
const string name) {
vector<Texture*> pages;
for (size_t i = 0; i <= 4; i++) {
string name = filename.string() + "_" + std::to_string(i) + ".png";