]> git.tdb.fi Git - libs/gl.git/blobdiff - source/resources.cpp
Add a builtin module for standard shaders
[libs/gl.git] / source / resources.cpp
index bba69315de900890e5c365a1c7a325e356394e63..48e986cea064b2742eadf3d2625f418ccf1cef24 100644 (file)
@@ -23,6 +23,8 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
+extern const char singlepass_glsl_data[];
+
 Resources::Resources():
        default_tex_filter(SGIS_generate_mipmap ? LINEAR_MIPMAP_LINEAR : LINEAR),
        srgb_conversion(false),
@@ -43,6 +45,22 @@ Resources::Resources():
        add_type<Texture3D>().base<Texture>().suffix(".tex3d").keyword("texture3d");
        add_type<TextureCube>().base<Texture>().suffix(".texcb").keyword("texture_cube");
        add_type<Texture2DArray>().base<Texture>().suffix(".tex2da").keyword("texture2d_array");
+
+       add_source(get_builtins());
+}
+
+DataFile::BuiltinSource &Resources::get_builtins()
+{
+       static DataFile::BuiltinSource builtins;
+       bool init_done = false;
+
+       if(!init_done)
+       {
+               builtins.add_object("singlepass.glsl", singlepass_glsl_data);
+               init_done = true;
+       }
+
+       return builtins;
 }
 
 void Resources::set_default_texture_filter(TextureFilter tf)
@@ -117,7 +135,7 @@ Program *Resources::create_program(const string &name)
        if(RefPtr<IO::Seekable> io = open_from_sources(name))
        {
                ProgramCompiler compiler;
-               compiler.compile(*io);
+               compiler.compile(*io, this);
                RefPtr<Program> program = new Program;
                compiler.add_shaders(*program);
                program->link();