]> git.sesse.net Git - movit/blobdiff - effect_chain.cpp
Drop setting the locale altogether.
[movit] / effect_chain.cpp
index ca6905bf53c177f3f5988dc2f08173b3b495584a..21c4a0d1d2cf84e8a2eb3f80153715557aab8d1c 100644 (file)
@@ -1,8 +1,7 @@
 #define GL_GLEXT_PROTOTYPES 1
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
-#include <locale.h>
 #include <math.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -229,7 +228,7 @@ string replace_prefix(const string &text, const string &prefix)
 
 void EffectChain::compile_glsl_program(Phase *phase)
 {
-       string frag_shader = read_file("header.frag");
+       string frag_shader = read_version_dependent_file("header", "frag");
 
        // Create functions for all the texture inputs that we need.
        for (unsigned i = 0; i < phase->inputs.size(); ++i) {
@@ -240,7 +239,7 @@ void EffectChain::compile_glsl_program(Phase *phase)
        
                frag_shader += string("uniform sampler2D tex_") + effect_id + ";\n";
                frag_shader += string("vec4 ") + effect_id + "(vec2 tc) {\n";
-               frag_shader += "\treturn texture2D(tex_" + string(effect_id) + ", tc);\n";
+               frag_shader += "\treturn tex2D(tex_" + string(effect_id) + ", tc);\n";
                frag_shader += "}\n";
                frag_shader += "\n";
        }
@@ -279,9 +278,10 @@ void EffectChain::compile_glsl_program(Phase *phase)
                frag_shader += "\n";
        }
        frag_shader += string("#define INPUT ") + phase->effect_ids[phase->effects.back()] + "\n";
-       frag_shader.append(read_file("footer.frag"));
+       frag_shader.append(read_version_dependent_file("footer", "frag"));
 
-       phase->glsl_program_num = resource_pool->compile_glsl_program(read_file("vs.vert"), frag_shader);
+       string vert_shader = read_version_dependent_file("vs", "vert");
+       phase->glsl_program_num = resource_pool->compile_glsl_program(vert_shader, frag_shader);
 }
 
 // Construct GLSL programs, starting at the given effect and following
@@ -1329,10 +1329,6 @@ Node *EffectChain::find_output_node()
 
 void EffectChain::finalize()
 {
-       // Save the current locale, and set it to C, so that we can output decimal
-       // numbers with printf and be sure to get them in the format mandated by GLSL.
-       char *saved_locale = setlocale(LC_NUMERIC, "C");
-
        // Output the graph as it is before we do any conversions on it.
        output_dot("step0-start.dot");
 
@@ -1395,7 +1391,6 @@ void EffectChain::finalize()
        assert(phases[0]->inputs.empty());
        
        finalized = true;
-       setlocale(LC_NUMERIC, saved_locale);
 }
 
 void EffectChain::render_to_fbo(GLuint dest_fbo, unsigned width, unsigned height)
@@ -1493,8 +1488,7 @@ void EffectChain::execute_phase(Phase *phase, bool last_phase, map<Phase *, GLui
 
        // And now the output. (Already set up for us if it is the last phase.)
        if (!last_phase) {
-               void *context = get_gl_context_identifier();
-               fbo = resource_pool->create_fbo(context, (*output_textures)[phase]);
+               fbo = resource_pool->create_fbo((*output_textures)[phase]);
                glBindFramebuffer(GL_FRAMEBUFFER, fbo);
                glViewport(0, 0, phase->output_width, phase->output_height);
        }