From 29072985d0a00a53e5b578a1444cee61a0c9e1f2 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 9 Jan 2013 20:12:06 +0100 Subject: [PATCH] Change to using GLEW everywhere. 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. --- Makefile | 14 +++++++++++-- blur_effect.cpp | 2 +- deconvolution_sharpen_effect.cpp | 2 +- demo.cpp | 3 ++- dither_effect.cpp | 2 +- effect.cpp | 4 ++-- effect.h | 2 +- effect_chain.cpp | 2 +- effect_chain_test.cpp | 3 ++- flat_input.cpp | 2 +- init.cpp | 36 +++++++++++--------------------- lift_gamma_gain_effect.cpp | 2 +- opengl.h | 11 ---------- resample_effect.cpp | 2 +- sandbox_effect.cpp | 2 +- util.cpp | 4 ++-- util.h | 2 +- vignette_effect.cpp | 2 +- white_balance_effect.cpp | 2 +- widgets.cpp | 2 +- ycbcr_input.cpp | 2 +- 21 files changed, 46 insertions(+), 57 deletions(-) delete mode 100644 opengl.h diff --git a/Makefile b/Makefile index cd1a4b8..8396ac6 100644 --- 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) diff --git a/blur_effect.cpp b/blur_effect.cpp index 80ccb3f..7723853 100644 --- a/blur_effect.cpp +++ b/blur_effect.cpp @@ -1,10 +1,10 @@ #include #include +#include #include "blur_effect.h" #include "effect_chain.h" #include "util.h" -#include "opengl.h" // Must match blur_effect.frag. #define NUM_TAPS 16 diff --git a/deconvolution_sharpen_effect.cpp b/deconvolution_sharpen_effect.cpp index 38cf0cf..2d32ecd 100644 --- a/deconvolution_sharpen_effect.cpp +++ b/deconvolution_sharpen_effect.cpp @@ -5,12 +5,12 @@ #include #include +#include #include #include #include "deconvolution_sharpen_effect.h" #include "util.h" -#include "opengl.h" using namespace Eigen; diff --git a/demo.cpp b/demo.cpp index cd6cf88..99fec55 100644 --- a/demo.cpp +++ b/demo.cpp @@ -14,6 +14,8 @@ #include #include +#include + #include #include #include @@ -22,7 +24,6 @@ #include "effect.h" #include "effect_chain.h" #include "util.h" -#include "opengl.h" #include "widgets.h" #include "flat_input.h" diff --git a/dither_effect.cpp b/dither_effect.cpp index 87e729a..1399c81 100644 --- a/dither_effect.cpp +++ b/dither_effect.cpp @@ -1,9 +1,9 @@ #include #include +#include #include "dither_effect.h" #include "util.h" -#include "opengl.h" namespace { diff --git a/effect.cpp b/effect.cpp index 9ff200b..384e8c2 100644 --- a/effect.cpp +++ b/effect.cpp @@ -1,12 +1,12 @@ #include #include #include +#include + #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; diff --git a/effect.h b/effect.h index 21068ef..235558f 100644 --- a/effect.h +++ b/effect.h @@ -18,7 +18,7 @@ #include -#include "opengl.h" +#include #include "util.h" class EffectChain; diff --git a/effect_chain.cpp b/effect_chain.cpp index 4916265..05deb76 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -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), diff --git a/effect_chain_test.cpp b/effect_chain_test.cpp index d8ade13..21cb2be 100644 --- a/effect_chain_test.cpp +++ b/effect_chain_test.cpp @@ -2,12 +2,13 @@ // // Note that this also contains the tests for some of the simpler effects. +#include + #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) { diff --git a/flat_input.cpp b/flat_input.cpp index b37a1ec..291bb0d 100644 --- a/flat_input.cpp +++ b/flat_input.cpp @@ -1,9 +1,9 @@ #include #include +#include #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), diff --git a/init.cpp b/init.cpp index ac52aa2..a89028c 100644 --- a/init.cpp +++ b/init.cpp @@ -1,10 +1,8 @@ +#include + #include "init.h" -#include "opengl.h" #include "util.h" -#include -#include - 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 *extensions) -{ - char *str = strdup(reinterpret_cast(glGetString(GL_EXTENSIONS))); - for (char *ptr = strtok(str, " "); ptr != NULL; ptr = strtok(NULL, " ")) { - extensions->insert(ptr); - } - free(str); -} - void check_extensions() { - std::set 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); diff --git a/lift_gamma_gain_effect.cpp b/lift_gamma_gain_effect.cpp index c26386c..3301d46 100644 --- a/lift_gamma_gain_effect.cpp +++ b/lift_gamma_gain_effect.cpp @@ -1,8 +1,8 @@ #include +#include #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 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 -#include - -#endif // !defined(_OPENGL_H) diff --git a/resample_effect.cpp b/resample_effect.cpp index 5ab0468..600b939 100644 --- a/resample_effect.cpp +++ b/resample_effect.cpp @@ -3,11 +3,11 @@ #include #include +#include #include "resample_effect.h" #include "effect_chain.h" #include "util.h" -#include "opengl.h" namespace { diff --git a/sandbox_effect.cpp b/sandbox_effect.cpp index 561048d..3f24a42 100644 --- a/sandbox_effect.cpp +++ b/sandbox_effect.cpp @@ -1,9 +1,9 @@ #include #include +#include #include "sandbox_effect.h" #include "util.h" -#include "opengl.h" SandboxEffect::SandboxEffect() : parm(0.0f) diff --git a/util.cpp b/util.cpp index eeea198..62e0efc 100644 --- a/util.cpp +++ b/util.cpp @@ -1,10 +1,10 @@ #include +#include #include #include +#include -#include #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 b01d62c..8917dd3 100644 --- a/util.h +++ b/util.h @@ -9,7 +9,7 @@ #include #include -#include "opengl.h" +#include #define BUFFER_OFFSET(i) ((char *)NULL + (i)) diff --git a/vignette_effect.cpp b/vignette_effect.cpp index f75b4ae..83aaa10 100644 --- a/vignette_effect.cpp +++ b/vignette_effect.cpp @@ -1,8 +1,8 @@ #include +#include #include "vignette_effect.h" #include "util.h" -#include "opengl.h" VignetteEffect::VignetteEffect() : center(0.5f, 0.5f), diff --git a/white_balance_effect.cpp b/white_balance_effect.cpp index d2e380a..b00f0ca 100644 --- a/white_balance_effect.cpp +++ b/white_balance_effect.cpp @@ -1,11 +1,11 @@ #include #include +#include #include #include "white_balance_effect.h" #include "util.h" -#include "opengl.h" #include "d65.h" using namespace Eigen; diff --git a/widgets.cpp b/widgets.cpp index 85fa048..5742e45 100644 --- a/widgets.cpp +++ b/widgets.cpp @@ -1,8 +1,8 @@ #include +#include #include "widgets.h" #include "util.h" -#include "opengl.h" #define HSV_WHEEL_SIZE 128 diff --git a/ycbcr_input.cpp b/ycbcr_input.cpp index fe36eb0..958b916 100644 --- a/ycbcr_input.cpp +++ b/ycbcr_input.cpp @@ -1,11 +1,11 @@ #include #include +#include #include #include "ycbcr_input.h" #include "util.h" -#include "opengl.h" using namespace Eigen; -- 2.39.2