content-pack resources support
This commit is contained in:
@@ -5,25 +5,22 @@
|
||||
#include "../util/stringutil.h"
|
||||
#include "../typedefs.h"
|
||||
#include "../files/files.h"
|
||||
#include "../files/engine_paths.h"
|
||||
|
||||
using std::string;
|
||||
using std::filesystem::path;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
path GLSLExtension::getHeaderPath(string name) {
|
||||
return libFolder/path(name+".glsl");
|
||||
}
|
||||
|
||||
void GLSLExtension::setLibFolder(path folder) {
|
||||
this->libFolder = folder;
|
||||
}
|
||||
|
||||
void GLSLExtension::setVersion(string version) {
|
||||
this->version = version;
|
||||
}
|
||||
|
||||
void GLSLExtension::setPaths(const ResPaths* paths) {
|
||||
this->paths = paths;
|
||||
}
|
||||
|
||||
void GLSLExtension::loadHeader(string name) {
|
||||
path file = getHeaderPath(name);
|
||||
path file = paths->find("shaders/lib/"+name+".glsl");
|
||||
string source = files::read_string(file);
|
||||
addHeader(name, source);
|
||||
}
|
||||
@@ -117,7 +114,6 @@ const string GLSLExtension::process(const path file, const string& source) {
|
||||
"expected '#include <filename>' syntax");
|
||||
}
|
||||
string name = line.substr(1, line.length()-2);
|
||||
path hfile = getHeaderPath(name);
|
||||
if (!hasHeader(name)) {
|
||||
loadHeader(name);
|
||||
}
|
||||
|
||||
@@ -2,19 +2,21 @@
|
||||
#define CODERS_GLSL_EXTESION_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <filesystem>
|
||||
|
||||
class ResPaths;
|
||||
|
||||
class GLSLExtension {
|
||||
std::unordered_map<std::string, std::string> headers;
|
||||
std::unordered_map<std::string, std::string> defines;
|
||||
std::filesystem::path libFolder;
|
||||
std::string version = "330 core";
|
||||
|
||||
const ResPaths* paths = nullptr;
|
||||
void loadHeader(std::string name);
|
||||
std::filesystem::path getHeaderPath(std::string name);
|
||||
public:
|
||||
void setLibFolder(std::filesystem::path folder);
|
||||
void setPaths(const ResPaths* paths);
|
||||
void setVersion(std::string version);
|
||||
|
||||
void define(std::string name, std::string value);
|
||||
@@ -30,4 +32,4 @@ public:
|
||||
const std::string process(const std::filesystem::path file, const std::string& source);
|
||||
};
|
||||
|
||||
#endif // CODERS_GLSL_EXTESION_H_
|
||||
#endif // CODERS_GLSL_EXTESION_H_
|
||||
|
||||
Reference in New Issue
Block a user