#include "error.h"
#include "misc.h"
#include "program.h"
+#include "programcompiler.h"
#include "shader.h"
using namespace std;
link();
}
+Program::Program(const std::string &source)
+{
+ init();
+
+ ProgramCompiler compiler;
+ compiler.compile(source);
+ compiler.add_shaders(*this);
+ link();
+}
+
Program::Program(const string &vert, const string &frag)
{
init();
/// Constructs a Program with standard features.
Program(const ProgramBuilder::StandardFeatures &);
+ /// Constructs a Program from unified source code using ProgramCompiler.
+ Program(const std::string &);
+
/// Constructs a Program from vertex and fragment shader source code.
Program(const std::string &, const std::string &);
#include "object.h"
#include "pose.h"
#include "program.h"
+#include "programcompiler.h"
#include "resourcemanager.h"
#include "resources.h"
#include "technique.h"
add_type<Mesh>().keyword("mesh").creator(&Resources::create_mesh);
add_type<Object>().keyword("object");
add_type<Pose>().keyword("pose");
- add_type<Program>().keyword("shader");
+ add_type<Program>().keyword("shader").suffix(".glsl").creator(&Resources::create_program);
add_type<Technique>().suffix(".tech").keyword("technique");
add_type<Texture1D>().base<Texture>().suffix(".tex1d").keyword("texture1d");
add_type<Texture2D>().base<Texture>().suffix(".tex2d").suffix(".png").suffix(".jpg").keyword("texture2d").creator(&Resources::create_texture2d);
return 0;
}
+Program *Resources::create_program(const string &name)
+{
+ string ext = FS::extpart(name);
+ if(ext==".shader")
+ return 0;
+
+ if(RefPtr<IO::Seekable> io = open_from_sources(name))
+ {
+ ProgramCompiler compiler;
+ compiler.compile(*io);
+ RefPtr<Program> program = new Program;
+ compiler.add_shaders(*program);
+ program->link();
+ return program.release();
+ }
+
+ return 0;
+}
+
} // namespace GL
} // namespace Msp
namespace GL {
class Mesh;
+class Program;
class ResourceManager;
class Texture2D;
protected:
Mesh *create_mesh(const std::string &);
Texture2D *create_texture2d(const std::string &);
+ Program *create_program(const std::string &);
};
} // namespace GL