Kill the vertex shader system; it is too complicated to get it right until we have...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 2 Oct 2012 16:50:16 +0000 (18:50 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 2 Oct 2012 16:50:16 +0000 (18:50 +0200)
effect.cpp
effect.h
effect_chain.cpp
identity.vert [deleted file]
mirror_effect.cpp
mirror_effect.frag [new file with mode: 0644]
mirror_effect.h
mirror_effect.vert [deleted file]
vs.vert [new file with mode: 0644]

index 6f9d4c5..3a4f8c8 100644 (file)
@@ -152,8 +152,3 @@ void Effect::set_uniforms(GLuint glsl_program_num, const std::string& prefix)
                set_uniform_vec3(glsl_program_num, prefix, it->first, it->second);
        }
 }
-
-std::string Effect::output_vertex_shader()
-{
-       return read_file("identity.vert");
-}
index 79209b8..1478c6e 100644 (file)
--- a/effect.h
+++ b/effect.h
@@ -35,7 +35,6 @@ public:
        virtual bool needs_mipmaps() { return false; }
 
        virtual std::string output_convenience_uniforms();
-       virtual std::string output_vertex_shader();
        virtual std::string output_fragment_shader() = 0;
 
        virtual void set_uniforms(GLuint glsl_program_num, const std::string& prefix);
index f860cad..d45c2fc 100644 (file)
@@ -159,24 +159,6 @@ void EffectChain::finalize()
                current_gamma_curve = output_format.gamma_curve;
        }
        
-       std::string vert_shader = read_file("header.vert");
-       for (unsigned i = 0; i < effects.size(); ++i) {
-               char effect_id[256];
-               sprintf(effect_id, "eff%d", i);
-       
-               vert_shader += "\n";
-               vert_shader += std::string("#define FUNCNAME ") + effect_id + "\n";
-               vert_shader += replace_prefix(effects[i]->output_convenience_uniforms(), effect_id);
-               vert_shader += replace_prefix(effects[i]->output_vertex_shader(), effect_id);
-               vert_shader += "#undef PREFIX\n";
-               vert_shader += "#undef FUNCNAME\n";
-               vert_shader += "#undef LAST_INPUT\n";
-               vert_shader += std::string("#define LAST_INPUT ") + effect_id + "\n";
-               vert_shader += "\n";
-       }
-       vert_shader.append(read_file("footer.vert"));
-       printf("%s\n", vert_shader.c_str());
-
        std::string frag_shader = read_file("header.frag");
        for (unsigned i = 0; i < effects.size(); ++i) {
                char effect_id[256];
@@ -196,7 +178,7 @@ void EffectChain::finalize()
        printf("%s\n", frag_shader.c_str());
        
        glsl_program_num = glCreateProgram();
-       GLuint vs_obj = compile_shader(vert_shader, GL_VERTEX_SHADER);
+       GLuint vs_obj = compile_shader(read_file("vs.vert"), GL_VERTEX_SHADER);
        GLuint fs_obj = compile_shader(frag_shader, GL_FRAGMENT_SHADER);
        glAttachShader(glsl_program_num, vs_obj);
        check_error();
diff --git a/identity.vert b/identity.vert
deleted file mode 100644 (file)
index 77b6ff8..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-// Identity transformation (sometimes useful to do nothing).
-vec2 FUNCNAME()
-{
-       return LAST_INPUT();
-}
index f772821..7c9875a 100644 (file)
@@ -5,12 +5,7 @@ MirrorEffect::MirrorEffect()
 {
 }
 
-std::string MirrorEffect::output_vertex_shader()
-{
-       return read_file("mirror_effect.vert");
-}
-
 std::string MirrorEffect::output_fragment_shader()
 {
-       return read_file("identity.frag");
+       return read_file("mirror_effect.frag");
 }
diff --git a/mirror_effect.frag b/mirror_effect.frag
new file mode 100644 (file)
index 0000000..2f52d2b
--- /dev/null
@@ -0,0 +1,6 @@
+// Mirrors the image horizontally.
+vec4 FUNCNAME(vec2 tc)
+{
+       tc = vec2(1.0, 0.0) + tc * vec2(-1.0, 1.0);
+       return LAST_INPUT(tc);
+}
index 6e75b26..6b07ea9 100644 (file)
@@ -6,7 +6,6 @@
 class MirrorEffect : public Effect {
 public:
        MirrorEffect();
-       std::string output_vertex_shader();
        std::string output_fragment_shader();
 };
 
diff --git a/mirror_effect.vert b/mirror_effect.vert
deleted file mode 100644 (file)
index 8c29945..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-vec2 FUNCNAME()
-{
-       return vec2(1.0, 0.0) + LAST_INPUT() * vec2(-1.0, 1.0);
-}
diff --git a/vs.vert b/vs.vert
new file mode 100644 (file)
index 0000000..1f48069
--- /dev/null
+++ b/vs.vert
@@ -0,0 +1,7 @@
+varying vec2 tc;
+
+void main()
+{
+       tc = gl_MultiTexCoord0.st;
+        gl_Position = ftransform();
+}