]> git.sesse.net Git - movit/blobdiff - main.cpp
Move slurping of files into its own function.
[movit] / main.cpp
index 3b2bcad7961dc53c5bd13ed8a8703602c2b5bfd3..8c28c8f6cbde8716efc16fc25c3bdfda25387e20 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -40,19 +40,11 @@ float gain_r = 1.0f, gain_g = 1.0f, gain_b = 1.0f;
 
 GLhandleARB read_shader(const char* filename, GLenum type)
 {
-       static char buf[131072];
-       FILE *fp = fopen(filename, "r");
-       if (fp == NULL) {
-               perror(filename);
-               exit(1);
-       }
-
-       int len = fread(buf, 1, sizeof(buf), fp);
-       fclose(fp);
+       std::string shader_src = read_file(filename);
 
        GLhandleARB obj = glCreateShaderObjectARB(type);
-       const GLchar* source[] = { buf };
-       const GLint length[] = { len };
+       const GLchar* source[] = { shader_src.data() };
+       const GLint length[] = { shader_src.size() };
        glShaderSource(obj, 1, source, length);
        glCompileShader(obj);