]> git.tdb.fi Git - libs/gl.git/blobdiff - source/program.cpp
Some cleanup for View and WindowView
[libs/gl.git] / source / program.cpp
index 82308b3405e0c42cc2086925c7633bd6b6a08770..270dbdc3e5675163017349d0cef901fcffaccdf8 100644 (file)
@@ -14,6 +14,8 @@
 #include "error.h"
 #include "misc.h"
 #include "program.h"
+#include "programcompiler.h"
+#include "resources.h"
 #include "shader.h"
 
 using namespace std;
@@ -35,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::Seekable> 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();