]> git.sesse.net Git - movit/commitdiff
Change to using GLEW everywhere.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 9 Jan 2013 19:12:06 +0000 (20:12 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 9 Jan 2013 19:12:06 +0000 (20:12 +0100)
We could have done this on Windows only, but it's just as simple to
keep the dependency list equal on all platforms. This subsumes our
own extension-checking logic, too.

21 files changed:
Makefile
blur_effect.cpp
deconvolution_sharpen_effect.cpp
demo.cpp
dither_effect.cpp
effect.cpp
effect.h
effect_chain.cpp
effect_chain_test.cpp
flat_input.cpp
init.cpp
lift_gamma_gain_effect.cpp
opengl.h [deleted file]
resample_effect.cpp
sandbox_effect.cpp
util.cpp
util.h
vignette_effect.cpp
white_balance_effect.cpp
widgets.cpp
ycbcr_input.cpp

index cd1a4b859639a119d79e6d9d768a215faabd5630..8396ac6c5170e2f6be7963d2cd258261e76d17b2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,10 +5,20 @@ ifeq ($(EIGEN_CXXFLAGS),)
 $(error Empty EIGEN_CXXFLAGS. You probably need to install Eigen3)
 endif
 
+GLEW_CXXFLAGS := $(shell pkg-config --cflags glew)
+ifeq ($(GLEW_CXXFLAGS),)
+$(error Empty GLEW_CXXFLAGS. You probably need to install GLEW)
+endif
+
+GLEW_LIBS := $(shell pkg-config --libs glew)
+ifeq ($(GLEW_LIBS),)
+$(error Empty GLEW_LIBS. You probably need to install GLEW)
+endif
+
 CC=gcc
 CXX=g++
-CXXFLAGS=-Wall -g -I$(GTEST_DIR)/include $(EIGEN_CXXFLAGS)
-LDFLAGS=-lSDL -lSDL_image -lGL -lrt -lpthread
+CXXFLAGS=-Wall -g -I$(GTEST_DIR)/include $(EIGEN_CXXFLAGS) $(GLEW_CXXFLAGS)
+LDFLAGS=-lSDL -lSDL_image -lGL -lrt -lpthread $(GLEW_LIBS)
 RANLIB=ranlib
 
 ifeq ($(COVERAGE),1)
index 80ccb3f2bee02769b90b487975b36ca83248ded6..77238533e308054ccdd60475313d86b2e573bbd8 100644 (file)
@@ -1,10 +1,10 @@
 #include <math.h>
 #include <assert.h>
+#include <GL/glew.h>
 
 #include "blur_effect.h"
 #include "effect_chain.h"
 #include "util.h"
-#include "opengl.h"
 
 // Must match blur_effect.frag.
 #define NUM_TAPS 16
index 38cf0cf3fcbc66bf6f8b9a5e64e65972da977fab..2d32ecd6724d886a03185b1042b643a15a83075b 100644 (file)
@@ -5,12 +5,12 @@
 
 #include <math.h>
 #include <assert.h>
+#include <GL/glew.h>
 #include <Eigen/Dense>
 #include <Eigen/Cholesky>
 
 #include "deconvolution_sharpen_effect.h"
 #include "util.h"
-#include "opengl.h"
 
 using namespace Eigen;
 
index cd6cf88a0286045e55782d8ca2d6a59714c8bb8b..99fec55470cf31d7690ce9a372f58ec6f7b71a95 100644 (file)
--- a/demo.cpp
+++ b/demo.cpp
@@ -14,6 +14,8 @@
 #include <vector>
 #include <map>
 
+#include <GL/glew.h>
+
 #include <SDL/SDL.h>
 #include <SDL/SDL_opengl.h>
 #include <SDL/SDL_image.h>
@@ -22,7 +24,6 @@
 #include "effect.h"
 #include "effect_chain.h"
 #include "util.h"
-#include "opengl.h"
 #include "widgets.h"
 
 #include "flat_input.h"
index 87e729a3c9feca0a7253e7617eeb41d287d9f68b..1399c8196984c728ac148ea686f4ab9de504e403 100644 (file)
@@ -1,9 +1,9 @@
 #include <math.h>
 #include <assert.h>
+#include <GL/glew.h>
 
 #include "dither_effect.h"
 #include "util.h"
-#include "opengl.h"
 
 namespace {
 
index 9ff200bacde5d01258ffa2b7040181f266824efa..384e8c2944e741ce53bade017d4e7b9064148228 100644 (file)
@@ -1,12 +1,12 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
+#include <GL/glew.h>
+
 #include "effect.h"
 #include "effect_chain.h"
 #include "util.h"
 
-#include "opengl.h"
-
 GLint get_uniform_location(GLuint glsl_program_num, const std::string &prefix, const std::string &key)
 {
        std::string name = prefix + "_" + key;
index 21068effc20b7debc024923ca3e12cd504ca63fb..235558f8e1c4cf9f480361f0f428916885b1e0e5 100644 (file)
--- a/effect.h
+++ b/effect.h
@@ -18,7 +18,7 @@
 
 #include <Eigen/Core>
 
-#include "opengl.h"
+#include <GL/glew.h>
 #include "util.h"
 
 class EffectChain;
index 491626500ec78cc9a88e692e885ebcddd288a9c6..05deb76226deecb081d8953c3fc65287ff0f438a 100644 (file)
@@ -4,6 +4,7 @@
 #include <math.h>
 #include <string.h>
 #include <assert.h>
+#include <GL/glew.h>
 
 #include <algorithm>
 #include <set>
@@ -17,7 +18,6 @@
 #include "colorspace_conversion_effect.h"
 #include "dither_effect.h"
 #include "input.h"
-#include "opengl.h"
 
 EffectChain::EffectChain(float aspect_nom, float aspect_denom)
        : aspect_nom(aspect_nom),
index d8ade1370e06d58669d2c47d1e2ff2c5b0d6f4ae..21cb2bec6538189d5cfd9bc7b009a014b9e271bf 100644 (file)
@@ -2,12 +2,13 @@
 //
 // Note that this also contains the tests for some of the simpler effects.
 
+#include <GL/glew.h>
+
 #include "effect_chain.h"
 #include "flat_input.h"
 #include "gtest/gtest.h"
 #include "mirror_effect.h"
 #include "resize_effect.h"
-#include "opengl.h"
 #include "test_util.h"
 
 TEST(EffectChainTest, EmptyChain) {
index b37a1ec97d0392568c8f8ca49dfdb3dbde30b82b..291bb0dcc3a08ce5c9024cd29153883907a0f0eb 100644 (file)
@@ -1,9 +1,9 @@
 #include <string.h>
 #include <assert.h>
+#include <GL/glew.h>
 
 #include "flat_input.h"
 #include "util.h"
-#include "opengl.h"
 
 FlatInput::FlatInput(ImageFormat image_format, MovitPixelFormat pixel_format, GLenum type, unsigned width, unsigned height)
        : image_format(image_format),
index ac52aa2ce3d7eee956e6cc629912e699bb6553b1..a89028c645eb1504a203b0562948a4693ebfa614 100644 (file)
--- a/init.cpp
+++ b/init.cpp
@@ -1,10 +1,8 @@
+#include <GL/glew.h>
+
 #include "init.h"
-#include "opengl.h"
 #include "util.h"
 
-#include <set>
-#include <string>
-
 bool movit_initialized = false;
 float movit_texel_subpixel_precision;
 bool movit_srgb_textures_supported;
@@ -123,41 +121,29 @@ void measure_texel_subpixel_precision()
        check_error();
 }
 
-void get_extensions(std::set<std::string> *extensions)
-{
-       char *str = strdup(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
-       for (char *ptr = strtok(str, " "); ptr != NULL; ptr = strtok(NULL, " ")) {
-               extensions->insert(ptr);
-       }
-       free(str);
-}
-
 void check_extensions()
 {
-       std::set<std::string> extensions;
-       get_extensions(&extensions);
-
        // We fundamentally need FBOs and floating-point textures.
-       assert(extensions.count("GL_ARB_framebuffer_object") != 0);
-       assert(extensions.count("GL_ARB_texture_float") != 0);
+       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(extensions.count("GL_ARB_texture_non_power_of_two") != 0);
+       assert(glewIsSupported("GL_ARB_texture_non_power_of_two") != 0);
 
        // We also need GLSL fragment shaders.
-       assert(extensions.count("GL_ARB_fragment_shader") != 0);
-       assert(extensions.count("GL_ARB_shading_language_100") != 0);
+       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(extensions.count("GL_ARB_pixel_buffer_object") != 0);
+       assert(glewIsSupported("GL_ARB_pixel_buffer_object") != 0);
 
        // ResampleEffect uses RG textures to encode a two-component LUT.
-       assert(extensions.count("GL_ARB_texture_rg") != 0);
+       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 = extensions.count("GL_EXT_texture_sRGB");
+       movit_srgb_textures_supported = glewIsSupported("GL_EXT_texture_sRGB");
 }
 
 }  // namespace
@@ -168,6 +154,8 @@ void init_movit()
                return;
        }
 
+       glewInit();
+
        // geez 
        glPixelStorei(GL_PACK_ALIGNMENT, 1);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
index c26386c644ffa5cc2756646b825975fb4a29168e..3301d462104e3022094ddc9eb8c13003eabee072 100644 (file)
@@ -1,8 +1,8 @@
 #include <math.h>
+#include <GL/glew.h>
 
 #include "lift_gamma_gain_effect.h"
 #include "util.h"
-#include "opengl.h"
 
 LiftGammaGainEffect::LiftGammaGainEffect()
        : lift(0.0f, 0.0f, 0.0f),
diff --git a/opengl.h b/opengl.h
deleted file mode 100644 (file)
index 34079b7..0000000
--- a/opengl.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _OPENGL_H
-#define _OPENGL_H 1
-
-// A common place to find OpenGL includes, if your system should have them in weird places.
-
-#define GL_GLEXT_PROTOTYPES 1
-
-#include <GL/gl.h>
-#include <GL/glext.h>
-
-#endif  // !defined(_OPENGL_H)
index 5ab0468d41122c8d367e8d4907c5cdd2d5bc4a41..600b939ace7107b3db9fc7295ef4b13655b5a41e 100644 (file)
@@ -3,11 +3,11 @@
 
 #include <math.h>
 #include <assert.h>
+#include <GL/glew.h>
 
 #include "resample_effect.h"
 #include "effect_chain.h"
 #include "util.h"
-#include "opengl.h"
 
 namespace {
 
index 561048d416fd0241af4e4bac1c9edc34e9a4c1e3..3f24a42503c9fec5190e9f72b2a3c6d8b683929f 100644 (file)
@@ -1,9 +1,9 @@
 #include <math.h>
 #include <assert.h>
+#include <GL/glew.h>
 
 #include "sandbox_effect.h"
 #include "util.h"
-#include "opengl.h"
 
 SandboxEffect::SandboxEffect()
        : parm(0.0f)
index eeea198a4a074fa357311356d3157e7d00f15d36..62e0efcc314250505ea3513a159425e4a5a81580 100644 (file)
--- a/util.cpp
+++ b/util.cpp
@@ -1,10 +1,10 @@
 #include <stdio.h>
+#include <math.h>
 #include <string.h>
 #include <assert.h>
+#include <GL/glew.h>
 
-#include <math.h>
 #include "util.h"
-#include "opengl.h"
 #include "init.h"
 
 void hsv2rgb(float h, float s, float v, float *r, float *g, float *b)
diff --git a/util.h b/util.h
index b01d62c00f00588a21b2587e6387f649b6b3bdc1..8917dd3cf9e039c4ead7008d7d0a162af54d24ee 100644 (file)
--- a/util.h
+++ b/util.h
@@ -9,7 +9,7 @@
 #include <string>
 #include <Eigen/Core>
 
-#include "opengl.h"
+#include <GL/glew.h>
 
 #define BUFFER_OFFSET(i) ((char *)NULL + (i))
 
index f75b4ae762f47f2db0e6adf960a229f74d50cfc9..83aaa10e9c2ac51c6eb44b9be7cf104ac773fd71 100644 (file)
@@ -1,8 +1,8 @@
 #include <math.h>
+#include <GL/glew.h>
 
 #include "vignette_effect.h"
 #include "util.h"
-#include "opengl.h"
 
 VignetteEffect::VignetteEffect()
        : center(0.5f, 0.5f),
index d2e380aaea9c7a8810b7d291ef5e70a695bb4276..b00f0ca6b50b40705f31d7426379cf48388cf6d4 100644 (file)
@@ -1,11 +1,11 @@
 #include <math.h>
 #include <assert.h>
+#include <GL/glew.h>
 
 #include <Eigen/LU>
 
 #include "white_balance_effect.h"
 #include "util.h"
-#include "opengl.h"
 #include "d65.h"
 
 using namespace Eigen;
index 85fa04899697d35602c1a8c25f2b348b512f294a..5742e457a8117f9690de9c9aeec852e62a3a4f67 100644 (file)
@@ -1,8 +1,8 @@
 #include <math.h>
+#include <GL/glew.h>
 
 #include "widgets.h"
 #include "util.h"
-#include "opengl.h"
 
 #define HSV_WHEEL_SIZE 128
 
index fe36eb0488922cba13e8e640a6ab8fc7d50a4f01..958b9167f2ede78eba5b543f9eae54053d908de5 100644 (file)
@@ -1,11 +1,11 @@
 #include <string.h>
 #include <assert.h>
+#include <GL/glew.h>
 
 #include <Eigen/LU>
 
 #include "ycbcr_input.h"
 #include "util.h"
-#include "opengl.h"
 
 using namespace Eigen;