]> git.sesse.net Git - movit/blobdiff - util.cpp
Keep FBOs around in EffectChain again.
[movit] / util.cpp
index 8162f712d02eed8f5b47b7f481b977b827f56f8f..1e66c30b573e51ef419146d5149c32ed9e53e7d3 100644 (file)
--- a/util.cpp
+++ b/util.cpp
@@ -9,6 +9,14 @@
 #include "init.h"
 #include "util.h"
 
+#if defined(__DARWIN__)
+#include <OpenGL/OpenGL.h>
+#elif defined(WIN32)
+#include <GL/wglew.h>
+#else
+#include <GL/glxew.h>
+#endif
+
 using namespace std;
 
 namespace movit {
@@ -220,4 +228,28 @@ unsigned div_round_up(unsigned a, unsigned b)
        return (a + b - 1) / b;
 }
 
+// Algorithm from http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2.
+unsigned next_power_of_two(unsigned v)
+{
+       v--;
+       v |= v >> 1;
+       v |= v >> 2;
+       v |= v >> 4;
+       v |= v >> 8;
+       v |= v >> 16;
+       v++;
+       return v;
+}
+
+void *get_gl_context_identifier()
+{
+#if defined(__DARWIN__)
+       return (void *)CGLGetCurrentContext();
+#elif defined(WIN32)
+       return (void *)wglGetCurrentContext();
+#else
+       return (void *)glXGetCurrentContext();
+#endif
+}
+
 }  // namespace movit