#include #include #include "../../libShaderFile.hpp" #if _WIN64 static const char* LibName = "..\\..\\..\\libShaderFile-x86_64-win64.dll"; #elif _WIN32 static const char* LibName = "..\\..\\..\\libShaderFile-i386-win32.dll"; #elif __linux__ && (__amd64 || __x86_64 || _M_AMD64 || __ppc64__) static const char* LibName = "../../../libShaderFile-x86_64-linux.so"; #elif __linux__ && (__i386 || _X86_) static const char* LibName = "../../../libShaderFile-i386-linux.so"; #else # error 'unknown operation system' #endif class FileReader : public lsf::IFileReader { public: virtual bool loadStream(const std::string& filename, std::ostream& os) { std::ifstream fs(filename.c_str()); if (!fs) return false; os << fs.rdbuf(); return true; } }; int main(int argc, char **argv) { try { if (argc < 3) { std::cout << "error: expected input file and generator/class name as parameter" << std::endl; return 1; } // initialize library lsf::Library lib(LibName); // create and load shader file lsf::ShaderFile shaderFile(lib); FileReader reader; shaderFile.loadFromFunc(argv[1], reader); const lsf::Library& l = shaderFile.getLibrary(); // get generator lsf::Generator generator(shaderFile, argv[2]); int i = 3; while (i < argc-1) { generator.setProperty(argv[i], argv[i+1]); i += 2; } std::cout << generator.generateCode() << std::endl; return 0; } catch(const std::exception& ex) { std::cout << "error: " << ex.what() << std::endl; return 2; } }