X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprogram.cpp;h=270dbdc3e5675163017349d0cef901fcffaccdf8;hp=021b23483dcdce1c074388916a38721a72aee567;hb=4598d28936d3a4772927d1e3a1534f872731b358;hpb=e3561c5c4d0b2caf00a0e50ce85c11a9fb62aa72 diff --git a/source/program.cpp b/source/program.cpp index 021b2348..270dbdc3 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -8,11 +8,14 @@ #include #include #include +#include #include #include "buffer.h" #include "error.h" #include "misc.h" #include "program.h" +#include "programcompiler.h" +#include "resources.h" #include "shader.h" using namespace std; @@ -34,6 +37,24 @@ Program::Program(const ProgramBuilder::StandardFeatures &features) link(); } +Program::Program(const std::string &source) +{ + init(); + + ProgramCompiler compiler; + if(source.find(';')==string::npos && source.size()>5 && !source.compare(source.size()-5, 5, ".glsl")) + { + if(RefPtr io = Resources::get_builtins().open(source)) + compiler.compile(*io, source); + else + throw IO::file_not_found(source); + } + else + compiler.compile(source); + compiler.add_shaders(*this); + link(); +} + Program::Program(const string &vert, const string &frag) { init(); @@ -115,6 +136,12 @@ void Program::link() if(!linked) throw compile_error(get_info_log()); +#ifdef DEBUG + std::string info_log = get_info_log(); + if(!info_log.empty()) + IO::print("Program link info log:\n%s", info_log); +#endif + unsigned count = get_program_i(id, GL_ACTIVE_UNIFORMS); vector uniforms_by_index(count); for(unsigned i=0; i