]> git.sesse.net Git - movit/blobdiff - init.cpp
Allow data files to be fetched somewhere else than the current directory.
[movit] / init.cpp
index 129ee4c894d91ea3d5072b35a9812338981707fc..a70ae058bbf39ddd0eb0b0ae2ee31b3cafef0be9 100644 (file)
--- a/init.cpp
+++ b/init.cpp
@@ -1,9 +1,17 @@
+#include <GL/glew.h>
+#include <string>
+
 #include "init.h"
 #include "init.h"
-#include "opengl.h"
 #include "util.h"
 
 bool movit_initialized = false;
 float movit_texel_subpixel_precision;
 #include "util.h"
 
 bool movit_initialized = false;
 float movit_texel_subpixel_precision;
+bool movit_srgb_textures_supported;
+
+// The rules for objects with nontrivial constructors in static scope
+// are somewhat convoluted, and easy to mess up. We simply have a
+// pointer instead (and never care to clean it up).
+std::string *movit_data_directory = NULL;
 
 namespace {
 
 
 namespace {
 
@@ -119,19 +127,49 @@ void measure_texel_subpixel_precision()
        check_error();
 }
 
        check_error();
 }
 
+void check_extensions()
+{
+       // We fundamentally need FBOs and floating-point textures.
+       assert(glewIsSupported("GL_ARB_framebuffer_object") != 0);
+       assert(glewIsSupported("GL_ARB_texture_float") != 0);
+
+       // We assume that we can use non-power-of-two textures without restrictions.
+       assert(glewIsSupported("GL_ARB_texture_non_power_of_two") != 0);
+
+       // We also need GLSL fragment shaders.
+       assert(glewIsSupported("GL_ARB_fragment_shader") != 0);
+       assert(glewIsSupported("GL_ARB_shading_language_100") != 0);
+
+       // FlatInput and YCbCrInput uses PBOs. (They could in theory do without,
+       // but no modern card would really not provide it.)
+       assert(glewIsSupported("GL_ARB_pixel_buffer_object") != 0);
+
+       // ResampleEffect uses RG textures to encode a two-component LUT.
+       assert(glewIsSupported("GL_ARB_texture_rg") != 0);
+
+       // sRGB texture decode would be nice, but are not mandatory
+       // (GammaExpansionEffect can do the same thing if needed).
+       movit_srgb_textures_supported = glewIsSupported("GL_EXT_texture_sRGB");
+}
+
 }  // namespace
 
 }  // namespace
 
-void init_movit()
+void init_movit(const std::string& data_directory)
 {
        if (movit_initialized) {
                return;
        }
 
 {
        if (movit_initialized) {
                return;
        }
 
+       movit_data_directory = new std::string(data_directory);
+
+       glewInit();
+
        // geez 
        glPixelStorei(GL_PACK_ALIGNMENT, 1);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
 
        measure_texel_subpixel_precision();
        // geez 
        glPixelStorei(GL_PACK_ALIGNMENT, 1);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
 
        measure_texel_subpixel_precision();
+       check_extensions();
 
        movit_initialized = true;
 }
 
        movit_initialized = true;
 }