#include <msp/gl/extensions/arb_vertex_shader.h>
#include <msp/gl/extensions/ext_gpu_shader4.h>
#include <msp/gl/extensions/nv_non_square_matrices.h>
+#include <msp/io/print.h>
#include <msp/strings/format.h>
#include "buffer.h"
#include "error.h"
#include "misc.h"
#include "program.h"
+#include "programcompiler.h"
+#include "resources.h"
#include "shader.h"
using namespace std;
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);
+ 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();
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<UniformInfo *> uniforms_by_index(count);
for(unsigned i=0; i<count; ++i)
{
add("attribute", &Loader::attribute);
add("fragment_shader", &Loader::fragment_shader);
+ add("geometry_shader", &Loader::geometry_shader);
add("standard", &Loader::standard);
add("vertex_shader", &Loader::vertex_shader);
}
obj.attach_shader_owned(new FragmentShader(src));
}
+void Program::Loader::geometry_shader(const string &src)
+{
+ obj.attach_shader_owned(new GeometryShader(src));
+}
+
void Program::Loader::standard()
{
ProgramBuilder::StandardFeatures feat;