]> git.sesse.net Git - movit/blobdiff - init.cpp
Allow data files to be fetched somewhere else than the current directory.
[movit] / init.cpp
index a89028c645eb1504a203b0562948a4693ebfa614..a70ae058bbf39ddd0eb0b0ae2ee31b3cafef0be9 100644 (file)
--- a/init.cpp
+++ b/init.cpp
@@ -1,4 +1,5 @@
 #include <GL/glew.h>
+#include <string>
 
 #include "init.h"
 #include "util.h"
@@ -7,6 +8,11 @@ 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 {
 
 void measure_texel_subpixel_precision()
@@ -148,12 +154,14 @@ void check_extensions()
 
 }  // namespace
 
-void init_movit()
+void init_movit(const std::string& data_directory)
 {
        if (movit_initialized) {
                return;
        }
 
+       movit_data_directory = new std::string(data_directory);
+
        glewInit();
 
        // geez