]> git.sesse.net Git - movit/commitdiff
Merge branch 'master' into epoxy
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 10 Mar 2014 00:28:46 +0000 (01:28 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 10 Mar 2014 00:31:54 +0000 (01:31 +0100)
76 files changed:
Makefile.in
README
alpha_division_effect_test.cpp
alpha_multiplication_effect_test.cpp
blur_effect.cpp
blur_effect.h
blur_effect_test.cpp
colorspace_conversion_effect_test.cpp
configure.ac
deconvolution_sharpen_effect.cpp
deconvolution_sharpen_effect.h
deconvolution_sharpen_effect_test.cpp
demo.cpp
diffusion_effect.h
diffusion_effect_test.cpp
dither_effect.cpp
dither_effect.h
dither_effect_test.cpp
effect.cpp
effect.h
effect_chain.cpp
effect_chain.h
effect_chain_test.cpp
effect_util.cpp
effect_util.h
fft_pass_effect.cpp
fft_pass_effect.h
fft_pass_effect_test.cpp
flat_input.cpp
flat_input.h
flat_input_test.cpp
gamma_compression_effect.h
gamma_compression_effect_test.cpp
gamma_expansion_effect.h
gamma_expansion_effect_test.cpp
glow_effect.h
glow_effect_test.cpp
gtest_sdl_main.cpp
init.cpp
lift_gamma_gain_effect.cpp
lift_gamma_gain_effect.h
lift_gamma_gain_effect_test.cpp
mix_effect_test.cpp
movit.pc.in
multiply_effect.h
overlay_effect_test.cpp
padding_effect.cpp
padding_effect.h
padding_effect_test.cpp
resample_effect.cpp
resample_effect.h
resample_effect_test.cpp
resource_pool.cpp
resource_pool.h
sandbox_effect.cpp
sandbox_effect.h
saturation_effect_test.cpp
slice_effect.cpp
slice_effect.h
slice_effect_test.cpp
test_util.cpp
test_util.h
unsharp_mask_effect.h
unsharp_mask_effect_test.cpp
util.cpp
util.h
vignette_effect.cpp
vignette_effect.h
vignette_effect_test.cpp
white_balance_effect.cpp
white_balance_effect.h
white_balance_effect_test.cpp
widgets.cpp
ycbcr_input.cpp
ycbcr_input.h
ycbcr_input_test.cpp

index db9628d22181c7b57dcfc708f939ea05976dc4bc..660bf7aba58c807be087161f3bcebd11aa7f95ac 100644 (file)
@@ -8,12 +8,16 @@ datarootdir = @datarootdir@
 datadir = @datadir@
 top_builddir = @top_builddir@
 with_demo_app = @with_demo_app@
+with_SDL2 = @with_SDL2@
 
 CC=@CC@
 CXX=@CXX@
-CXXFLAGS=-Wall @CXXFLAGS@ -I$(GTEST_DIR)/include @Eigen3_CFLAGS@ @GLEW_CFLAGS@
-LDFLAGS=@GLEW_LIBS@ @SDL_LIBS@ -lpthread
-DEMO_LDLIBS=@SDL_image_LIBS@ -lrt -lpthread @libpng_LIBS@
+CXXFLAGS=-Wall @CXXFLAGS@ -I$(GTEST_DIR)/include @SDL2_CFLAGS@ @SDL_CFLAGS@ @Eigen3_CFLAGS@ @epoxy_CFLAGS@
+ifeq ($(with_SDL2),yes)
+CXXFLAGS += -DHAVE_SDL2
+endif
+LDFLAGS=@epoxy_LIBS@ @SDL2_LIBS@ @SDL_LIBS@ -lpthread
+DEMO_LDLIBS=@SDL2_image_LIBS@ @SDL_image_LIBS@ -lrt -lpthread @libpng_LIBS@
 SHELL=@SHELL@
 LIBTOOL=@LIBTOOL@ --tag=CXX
 RANLIB=ranlib
diff --git a/README b/README
index 3f29bea69b8a7230c2309384f74aab8b885f03c7..81bb4c99e2f8428cca5b417c6fd7801c17a57103 100644 (file)
--- a/README
+++ b/README
@@ -21,12 +21,13 @@ OK, you need
   works fine on Linux and OS X, and Movit is not very POSIX-bound.)
 * GNU Make.
 * A GPU capable of running GLSL fragment shaders,
-  process floating-point textures, and a few other things. If your machine
-  is less than five years old _and you have the appropriate drivers_,
-  you're home free.
+  processing floating-point textures, and a few other things (all are
+  part of OpenGL 3.0 or newer, although most OpenGL 2.0 cards also
+  have what's needed through extensions). If your machine is less than five
+  years old _and you have the appropriate drivers_, you're home free.
 * The [Eigen 3] and [Google Test] libraries. (The library itself
   depends only on the former, but you probably want to run the unit tests.)
-* The [GLEW] library, for dealing with OpenGL extensions on various
+* The [epoxy] library, for dealing with OpenGL extensions on various
   platforms.
 
 Movit has been tested with Intel GPUs with the Mesa drivers
@@ -53,7 +54,8 @@ all research-grade problems, and Movit is currently not there.)
 TL;DR, but I am interested in a programming example instead
 ===========================================================
 
-Assuming you have an OpenGL context already set up:
+Assuming you have an OpenGL context already set up (currently you need
+a classic OpenGL context; a GL 3.2+ core context won't do):
 
 <code>
   using namespace movit;
index faa8b173b99648e8376ee44bd6801878422b26e8..549b5691f54c65bf2a5b6ea3c9bda761c76ec071 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for AlphaDivisionEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include "gtest/gtest.h"
 #include "image_format.h"
 #include "test_util.h"
index c63c0a3087841c3d90244b60dea312751b03acae..2aa9b6d98949d49dc9b554071e8474583e381487 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for AlphaMultiplicationEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include "effect_chain.h"
 #include "gtest/gtest.h"
index 9397ca423d429853a9a21c470217447ec688f2a3..b0327e2948307c0f5a92bd7de1dd537425fd93b5 100644 (file)
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <math.h>
 #include <algorithm>
index d97f5bdcd2b05352c331ddafb552783444ac8235..ad269f558e57c7112ab1ec07732d227705783048 100644 (file)
@@ -9,7 +9,7 @@
 // which is what the user is intended to use, instantiates two copies of
 // SingleBlurPassEffect behind the scenes).
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <stddef.h>
 #include <string>
index 1ef479ec478d8a9be52ac3f70d87a46be761bd62..fb4e0250ef333a0b5e4586ae88ac681d0463340b 100644 (file)
@@ -1,5 +1,5 @@
 // Unit tests for BlurEffect.
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <math.h>
 #include <string.h>
 
index cf8aad7e4bd41daa8a3737f578d9dc855b4d890d..1395140c81a480a910f8f8691efdae5256e50b04 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for ColorspaceConversionEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include "colorspace_conversion_effect.h"
 #include "gtest/gtest.h"
index 7515e6def9a1ef36969136ebb98e6d551a003fd5..79e99cadbaf0162dba9c83cf17968339ebed5261 100644 (file)
@@ -7,17 +7,26 @@ AC_CONFIG_SRCDIR(effect.cpp)
 AC_PROG_CC
 AC_PROG_CXX
 PKG_CHECK_MODULES([Eigen3], [eigen3])
-PKG_CHECK_MODULES([GLEW], [glew])
+PKG_CHECK_MODULES([epoxy], [epoxy])
 
-# Needed for unit tests and the demo app.
-PKG_CHECK_MODULES([SDL], [sdl])
+# Needed for unit tests and the demo app. We prefer SDL2 if possible,
+# but can also use classic SDL.
+with_SDL2=no
+with_demo_app=yes
+PKG_CHECK_MODULES([SDL2], [sdl2], [with_SDL2=yes], [
+  PKG_CHECK_MODULES([SDL], [sdl])
+])
 
 # These are only needed for the demo app.
-with_demo_app=yes
-PKG_CHECK_MODULES([SDL_image], [SDL_image], [], [with_demo_app=no; AC_MSG_WARN([SDL_image not found, demo program will not be built])])
+if test $with_SDL2 = "yes"; then
+  PKG_CHECK_MODULES([SDL2_image], [SDL2_image], [], [with_demo_app=no; AC_MSG_WARN([SDL2_image not found, demo program will not be built])])
+else
+  PKG_CHECK_MODULES([SDL_image], [SDL_image], [], [with_demo_app=no; AC_MSG_WARN([SDL_image not found, demo program will not be built])])
+fi
 PKG_CHECK_MODULES([libpng], [libpng12], [], [with_demo_app=no; AC_MSG_WARN([libpng12 not found, demo program will not be built])])
 
 AC_SUBST([with_demo_app])
+AC_SUBST([with_SDL2])
 
 AC_CONFIG_FILES([Makefile movit.pc])
 AC_OUTPUT
index f564b68c4bcc62f350b88ca929d46d4f4cd1bec3..c4ad5cd2cd699b65c223d505dc0fd88932b4e3e1 100644 (file)
@@ -4,7 +4,7 @@
 
 #include <Eigen/Dense>
 #include <Eigen/Cholesky>
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
index e4cc9a556d224e239e411b98c2c1596374ff182e..1f6807172d85444b6f77c4a93e89e0a0ea6144a3 100644 (file)
@@ -19,7 +19,7 @@
 //
 //   Jain, Anil K.: “Fundamentals of Digital Image Processing”, Prentice Hall, 1988.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <Eigen/Dense>
 #include <string>
 
index 8829b9da21de959685e7346cf7b4374a16b2e936..ab1a5a4a5fc50b48da348f5feba3180e54a0ac0c 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for DeconvolutionSharpenEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <math.h>
 #include <stdlib.h>
 
index 845a776d20859b67f829ed69e5070d59cf509132..c9b46ea7ed6f78f08be936cb1c5f6199e8d98141 100644 (file)
--- a/demo.cpp
+++ b/demo.cpp
@@ -4,7 +4,17 @@
 #define WIDTH 1280
 #define HEIGHT 720
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
+
+#ifdef HAVE_SDL2
+#include <SDL2/SDL.h>
+#include <SDL2/SDL_error.h>
+#include <SDL2/SDL_events.h>
+#include <SDL2/SDL_image.h>
+#include <SDL2/SDL_keyboard.h>
+#include <SDL2/SDL_mouse.h>
+#include <SDL2/SDL_video.h>
+#else
 #include <SDL/SDL.h>
 #include <SDL/SDL_error.h>
 #include <SDL/SDL_events.h>
@@ -13,6 +23,8 @@
 #include <SDL/SDL_keysym.h>
 #include <SDL/SDL_mouse.h>
 #include <SDL/SDL_video.h>
+#endif
+
 #include <assert.h>
 #include <features.h>
 #include <math.h>
@@ -121,9 +133,11 @@ unsigned char *load_image(const char *filename, unsigned *w, unsigned *h)
        rgba_fmt.Gshift = 8;
        rgba_fmt.Bshift = 0;
        rgba_fmt.Ashift = 24;
-       
+
+#ifndef HAVE_SDL2
        rgba_fmt.colorkey = 0;
        rgba_fmt.alpha = 255;
+#endif
 
        SDL_Surface *converted = SDL_ConvertSurface(img, &rgba_fmt, SDL_SWSURFACE);
 
@@ -175,8 +189,19 @@ int main(int argc, char **argv)
        SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
        SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+
+#ifdef HAVE_SDL2
+       SDL_Window *window = SDL_CreateWindow("OpenGL window",
+               SDL_WINDOWPOS_UNDEFINED,
+               SDL_WINDOWPOS_UNDEFINED,
+               WIDTH, HEIGHT,
+               SDL_WINDOW_OPENGL);
+       SDL_GLContext context = SDL_GL_CreateContext(window);
+       assert(context != NULL);
+#else
        SDL_SetVideoMode(WIDTH, HEIGHT, 0, SDL_OPENGL);
        SDL_WM_SetCaption("OpenGL window", NULL);
+#endif
 
        CHECK(init_movit(".", MOVIT_DEBUG_ON));
        printf("GPU texture subpixel precision: about %.1f bits\n",
@@ -288,7 +313,11 @@ int main(int argc, char **argv)
                draw_saturation_bar(0.75f, blur_radius / 100.0f);
                draw_saturation_bar(0.80f, blurred_mix_amount);
 
+#ifdef HAVE_SDL2
+               SDL_GL_SwapWindow(window);
+#else
                SDL_GL_SwapBuffers();
+#endif
                check_error();
 
                glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
index 2c31e4ae348524e23ba2b55e344a739d01b2092c..82eda939779b1addd847a9aa7d1cf4640817b7c0 100644 (file)
@@ -12,7 +12,7 @@
 // where we first blur the picture, and then overlay it on the original
 // using the original as a matte.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <string>
 
index 7e50a04d8bcc7071167b026aae8dcfcf84c30da6..e58c0deef941b2f9b65005fdddf058cc1f0ebe99 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for DiffusionEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include "diffusion_effect.h"
 #include "effect_chain.h"
index 72a38deb46490aac5e738a6bf19e48b674a6c45a..17c577d4cdacc3ae44a4c79015d46c6e888389d6 100644 (file)
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <stdio.h>
 #include <algorithm>
index 20fb025532d5fea4e92329c7733d06669354b39d..9818603c2a46f4a659628b68c03be5fed3f868ac 100644 (file)
@@ -43,7 +43,7 @@
 // like many LCD monitors do, but it starts to get very hairy, again, for limited gains.)
 // The dither is also deterministic across runs.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <string>
 
 #include "effect.h"
index 8801aa0f94022697976462f44ef3fb2c84f139ac..210a2e721e999047357b212a177863005b9e1fbd 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for DitherEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <math.h>
 
 #include "effect_chain.h"
index eded11a7ef5746a6563bd9f157019bb0abcc1a2c..fb66514a290d1cb780c6a87b2fae4b97a8d9627f 100644 (file)
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <stdio.h>
 #include <string.h>
index ce07df472e46327a45e0533650bd98163638232b..16b6cbb92149f7de70cf24d92d01a1182c8c343a 100644 (file)
--- a/effect.h
+++ b/effect.h
@@ -10,7 +10,7 @@
 // effect instance; use the macro PREFIX() around your identifiers to
 // automatically prepend that prefix.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <stddef.h>
 #include <map>
index 7d19ac3eb0df29861b5a19012d81d3f6d2810bde..41e026d3f43dbf977aeae3509ec90d6dcb1bd932 100644 (file)
@@ -1,6 +1,6 @@
 #define GL_GLEXT_PROTOTYPES 1
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <locale.h>
 #include <math.h>
index 642f079201f037219b1ead3c02aebf3e85bfb28d..4c3232b5f7dbca5a67f55a005775278c37d904d9 100644 (file)
@@ -17,7 +17,7 @@
 // the EffectChain holds textures and other OpenGL objects that are tied to the
 // context.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <stdio.h>
 #include <map>
 #include <set>
index cf725f1131bb1eae8a1722c1e2989893d8c178be..67b3dfc56aa7567678624884818242b40b1d5487 100644 (file)
@@ -2,7 +2,7 @@
 //
 // Note that this also contains the tests for some of the simpler effects.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 
 #include "effect.h"
index 35a94a7c3e999b0ebc2795f92b40e0d10d0009cb..b671620388719b4e7943698124f3fe175c40ab01 100644 (file)
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <Eigen/Core>
 #include <stddef.h>
 #include <string>
index 65bd315855c5f004b2ec73bc6dc73f3b3c96aaec..da0f95a4d66a492bc3f24e41f7eb9e836a28ed07 100644 (file)
@@ -4,7 +4,7 @@
 // Utilities that are often useful for implementing Effect instances,
 // but don't need to be included from effect.h.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <stddef.h>
 #include <Eigen/Core>
index c2b47f047c0747459b92682895be7b9a147f5de2..ec550b2846be60cfa1ae24398903496e9f9e66ec 100644 (file)
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <math.h>
 
 #include "effect_util.h"
index 1fd4ea2c1886ed0bd6fb1f358954989770e0e5da..501c562700716ba3e0969595af950fdefb46d53f 100644 (file)
@@ -50,7 +50,7 @@
 // scaling), and as fp16 has quite limited range at times, this can be relevant
 // on some GPUs for larger sizes.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <stdio.h>
 #include <string>
index eb4e37cf3c439addad6c8726b607a209dda0ef7c..01527b8b804e01901e38e8ae63e52ebb29ed4940 100644 (file)
@@ -3,11 +3,11 @@
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
+#include <epoxy/gl.h>
+#include <gtest/gtest.h>
 
 #include "effect_chain.h"
 #include "fft_pass_effect.h"
-#include "glew.h"
-#include "gtest/gtest.h"
 #include "image_format.h"
 #include "multiply_effect.h"
 #include "test_util.h"
index b8ea70637876e358b8378312d5f3a46bf75a99ad..6036cf724c30cf97202ba7e9a1906663d679bb32 100644 (file)
@@ -1,6 +1,6 @@
 #include <string.h>
 #include <assert.h>
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include "effect_util.h"
 #include "flat_input.h"
index 12a94d9df06712ce7d8e88aface028c8a699d068..caa68b77900fcbff7e2db2ab7999e66f40d0d942 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _MOVIT_FLAT_INPUT_H
 #define _MOVIT_FLAT_INPUT_H 1
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <string>
 
index 58d9eb94b199a2c807c7a44397e23caed79eba69..397cae3c26d788f7abe5ed10ba064f23b60d2cbd 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for FlatInput.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <stddef.h>
 
 #include "effect_chain.h"
index 83208cf0dcc44d77412c5a595f6cab9906b75e0a..ee3985f9fa03c807b2928dac5176e9b0baf58eff 100644 (file)
@@ -9,7 +9,7 @@
 // Note that Movit's internal formats generally do not have enough accuracy
 // for 12-bit input or output.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <string>
 
 #include "effect.h"
index 41fe776c28079e1783d05065fcd6bc0d80796db2..6efbdea0944211a82e157518b616fb71b0cdf0a1 100644 (file)
@@ -5,7 +5,7 @@
 // However, the accuracy tests are somewhat simpler, since we
 // only need to care about absolute errors and not relative.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <math.h>
 
 #include "gtest/gtest.h"
index b5381ad38cdc76fa3b5aa2eb01da20df64111c4b..81f42d137392cf7e0c08ba557f3a3d090f708f7f 100644 (file)
@@ -9,7 +9,7 @@
 // Note that Movit's internal formats generally do not have enough accuracy
 // for 12-bit input or output.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <string>
 
 #include "effect.h"
index d1d6d2a0ac0afabac906311adb5812e7ef17858f..499a0d47caba00a71cdc068a9fb956d7759df292 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for GammaExpansionEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <math.h>
 
 #include "gamma_expansion_effect.h"
index af833070558a05ce46e4aa5865516da0714cd740..2a2af16dd3abbd7d1bded97de0aaad88475b63bf 100644 (file)
@@ -4,7 +4,7 @@
 // Glow: Cut out the highlights of the image (everything above a certain threshold),
 // blur them, and overlay them onto the original image.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <string>
 
index 11083a9ca75a3412fe88a9c6b2e4c4914df6b7d5..174937be5fae6fb47f8c488a4dbef9bcf29bd606 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for GlowEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <math.h>
 
 #include "effect_chain.h"
index 39027e6be3246f75fae37a09d333859920ff539b..cd68777721e19cc92b300920fd094473ef5d5a7d 100644 (file)
@@ -1,8 +1,14 @@
 #define GTEST_HAS_EXCEPTIONS 0
 
+#ifdef HAVE_SDL2
+#include <SDL2/SDL.h>
+#include <SDL2/SDL_error.h>
+#include <SDL2/SDL_video.h>
+#else
 #include <SDL/SDL.h>
 #include <SDL/SDL_error.h>
 #include <SDL/SDL_video.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -17,8 +23,28 @@ int main(int argc, char **argv) {
        SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
        SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+
+#ifdef HAVE_SDL2
+       // You can uncomment this if you want to try a core context.
+       // For Mesa, you can get the same effect by doing
+       //
+       //   export MESA_GL_VERSION_OVERRIDE=3.1FC
+       //
+       // before running tests.
+//     SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
+//     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
+//     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
+       SDL_Window *window = SDL_CreateWindow("OpenGL window for unit test",
+               SDL_WINDOWPOS_UNDEFINED,
+               SDL_WINDOWPOS_UNDEFINED,
+               32, 32,
+               SDL_WINDOW_OPENGL);
+       SDL_GLContext context = SDL_GL_CreateContext(window);
+       assert(context != NULL);
+#else
        SDL_SetVideoMode(32, 32, 0, SDL_OPENGL);
        SDL_WM_SetCaption("OpenGL window for unit test", NULL);
+#endif
 
        testing::InitGoogleTest(&argc, argv);
        int err = RUN_ALL_TESTS();
index 13a86df236d5ea909dc269c8f8af827e1b7b5a35..671c507c5588c7faf5783b7f0a500d1780fc9162 100644 (file)
--- a/init.cpp
+++ b/init.cpp
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <stddef.h>
 #include <algorithm>
@@ -278,32 +278,43 @@ void measure_roundoff_problems()
 bool check_extensions()
 {
        // We fundamentally need FBOs and floating-point textures.
-       if (!glewIsSupported("GL_ARB_framebuffer_object")) return false;
-       if (!glewIsSupported("GL_ARB_texture_float")) return false;
+       // FBOs are covered by OpenGL 1.5, and are not an extension there.
+       // Floating-point textures are part of OpenGL 3.0 and newer.
+       if (epoxy_gl_version() < 15 &&
+           !epoxy_has_gl_extension("GL_ARB_framebuffer_object")) return false;
+       if (epoxy_gl_version() < 30 &&
+           !epoxy_has_gl_extension("GL_ARB_texture_float")) return false;
 
        // We assume that we can use non-power-of-two textures without restrictions.
-       if (!glewIsSupported("GL_ARB_texture_non_power_of_two")) return false;
+       if (epoxy_gl_version() < 20 &&
+           !epoxy_has_gl_extension("GL_ARB_texture_non_power_of_two")) return false;
 
        // We also need GLSL fragment shaders.
-       if (!glewIsSupported("GL_ARB_fragment_shader")) return false;
-       if (!glewIsSupported("GL_ARB_shading_language_100")) return false;
+       if (epoxy_gl_version() < 20) {
+               if (!epoxy_has_gl_extension("GL_ARB_fragment_shader")) return false;
+               if (!epoxy_has_gl_extension("GL_ARB_shading_language_100")) return false;
+       }
 
        // FlatInput and YCbCrInput uses PBOs. (They could in theory do without,
        // but no modern card would really not provide it.)
-       if (!glewIsSupported("GL_ARB_pixel_buffer_object")) return false;
+       if (epoxy_gl_version() < 21 &&
+           !epoxy_has_gl_extension("GL_ARB_pixel_buffer_object")) return false;
 
        // ResampleEffect uses RG textures to encode a two-component LUT.
-       if (!glewIsSupported("GL_ARB_texture_rg")) return false;
+       if (epoxy_gl_version() < 30 &&
+           !epoxy_has_gl_extension("GL_ARB_texture_rg")) return false;
 
        // 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");
+       movit_srgb_textures_supported =
+               (epoxy_gl_version() >= 21 || epoxy_has_gl_extension("GL_EXT_texture_sRGB"));
 
        // We may want to use round() at the end of the final shader,
        // if supported. We need either GLSL 1.30 or this extension to do that,
        // and 1.30 brings with it other things that we don't want to demand
        // for now.
-       movit_shader_rounding_supported = glewIsSupported("GL_EXT_gpu_shader4");
+       movit_shader_rounding_supported =
+               (epoxy_gl_version() >= 30 || epoxy_has_gl_extension("GL_EXT_gpu_shader4"));
 
        return true;
 }
@@ -319,11 +330,6 @@ bool init_movit(const string& data_directory, MovitDebugLevel debug_level)
        movit_data_directory = new string(data_directory);
        movit_debug_level = debug_level;
 
-       GLenum err = glewInit();
-       if (err != GLEW_OK) {
-               return false;
-       }
-
        // geez 
        glPixelStorei(GL_PACK_ALIGNMENT, 1);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
index e9832f458a6cb83f07cbe86de93aefb2f0462043..60cd7df5f2b1c2cef74128fdab446335aa945fbb 100644 (file)
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <math.h>
 
 #include "effect_util.h"
index b5007721710b28173130e6701650474df57cc20d..c93724d8b8fe2ae10150feb4cad8096ebfbce5dc 100644 (file)
@@ -20,7 +20,7 @@
 // Also, gamma is a case where we would not want premultiplied alpha.
 // Thus, we have to divide away alpha first, and then re-multiply it back later.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <string>
 
 #include "effect.h"
index 612901f4a2cfcd1feab73a6c1e58d2a4041c81a4..1be2847a91ee3d0c5260333461462a5452f3494a 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for LiftGammaGainEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include "effect_chain.h"
 #include "gtest/gtest.h"
index 8432f1e1a96b7c6145e991cf732b3b50500323eb..7e54ca5690c6777540afa47c447116c028b1eebf 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for MixEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include "effect_chain.h"
 #include "gtest/gtest.h"
index f990618dcf8ff88973dcb4b227524138280078a6..6069a06e4d72f0b468f97ef979b1f629b4cd8e60 100644 (file)
@@ -13,5 +13,5 @@ Description: Movit is a library for high-quality, high-performance video filters
 Version: git
 Requires:
 Conflicts:
-Libs: -lmovit @GLEW_LIBS@
-Cflags: -I${includedir}/movit @Eigen3_CFLAGS@ @GLEW_CFLAGS@
+Libs: -lmovit @epoxy_LIBS@
+Cflags: -I${includedir}/movit @Eigen3_CFLAGS@ @epoxy_CFLAGS@
index 50612fc941f1a5bf50894d39437bd872225034ad..92e98e30944ec61eedca44e75e27276cef26a609 100644 (file)
@@ -6,7 +6,7 @@
 // sending it through OverlayEffect, e.g. with R=G=B=A=0.3 to get 30% alpha
 // (remember, alpha is premultiplied).
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <string>
 
 #include "effect.h"
index 0a9682e0392e8e2c61959d9565f30695ac1c28c1..47c39b5bf03b1d6ce0ca96aa7a424693bc94abf6 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for OverlayEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include "effect_chain.h"
 #include "gtest/gtest.h"
index 15381a32567e7bdd6ffed157c8aea6b52cdf4aff..f576baa2d5c3f8cb043a0395cdd3d3314a7bdd90 100644 (file)
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 
 #include "effect_util.h"
index 3bd4aacb321a54c80ce98e23526d941a9f1bce58..901f892b9dd14f999776f823bb897370f32d25d5 100644 (file)
@@ -12,7 +12,7 @@
 // You may not change it after calling finalize(), since that could change the
 // graph (need_linear_light() etc. depend on the border color you choose).
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <string>
 
 #include "effect.h"
index 767f3e8d4f3a79c654553c3aa9e843f57e629ef4..dd836ea066ee527dd6f5af3aaa6c4415eeebe28b 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for AlphaMultiplicationEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <stddef.h>
 
 #include "effect_chain.h"
index 4af60de7d3c47c6089a560f0d23c2ce62594cd81..b988e5af8eb656d2110352f7339e090d799c95c7 100644 (file)
@@ -1,7 +1,7 @@
 // Three-lobed Lanczos, the most common choice.
 #define LANCZOS_RADIUS 3.0
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <limits.h>
 #include <math.h>
index 628c61a348ea3ba22904370a4a572f753dfed8aa..24e637260ea97489d54080bef521572bc68d8b05 100644 (file)
@@ -15,7 +15,7 @@
 // which is what the user is intended to use, instantiates two copies of
 // SingleResamplePassEffect behind the scenes).
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <stddef.h>
 #include <string>
index 211e6d123e65d93dbcc075f60ea8371b1eaa5736..95c2bcfb9aec95693653ea65572cfdca76f79699 100644 (file)
@@ -1,12 +1,11 @@
 // Unit tests for ResampleEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
+#include <gtest/gtest.h>
 #include <math.h>
 
 #include "effect_chain.h"
 #include "flat_input.h"
-#include "glew.h"
-#include "gtest/gtest.h"
 #include "image_format.h"
 #include "resample_effect.h"
 #include "test_util.h"
index 72b309519062b728d7b1b6ae73d05c0cc5086c9d..b515769e4e8d49a6664e418d02745a171df1fb86 100644 (file)
@@ -6,8 +6,8 @@
 #include <map>
 #include <string>
 #include <utility>
+#include <epoxy/gl.h>
 
-#include "glew.h"
 #include "init.h"
 #include "resource_pool.h"
 #include "util.h"
index ea56d0184fd6f1a49d4238034d526acfd3672185..d8d8ceca3ca1deb2b50dfd2b45fa256af908beeb 100644 (file)
@@ -16,7 +16,7 @@
 // safely called from multiple threads at the same time, provided they have
 // separate (but sharing) OpenGL contexts.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <pthread.h>
 #include <stddef.h>
 #include <list>
index 76e1f5cf81625944f3f0df1faa3d1ccef5f31121..1ec093d43fbda2fd9bb370f076f9fbd6aadb9c1a 100644 (file)
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include "sandbox_effect.h"
 #include "util.h"
index f06b2ef3758d17cb95f014f0d7a1e0508a1218df..25c79920109cbbdbf1d0418c41566df863a037df 100644 (file)
@@ -8,7 +8,7 @@
 // throwaway code. When you're happy, you can do a bit of search and replace
 // to give it a proper name and its own place in the build system.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <string>
 
 #include "effect.h"
index 941df9924bfbeb4ee5642b37c490fb793a1560e4..6a711a42a25d5f0799a3fc54298f4d1041aa3aac 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for SaturationEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include "effect_chain.h"
 #include "gtest/gtest.h"
index 09b91b90a9a4b03c291875948f844ea63590194e..3cdd415251d880577b3d47456edb471c8a4798fb 100644 (file)
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include "slice_effect.h"
 #include "effect_util.h"
index 6380c1665279078623a802c9ccf2f7db4f17574d..3448941873aebbfef9067e682d906fafc0308805 100644 (file)
@@ -10,7 +10,7 @@
 // Note that vertical slices happen from the bottom, not the top, due to the
 // OpenGL coordinate system.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <string>
 
 #include "effect.h"
index efa6803fdbd7225d02c2c2d12b69e64b5730aa92..410439abcb606cd9a13be2f4017a797093ea6a7c 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for SliceEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include "effect_chain.h"
 #include "flat_input.h"
index cb972364d000b45ee57ab4024f2a141c1d6576b4..ec9cbf947a5bcbd7b518677f44f279c7972df301 100644 (file)
@@ -2,11 +2,11 @@
 #include <math.h>
 #include <stdio.h>
 #include <algorithm>
+#include <epoxy/gl.h>
+#include <gtest/gtest.h>
+#include <gtest/gtest-message.h>
 
 #include "flat_input.h"
-#include "glew.h"
-#include "gtest/gtest.h"
-#include "gtest/gtest-message.h"
 #include "init.h"
 #include "resource_pool.h"
 #include "test_util.h"
index ff568ba83056f108deca35f4d20078fed7b35347..e5e65513ddb82914758162080fabae40e039a7de 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _MOVIT_TEST_UTIL_H
 #define _MOVIT_TEST_UTIL_H 1
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include "effect_chain.h"
 #include "image_format.h"
 
index e6d3790b86a1a6763ba1f00b627a00fe5bc73765..7a2052b5b4ef4e81c6dd0418ae524033381333e0 100644 (file)
@@ -10,7 +10,7 @@
 // See DeconvolutionSharpenEffect for a different, possibly better
 // sharpening algorithm.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <string>
 
index 69ea5f706af5a31e025c790cf7c524619632c4fd..e6750ce8156d6fff8856a69daaab93a69c1907f1 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for UnsharpMaskEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <math.h>
 
 #include "effect_chain.h"
index 8162f712d02eed8f5b47b7f481b977b827f56f8f..372064b28948238c1c30815f7cb9cdb82087128f 100644 (file)
--- a/util.cpp
+++ b/util.cpp
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
diff --git a/util.h b/util.h
index c59231d205d2537c4ec965a4b5b85cf4162ff8f4..5c15c9f789fceda67e764002413d053911524806 100644 (file)
--- a/util.h
+++ b/util.h
@@ -3,7 +3,7 @@
 
 // Various utilities.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <Eigen/Core>
index 94383ff4839aee7010d78777d84d21c9d711d741..d8b4f9bf24d674fc1cf6b815e7e6f07c16e8ff78 100644 (file)
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <math.h>
 
index 737a834cb68556a063404063a0e92a18f5be88c9..fdf1a116502b8be220b74cacca1432539daec206 100644 (file)
@@ -4,7 +4,7 @@
 // A circular vignette, falling off as cos² of the distance from the center
 // (the classic formula for approximating a real lens).
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <string>
 
 #include "effect.h"
index 9c28852dfdbbf5045d5364b593b7601fa8dc37ae..010fbc4827a21b3a286e89bdf38d5dc948908b4b 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for VignetteEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <math.h>
 
 #include "effect_chain.h"
index 0aa85da66f0159ca7bfd94e8b7ff1e132c73746a..69759adfc6148379698998674109a5ae17213e4b 100644 (file)
@@ -1,6 +1,6 @@
 #include <Eigen/Core>
 #include <Eigen/LU>
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 
 #include "colorspace_conversion_effect.h"
index 43bfccb1f132bf93d01ae57a7aaad481647c6e3d..f438b91507a00b579d9eac697a3f619ac4527096 100644 (file)
@@ -3,7 +3,7 @@
 
 // Color correction in LMS color space.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <string>
 
 #include "effect.h"
index 5d51dd89a46abec302bb19c1e6f73482d18e74b3..b0642077e5c039143f23574f5d9d9ca7655f0077 100644 (file)
@@ -1,6 +1,6 @@
 // Unit tests for WhiteBalanceEffect.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include "effect_chain.h"
 #include "gtest/gtest.h"
index 3bf53c77e428530dc5b731f33460077b35db2f27..87260215e2b1b4bb3f2e916c98e9e1d4adb37a37 100644 (file)
@@ -1,4 +1,4 @@
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <math.h>
 
 #include "widgets.h"
index 49747151532ae5863de08fdf0016964cbb2cd30e..dc5e4d9fd2db9e619d9b680583b6c1f514f65220 100644 (file)
@@ -1,6 +1,6 @@
 #include <Eigen/Core>
 #include <Eigen/LU>
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <stdio.h>
 #include <string.h>
index 2466eedf0307beb7e6f613ea9695cef740d20437..bf6d800eeb0c918c1b535bd2f6bf2c65c0bfa354 100644 (file)
@@ -5,7 +5,7 @@
 // imprecisely, called “YUV”), which is typically what you get from a video decoder.
 // It upsamples planes as needed, using the default linear upsampling OpenGL gives you.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <string>
 
index 352fe290dffc4143c27a44e62bf27bef842f2980..6895b3834a62602aa293c012957638684b471074 100644 (file)
@@ -1,7 +1,7 @@
 // Unit tests for YCbCrInput.
 // FIXME: This class really ought to support mipmaps.
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <stddef.h>
 
 #include "effect_chain.h"