#include "lighting.h"
#include "material.h"
#include "mesh.h"
+#include "module.h"
#include "object.h"
#include "pipelinetemplate.h"
#include "pose.h"
#include "program.h"
-#include "programcompiler.h"
#include "resourcemanager.h"
#include "resources.h"
#include "sampler.h"
#include "texture2d.h"
#include "texture2darray.h"
#include "texturecube.h"
+#include "glsl/compiler.h"
using namespace std;
namespace GL {
void init_shaderlib(DataFile::BuiltinSource &);
+void init_builtin_data(DataFile::BuiltinSource &);
Resources::Resources():
default_tex_filter(Texture::can_generate_mipmap() ? LINEAR_MIPMAP_LINEAR : LINEAR),
add_type<Lighting>().suffix(".lightn").keyword("lighting");
add_type<Material>().suffix(".mat").creator(&Resources::create_material);
add_type<Mesh>().keyword("mesh").creator(&Resources::create_mesh);
+ add_type<Module>().suffix(".glsl").creator(&Resources::create_module);
add_type<Object>().keyword("object");
add_type<PipelineTemplate>().suffix(".pipe").keyword("pipeline");
add_type<Pose>().keyword("pose");
- add_type<Program>().keyword("shader").suffix(".glsl").creator(&Resources::create_program);
+ add_type<Program>().keyword("shader").creator(&Resources::create_program);
add_type<Sampler>().suffix(".samp").keyword("sampler");
add_type<Technique>().suffix(".tech").keyword("technique");
add_type<Texture1D>().base<Texture>().suffix(".tex1d").keyword("texture1d");
if(!init_done)
{
+ init_builtin_data(builtins);
init_shaderlib(builtins);
init_done = true;
}
return 0;
}
+Module *Resources::create_module(const string &name)
+{
+ if(RefPtr<IO::Seekable> io = open_raw(name))
+ {
+ RefPtr<Module> module = new Module;
+ module->load_source(*io, this, name);
+ return module.release();
+ }
+
+ 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_raw(name))
+ string base = FS::basepart(name);
+ string ext2 = FS::extpart(base);
+ if(ext==".shader" && ext2==".glsl")
{
- ProgramCompiler compiler;
- compiler.compile(*io, this, name);
- RefPtr<Program> program = new Program;
- compiler.add_shaders(*program);
- program->link();
- return program.release();
+ Module &module = get<Module>(base);
+ RefPtr<Program> shprog = new Program;
+ shprog->add_stages(module);
+ shprog->link();
+ return shprog.release();
}
return 0;