var fs = require('fs');

function Program(name, v, f) {
    this.vertex = v;
    this.vertex_history = { done: [], undone: [] };

    this.fragment = f;
    this.fragment_history = { done: [], undone: [] };

    this.name = name;
}

Program.default = function() {
    var v = fs.readFileSync(__dirname + '/default.glslv', 'utf-8').trimRight('\n');
    var f = fs.readFileSync(__dirname + '/default.glslf', 'utf-8').trimRight('\n');

    return new Program('default', v, f);
}

Program.prototype.serialize = function() {
    return {
        version: 1,
        name: this.name,
        vertex: this.vertex,
        vertex_history: this.vertex_history,
        fragment: this.fragment,
        fragment_history: this.fragment_history,
    };
}

Program.deserialize = function(program) {
    var ret = new Program();

    ret.vertex = program.vertex;
    ret.vertex_history = program.vertex_history;

    ret.fragment = program.fragment;
    ret.fragment_history = program.fragment_editor;

    ret.name = program.name;

    return ret;
}

module.exports = Program;

// vi:ts=4:et

@@ -466,24 +466,587 @@
 , v, f);%0A%7D%0A%0A
+Program.prototype._compile_shader = function(gl, type, source) %7B%0A    var ret = gl.createShader(type);%0A%0A    gl.shaderSource(ret, source);%0A    gl.compileShader(ret);%0A%0A    return ret;%0A%7D%0A%0AProgram.prototype.compile = function(gl) %7B%0A    var v = this._compile_shader(gl, gl.VERTEX_SHADER, this.vertex);%0A    var f = this._compile_shader(gl, gl.FRAGMENT_SHADER, this.fragment);%0A%0A    var p = gl.createProgram();%0A%0A    gl.attachShader(p, v);%0A    gl.attachShader(p, f);%0A%0A    gl.linkProgram(p);%0A%0A    return %7B%0A        vertex: v,%0A        fragment: f,%0A        program: p%0A    %7D%0A%7D%0A%0A
 Program.prot

Add program compilation