Blob Blame History Raw
From 6562e12885fa2abf1a1bf0d606b08e00c4547934 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Fri, 25 Nov 2016 20:25:27 +0000
Subject: [PATCH] change from glew to epoxy

cause that works under wayland out of the box and gtk3 uses it already

Change-Id: Iefaac31e325534a81a5389f752804af917c1baef
---
 Makefile.fetch                                     |  2 +-
 RepositoryExternal.mk                              | 46 +++++++++------------
 avmedia/Library_avmedia.mk                         |  2 +-
 avmedia/Library_avmediaogl.mk                      |  6 +--
 bin/check-elf-dynamic-objects                      |  2 +-
 bin/lo-all-static-libs                             |  2 +-
 canvas/Library_oglcanvas.mk                        |  7 +---
 canvas/source/opengl/ogl_buffercontext.hxx         |  2 +-
 canvas/source/opengl/ogl_canvascustomsprite.cxx    |  2 +-
 canvas/source/opengl/ogl_canvashelper.cxx          |  2 +-
 canvas/source/opengl/ogl_canvastools.cxx           |  2 +-
 canvas/source/opengl/ogl_texturecache.cxx          |  2 +-
 canvas/source/opengl/ogl_tools.hxx                 |  3 +-
 chart2/Library_chartcore.mk                        |  9 +---
 chart2/Library_chartopengl.mk                      |  4 +-
 chart2/inc/pch/precompiled_chartcore.hxx           |  2 +-
 chart2/source/view/charttypes/GL3DBarChart.cxx     |  2 +-
 chart2/source/view/main/GL3DRenderer.cxx           |  8 ++--
 chart2/source/view/main/OpenGLRender.cxx           |  2 +-
 config_host.mk.in                                  |  6 +--
 config_host/config_opengl.h.in                     | 10 -----
 configure.ac                                       | 21 +++++-----
 cui/Library_cui.mk                                 |  2 +-
 distro-configs/LibreOfficeFlatpak.conf             |  1 -
 download.lst                                       |  7 ++--
 external/Module_external.mk                        |  2 +-
 external/glew/ExternalPackage_glew.mk              | 33 ---------------
 external/glew/ExternalProject_glew.mk              | 36 ----------------
 external/glew/Makefile                             |  7 ----
 external/glew/Module_glew.mk                       | 18 --------
 external/glew/README                               |  6 ---
 external/glew/UnpackedTarball_glew.mk              | 48 ----------------------
 external/glew/glew-macosx-install-name.patch.1     | 13 ------
 external/glew/glew-msvc-disable-sse2.patch.1       | 10 -----
 external/glew/glew-static-only.patch.1             | 12 ------
 external/glew/glew-tmpdir.patch.1                  | 13 ------
 external/glew/glew_use_CC_variable.patch.1         | 24 -----------
 external/libgltf/ExternalProject_libgltf.mk        | 10 ++---
 external/libgltf/libgltf-msvc-x64.patch.1          | 31 +++++++-------
 include/vcl/opengl/OpenGLContext.hxx               |  6 +--
 include/vcl/opengl/OpenGLHelper.hxx                |  2 +-
 include/vcl/opengl/OpenGLWrapper.hxx               |  2 +-
 slideshow/Library_OGLTrans.mk                      |  9 +---
 slideshow/Library_slideshow.mk                     |  2 +-
 slideshow/source/engine/opengl/TransitionImpl.cxx  |  1 -
 slideshow/source/engine/opengl/TransitionImpl.hxx  |  3 +-
 .../source/engine/opengl/TransitionerImpl.cxx      |  2 +-
 svx/Library_svxcore.mk                             |  2 +-
 toolkit/Library_tk.mk                              |  2 +-
 vcl/CppunitTest_vcl_bitmap_test.mk                 |  2 +-
 vcl/CppunitTest_vcl_wmf_test.mk                    |  4 +-
 vcl/Executable_icontest.mk                         |  2 +-
 vcl/Executable_vcldemo.mk                          |  2 +-
 vcl/Executable_visualbackendtest.mk                |  1 -
 vcl/Library_vcl.mk                                 |  3 +-
 vcl/Library_vclplug_gen.mk                         |  3 +-
 vcl/Library_vclplug_gtk.mk                         |  2 +-
 vcl/Library_vclplug_gtk3.mk                        |  2 +-
 vcl/Library_vclplug_kde4.mk                        |  2 +-
 vcl/inc/opengl/LineRenderUtils.hxx                 |  1 -
 vcl/inc/opengl/VertexUtils.hxx                     |  2 +-
 vcl/inc/opengl/framebuffer.hxx                     |  1 -
 vcl/inc/opengl/program.hxx                         |  1 -
 vcl/inc/opengl/texture.hxx                         |  2 +-
 vcl/inc/pch/precompiled_vcl.hxx                    |  2 +-
 vcl/inc/unx/saldisp.hxx                            |  2 +-
 vcl/opengl/x11/gdiimpl.cxx                         | 31 ++++++--------
 vcl/osx/salobj.cxx                                 |  4 +-
 vcl/source/opengl/OpenGLContext.cxx                | 34 +++------------
 vcl/source/opengl/OpenGLHelper.cxx                 |  8 ++--
 vcl/unx/generic/app/saldisp.cxx                    |  1 -
 vcl/workben/icontest.cxx                           |  2 -
 72 files changed, 128 insertions(+), 434 deletions(-)
 delete mode 100644 config_host/config_opengl.h.in
 delete mode 100644 external/glew/ExternalPackage_glew.mk
 delete mode 100644 external/glew/ExternalProject_glew.mk
 delete mode 100644 external/glew/Makefile
 delete mode 100644 external/glew/Module_glew.mk
 delete mode 100644 external/glew/README
 delete mode 100644 external/glew/UnpackedTarball_glew.mk
 delete mode 100644 external/glew/glew-macosx-install-name.patch.1
 delete mode 100644 external/glew/glew-msvc-disable-sse2.patch.1
 delete mode 100644 external/glew/glew-static-only.patch.1
 delete mode 100644 external/glew/glew-tmpdir.patch.1
 delete mode 100644 external/glew/glew_use_CC_variable.patch.1

diff --git a/Makefile.fetch b/Makefile.fetch
index 3e21be3..cf31e5b 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -129,7 +129,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_host.mk $(SRCDIR)/download.lst $(SRCDIR)
 		$(call fetch_Optional,FONTCONFIG,FONTCONFIG_TARBALL) \
 		$(call fetch_Optional,FREEHAND,FREEHAND_TARBALL) \
 		$(call fetch_Optional,FREETYPE,FREETYPE_TARBALL) \
-		$(call fetch_Optional,GLEW,GLEW_TARBALL) \
+		$(call fetch_Optional,EPOXY,EPOXY_TARBALL) \
 		$(call fetch_Optional,GLM,GLM_TARBALL) \
 		$(call fetch_Optional_pack,GOOGLE_DOCS_EXTENSION_PACK) \
 		$(call fetch_Optional,GRAPHITE,GRAPHITE_TARBALL) \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 109b924..16ba7a8 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -183,51 +183,43 @@ endef
 
 endif # SYSTEM_CPPUNIT
 
-ifneq ($(SYSTEM_GLEW),)
+ifneq ($(SYSTEM_EPOXY),)
 
-define gb_LinkTarget__use_glew
+define gb_LinkTarget__use_epoxy
 $(call gb_LinkTarget_set_include,$(1),\
 	$$(INCLUDE) \
-    $(GLEW_CFLAGS) \
+    $(EPOXY_CFLAGS) \
 )
-$(call gb_LinkTarget_add_libs,$(1),$(GLEW_LIBS))
+$(call gb_LinkTarget_add_libs,$(1),$(EPOXY_LIBS))
 
 endef
 
-gb_ExternalProject__use_glew :=
+gb_ExternalProject__use_epoxy :=
 
-else # !SYSTEM_GLEW
+else # !SYSTEM_EPOXY
 
-$(eval $(call gb_Helper_register_packages_for_install,ooo,\
-	glew \
-))
-
-define gb_LinkTarget__use_glew
-$(call gb_LinkTarget_use_package,$(1),glew)
+define gb_LinkTarget__use_epoxy
 $(call gb_LinkTarget_set_include,$(1),\
-	-I$(call gb_UnpackedTarball_get_dir,glew/include) \
-	-DGLEW_NO_GLU \
-	$$(INCLUDE) \
+       -I$(call gb_UnpackedTarball_get_dir,epoxy/include) \
+       $$(INCLUDE) \
 )
 
-ifeq ($(COM),MSC)
-$(call gb_LinkTarget_add_libs,$(1),\
-	$(call gb_UnpackedTarball_get_dir,glew)/lib/$(if $(MSVC_USE_DEBUG_RUNTIME),Debug/$(wnt_arch_subdir_mandatory)/glew32d.lib,Release/$(wnt_arch_subdir_mandatory)/glew32.lib) \
-)
-else
-$(call gb_LinkTarget_add_libs,$(1),\
-	-L$(call gb_UnpackedTarball_get_dir,glew)/lib/ -lGLEW \
+$(call gb_LinkTarget_use_libraries,$(1),\
+    epoxy \
 )
-endif
 
 endef
 
-define gb_ExternalProject__use_glew
-$(call gb_ExternalProject_use_external_project,$(1),glew)
+$(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,ooo,\
+	epoxy \
+))
+
+define gb_ExternalProject__use_epoxy
+$(call gb_ExternalProject_use_external_project,$(1),epoxy)
 
 endef
 
-endif # SYSTEM_GLEW
+endif # SYSTEM_EPOXY
 
 define gb_LinkTarget__use_iconv
 $(call gb_LinkTarget_add_libs,$(1),-liconv)
@@ -3444,7 +3436,7 @@ $(call gb_LinkTarget_add_libs,$(1),\
 )
 else
 $(call gb_LinkTarget_add_libs,$(1),\
-	$(call gb_UnpackedTarball_get_dir,libgltf)/src/.libs/libgltf-0.0$(gb_StaticLibrary_PLAINEXT) \
+	$(call gb_UnpackedTarball_get_dir,libgltf)/src/.libs/libgltf-0.1$(gb_StaticLibrary_PLAINEXT) \
 )
 endif
 
diff --git a/avmedia/Library_avmedia.mk b/avmedia/Library_avmedia.mk
index 4e8f3b1..e662fc3 100644
--- a/avmedia/Library_avmedia.mk
+++ b/avmedia/Library_avmedia.mk
@@ -29,7 +29,7 @@ $(eval $(call gb_Library_use_externals,avmedia,\
 
 ifeq ($(ENABLE_HEADLESS),)
 $(eval $(call gb_Library_use_externals,avmedia,\
-    glew \
+    epoxy \
 ))
 endif
 
diff --git a/avmedia/Library_avmediaogl.mk b/avmedia/Library_avmediaogl.mk
index b7498bf..191fb75 100644
--- a/avmedia/Library_avmediaogl.mk
+++ b/avmedia/Library_avmediaogl.mk
@@ -16,7 +16,7 @@ $(eval $(call gb_Library_use_sdk_api,avmediaogl))
 $(eval $(call gb_Library_use_externals,avmediaogl, \
     boost_headers \
     libgltf \
-    glew \
+    epoxy \
     glm_headers \
 ))
 
@@ -51,10 +51,6 @@ else ifeq ($(OS),MACOSX)
 $(eval $(call gb_Library_use_system_darwin_frameworks,avmediaogl,\
 	OpenGL \
 ))
-else ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
-$(eval $(call gb_Library_add_libs,avmediaogl,\
-    -lGL \
-))
 endif
 
 # vim: set noet sw=4 ts=4:
diff --git a/bin/check-elf-dynamic-objects b/bin/check-elf-dynamic-objects
index f05d513..d189c1b 100755
--- a/bin/check-elf-dynamic-objects
+++ b/bin/check-elf-dynamic-objects
@@ -110,7 +110,7 @@ local file="$1"
         */libdesktop_detectorlo.so|*/ui-previewer|*/oosplash|*/gengal.bin)
             whitelist="${whitelist} ${x11whitelist}"
         ;;
-        */libvclplug_genlo.so|*/libGLEW.so.*|*/libchartcorelo.so|*/libavmediaogl.so|*/libOGLTranslo.so|*/liboglcanvaslo.so|*/libchartopengllo.so)
+        */libvclplug_genlo.so|*/libchartcorelo.so|*/libavmediaogl.so|*/libOGLTranslo.so|*/liboglcanvaslo.so|*/libchartopengllo.so)
             whitelist="${whitelist} ${x11whitelist} ${openglwhitelist}"
         ;;
         */libvcllo.so|*/libsofficeapp.so)
diff --git a/bin/lo-all-static-libs b/bin/lo-all-static-libs
index 813241e..9faa042 100755
--- a/bin/lo-all-static-libs
+++ b/bin/lo-all-static-libs
@@ -63,7 +63,7 @@ echo $INSTDIR/$LIBO_LIB_FOLDER/lib*.a \
      $WORKDIR/UnpackedTarball/coinmp/CoinMP/src/.libs/*.a \
      $WORKDIR/UnpackedTarball/coinmp/CoinUtils/src/.libs/*.a \
      $WORKDIR/UnpackedTarball/coinmp/Osi/src/Osi/.libs/*.a \
-     $WORKDIR/UnpackedTarball/glew/lib/*.a \
+     $WORKDIR/UnpackedTarball/epoxy/lib/*.a \
      $WORKDIR/UnpackedTarball/icu/source/lib/*.a \
      $WORKDIR/UnpackedTarball/langtag/liblangtag/.libs/*.a \
      $WORKDIR/UnpackedTarball/lcms2/src/.libs/*.a \
diff --git a/canvas/Library_oglcanvas.mk b/canvas/Library_oglcanvas.mk
index 0118eb1..9d1042d 100644
--- a/canvas/Library_oglcanvas.mk
+++ b/canvas/Library_oglcanvas.mk
@@ -42,7 +42,7 @@ $(eval $(call gb_Library_add_exception_objects,oglcanvas,\
 
 $(eval $(call gb_Library_use_externals,oglcanvas,\
 	boost_headers \
-	glew \
+	epoxy \
 ))
 
 ifeq ($(strip $(OS)),MACOSX)
@@ -58,11 +58,6 @@ $(eval $(call gb_Library_use_system_win32_libs,oglcanvas,\
     opengl32 \
 ))
 
-else
-$(eval $(call gb_Library_add_libs,oglcanvas,\
-    -lGL \
-    -lX11 \
-))
 endif
 
 # vim: set noet sw=4 ts=4:
diff --git a/canvas/source/opengl/ogl_buffercontext.hxx b/canvas/source/opengl/ogl_buffercontext.hxx
index 202e063..7f2066a 100644
--- a/canvas/source/opengl/ogl_buffercontext.hxx
+++ b/canvas/source/opengl/ogl_buffercontext.hxx
@@ -10,7 +10,7 @@
 #ifndef INCLUDED_CANVAS_SOURCE_OPENGL_OGL_BUFFERCONTEXT_HXX
 #define INCLUDED_CANVAS_SOURCE_OPENGL_OGL_BUFFERCONTEXT_HXX
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include <sal/config.h>
 #include <memory>
diff --git a/canvas/source/opengl/ogl_canvascustomsprite.cxx b/canvas/source/opengl/ogl_canvascustomsprite.cxx
index 8d38177..6b23d45 100644
--- a/canvas/source/opengl/ogl_canvascustomsprite.cxx
+++ b/canvas/source/opengl/ogl_canvascustomsprite.cxx
@@ -9,7 +9,7 @@
 
 #include <sal/config.h>
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <basegfx/point/b2dpoint.hxx>
diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx
index 84a96ce..175a02b 100644
--- a/canvas/source/opengl/ogl_canvashelper.cxx
+++ b/canvas/source/opengl/ogl_canvashelper.cxx
@@ -11,7 +11,7 @@
 
 #include <memory>
 #include <functional>
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include <basegfx/polygon/b2dpolygontriangulator.hxx>
 #include <basegfx/polygon/b2dpolypolygon.hxx>
diff --git a/canvas/source/opengl/ogl_canvastools.cxx b/canvas/source/opengl/ogl_canvastools.cxx
index 657a220..3d9448b 100644
--- a/canvas/source/opengl/ogl_canvastools.cxx
+++ b/canvas/source/opengl/ogl_canvastools.cxx
@@ -9,7 +9,7 @@
 
 #include <sal/config.h>
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <basegfx/polygon/b2dpolygontriangulator.hxx>
diff --git a/canvas/source/opengl/ogl_texturecache.cxx b/canvas/source/opengl/ogl_texturecache.cxx
index 08cdd2f..43fb7d8 100644
--- a/canvas/source/opengl/ogl_texturecache.cxx
+++ b/canvas/source/opengl/ogl_texturecache.cxx
@@ -9,7 +9,7 @@
 
 #include <sal/config.h>
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include <com/sun/star/geometry/IntegerSize2D.hpp>
 
diff --git a/canvas/source/opengl/ogl_tools.hxx b/canvas/source/opengl/ogl_tools.hxx
index 8133212..469a5be 100644
--- a/canvas/source/opengl/ogl_tools.hxx
+++ b/canvas/source/opengl/ogl_tools.hxx
@@ -11,8 +11,7 @@
 #define INCLUDED_CANVAS_SOURCE_OPENGL_OGL_TOOLS_HXX
 
 #include <sal/config.h>
-#include <GL/glew.h>
-
+#include <epoxy/gl.h>
 
 namespace oglcanvas
 {
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index b15f634..cc06fbd 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -32,7 +32,7 @@ $(eval $(call gb_Library_use_externals,chartcore,\
 
 ifeq ($(ENABLE_HEADLESS),)
 $(eval $(call gb_Library_use_externals,chartcore,\
-    glew \
+    epoxy \
 ))
 endif
 
@@ -264,13 +264,6 @@ else ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
 $(eval $(call gb_Library_add_libs,chartcore,\
 	$(DLOPEN_LIBS) \
 ))
-ifeq ($(ENABLE_HEADLESS),)
-$(eval $(call gb_Library_add_libs,chartcore,\
-    -lGL \
-    -lX11 \
-))
-endif #!ENABLE_HEADLESS
-
 endif
 
 # vim: set noet sw=4 ts=4:
diff --git a/chart2/Library_chartopengl.mk b/chart2/Library_chartopengl.mk
index 95ea58d..53056aa 100644
--- a/chart2/Library_chartopengl.mk
+++ b/chart2/Library_chartopengl.mk
@@ -22,7 +22,7 @@ $(eval $(call gb_Library_set_precompiled_header,chartopengl,$(SRCDIR)/chart2/inc
 $(eval $(call gb_Library_use_externals,chartopengl,\
 	boost_headers \
 	glm_headers \
-	glew \
+	epoxy \
 ))
 
 $(eval $(call gb_Library_use_sdk_api,chartopengl))
@@ -68,8 +68,6 @@ $(eval $(call gb_Library_use_system_darwin_frameworks,chartopengl,\
 else ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
 $(eval $(call gb_Library_add_libs,chartopengl,\
 	$(DLOPEN_LIBS) \
-	-lGL \
-	-lX11 \
 ))
 endif
  
diff --git a/chart2/inc/pch/precompiled_chartcore.hxx b/chart2/inc/pch/precompiled_chartcore.hxx
index 8d02451..908d7ac 100644
--- a/chart2/inc/pch/precompiled_chartcore.hxx
+++ b/chart2/inc/pch/precompiled_chartcore.hxx
@@ -73,7 +73,6 @@
 #include <vcl/virdev.hxx>
 #include <vcl/wall.hxx>
 #include <ChartModel.hxx>
-#include <GL/glew.h>
 #include <basegfx/basegfxdllapi.h>
 #include <basegfx/matrix/b3dhommatrix.hxx>
 #include <basegfx/numeric/ftools.hxx>
@@ -169,6 +168,7 @@
 #include <cppuhelper/weak.hxx>
 #include <editeng/editengdllapi.h>
 #include <editeng/unoprnms.hxx>
+#include <epoxy/gl.h>
 #include <i18nlangtag/i18nlangtagdllapi.h>
 #include <i18nlangtag/lang.h>
 #include <i18nlangtag/languagetag.hxx>
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index a4193da..401b664 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -9,7 +9,7 @@
 
 #include <GL3DBarChart.hxx>
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include <glm/glm.hpp>
 #include <glm/gtx/transform.hpp>
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index fb4fb13..e1e4c01 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include "GL3DRenderer.hxx"
 
@@ -244,8 +244,8 @@ void OpenGL3DRenderer::ShaderResources::LoadShaders()
         m_3DBatchNormalID = glGetAttribLocation(m_3DBatchProID, "vertexNormalModelspace");
         m_3DBatchColorID = glGetAttribLocation(m_3DBatchProID, "barColor");
 #if !defined MACOSX
-        //check whether the texture array is support
-        mbTexBatchSupport = GLEW_EXT_texture_array;
+        //check whether the texture array is supported
+        mbTexBatchSupport = epoxy_has_gl_extension("GL_EXT_texture_array");
 #endif
         CHECK_GL_ERROR();
         if (mbTexBatchSupport)
@@ -401,7 +401,7 @@ void OpenGL3DRenderer::init()
     m_fViewAngle = 30.0f;
     m_3DProjection = glm::perspective(m_fViewAngle, (float)m_iWidth / (float)m_iHeight, 0.01f, 6000.0f);
 
-    maResources.m_b330Support = GLEW_VERSION_3_3;
+    maResources.m_b330Support = epoxy_gl_version() >= 33;
     CHECK_GL_ERROR();
     maResources.LoadShaders();
     maPickingResources.LoadShaders();
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 3182e66..91a3763 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <vector>
 #include "OpenGLRender.hxx"
 #include <vcl/graph.hxx>
diff --git a/config_host.mk.in b/config_host.mk.in
index 3d39dcd..2a8fe3d 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -201,8 +201,8 @@ export GIO_LIBS=$(gb_SPACE)@GIO_LIBS@
 export GIT_REFERENCE_SRC=@GIT_REFERENCE_SRC@
 export GIT_LINK_SRC=@GIT_LINK_SRC@
 export GIT_NEEDED_SUBMODULES=@GIT_NEEDED_SUBMODULES@
-export GLEW_CFLAGS=$(gb_SPACE)@GLEW_CFLAGS@
-export GLEW_LIBS=$(gb_SPACE)@GLEW_LIBS@
+export EPOXY_CFLAGS=$(gb_SPACE)@EPOXY_CFLAGS@
+export EPOXY_LIBS=$(gb_SPACE)@EPOXY_LIBS@
 export GLM_CFLAGS=$(gb_SPACE)@GLM_CFLAGS@
 export GNOMEVFS_CFLAGS=$(gb_SPACE)@GNOMEVFS_CFLAGS@
 export GNOMEVFS_LIBS=$(gb_SPACE)@GNOMEVFS_LIBS@
@@ -514,7 +514,7 @@ export SYSTEM_FIREBIRD=@SYSTEM_FIREBIRD@
 export SYSTEM_GENBRK=@SYSTEM_GENBRK@
 export SYSTEM_GENCCODE=@SYSTEM_GENCCODE@
 export SYSTEM_GENCMN=@SYSTEM_GENCMN@
-export SYSTEM_GLEW=@SYSTEM_GLEW@
+export SYSTEM_EPOXY=@SYSTEM_EPOXY@
 export SYSTEM_GLM=@SYSTEM_GLM@
 export SYSTEM_GRAPHITE=@SYSTEM_GRAPHITE@
 export SYSTEM_HARFBUZZ=@SYSTEM_HARFBUZZ@
diff --git a/config_host/config_opengl.h.in b/config_host/config_opengl.h.in
deleted file mode 100644
index 67b9e47..0000000
--- a/config_host/config_opengl.h.in
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
-Settings for OpenGL
-*/
-
-#ifndef CONFIG_OPENGL_H
-#define CONFIG_OPENGL_H
-
-#define HAVE_GLEW_1_12 0
-
-#endif
diff --git a/configure.ac b/configure.ac
index 7fdcc65..f8b5df8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1645,6 +1645,11 @@ AC_ARG_WITH(system-cairo,
         [Use cairo libraries already on system.  Happens automatically for
          (implicit) --enable-gtk and for --enable-gtk3.]))
 
+AC_ARG_WITH(system-epoxy,
+    AS_HELP_STRING([--with-system-epoxy],
+        [Use epoxy libraries already on system.  Happens automatically for
+         --enable-gtk3.]))
+
 AC_ARG_WITH(myspell-dicts,
     AS_HELP_STRING([--with-myspell-dicts],
         [Adds myspell dictionaries to the LibreOffice installation set]),
@@ -8952,14 +8957,6 @@ AC_SUBST([GLM_CFLAGS])
 AC_SUBST([SYSTEM_GLM])
 
 dnl ===================================================================
-dnl Check for system glew
-dnl ===================================================================
-libo_CHECK_SYSTEM_MODULE([glew], [GLEW], [glew >= 1.10.0])
-AS_IF([test "$with_system_glew" = "yes"],
-    [PKG_CHECK_EXISTS([glew >= 1.12.0], [AC_DEFINE([HAVE_GLEW_1_12])])],
-    [AC_DEFINE([HAVE_GLEW_1_12])])
-
-dnl ===================================================================
 dnl Check for system odbc
 dnl ===================================================================
 AC_MSG_CHECKING([which odbc headers to use])
@@ -10508,7 +10505,7 @@ if test "x$enable_gltf" != "xno" -a $_os != iOS -a $_os != Android -a "$ENABLE_H
     AC_DEFINE(HAVE_FEATURE_GLTF,1)
     if test "$with_system_libgltf" = "yes"; then
         SYSTEM_LIBGLTF=TRUE
-        PKG_CHECK_MODULES( LIBGLTF, [libgltf-0.0 >= 0.0.1] )
+        PKG_CHECK_MODULES( LIBGLTF, [libgltf-0.1 >= 0.1.0] )
         FilterLibs "${LIBGLTF_LIBS}"
         LIBGLTF_LIBS="${filteredlibs}"
     else
@@ -11739,6 +11736,11 @@ AC_SUBST(CAIRO_CFLAGS)
 AC_SUBST(CAIRO_LIBS)
 
 dnl ===================================================================
+dnl Check for system epoxy
+dnl ===================================================================
+libo_CHECK_SYSTEM_MODULE([epoxy], [EPOXY], [epoxy >= 1.3.1], ["-I${WORKDIR}/UnpackedTarball/epoxy/include"])
+
+dnl ===================================================================
 dnl Test whether to use avahi
 dnl ===================================================================
 if test "$_os" = "WINNT"; then
@@ -12897,7 +12899,6 @@ AC_CONFIG_HEADERS([config_host/config_mpl.h])
 AC_CONFIG_HEADERS([config_host/config_orcus.h])
 AC_CONFIG_HEADERS([config_host/config_kde4.h])
 AC_CONFIG_HEADERS([config_host/config_oox.h])
-AC_CONFIG_HEADERS([config_host/config_opengl.h])
 AC_CONFIG_HEADERS([config_host/config_options.h])
 AC_CONFIG_HEADERS([config_host/config_options_calc.h])
 AC_CONFIG_HEADERS([config_host/config_test.h])
diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index 6a63a1d..64f7844 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -72,7 +72,7 @@ $(eval $(call gb_Library_use_externals,cui,\
 ))
 ifeq ($(ENABLE_HEADLESS),)
 $(eval $(call gb_Library_use_externals,cui,\
-     glew \
+     epoxy \
  ))
 endif
 
diff --git a/distro-configs/LibreOfficeFlatpak.conf b/distro-configs/LibreOfficeFlatpak.conf
index a7a0c73..d85e8ea 100644
--- a/distro-configs/LibreOfficeFlatpak.conf
+++ b/distro-configs/LibreOfficeFlatpak.conf
@@ -11,7 +11,6 @@
 --without-system-coinmp
 --without-system-cppunit
 --without-system-firebird
---without-system-glew
 --without-system-glm
 --without-system-libabw
 --without-system-libcdr
diff --git a/download.lst b/download.lst
index 4c67612..49d659a 100644
--- a/download.lst
+++ b/download.lst
@@ -29,6 +29,8 @@ export CURL_TARBALL := curl-7.52.1.tar.gz
 export DBGHELP_DLL := 13fbc2e8b37ddf28181dd6d8081c2b8e-dbghelp.dll
 export EBOOK_MD5SUM := 6b48eda57914e6343efebc9381027b78
 export EBOOK_TARBALL := libe-book-0.1.2.tar.bz2
+export EPOXY_MD5SUM := 96f6620a9b005a503e7b44b0b528287d
+export EPOXY_TARBALL := libepoxy-1.3.1.tar.bz2
 export EPM_TARBALL := 3ade8cfe7e59ca8e65052644fed9fca4-epm-3.7.tar.gz
 export ETONYEK_MD5SUM := 77ff46936dcc83670557274e7dd2aa33
 export ETONYEK_VERSION_MICRO := 6
@@ -54,7 +56,6 @@ export FONT_EMOJIONE_COLOR_TARBALL := EmojiOneColor-SVGinOT-1.3.tar.gz
 export FREEHAND_MD5SUM := 8cf70c5dc4d24d2dc4a107f509d2d6d7
 export FREEHAND_TARBALL := libfreehand-0.1.1.tar.bz2
 export FREETYPE_TARBALL := dbf2caca1d3afd410a29217a9809d397-freetype-2.4.8.tar.bz2
-export GLEW_TARBALL := 3941e9cab2f4f9d8faee3e8d57ae7664-glew-1.12.0.zip
 export GLM_TARBALL := bae83fa5dc7f081768daace6e199adc3-glm-0.9.4.6-libreoffice.zip
 export GRAPHITE_MD5SUM := 9c499b8ec9f1b81fd0bb6a3b986f4b0f
 export GRAPHITE_TARBALL := graphite2-minimal-1.3.10.tgz
@@ -89,8 +90,8 @@ export LIBATOMIC_OPS_TARBALL := libatomic_ops-7_2d.zip
 export LIBEOT_MD5SUM := aa24f5dd2a2992f4a116aa72af817548
 export LIBEOT_TARBALL := libeot-0.01.tar.bz2
 export LIBEXTTEXTCAT_TARBALL := 10d61fbaa6a06348823651b1bd7940fe-libexttextcat-3.4.4.tar.bz2
-export LIBGLTF_MD5SUM := d63a9f47ab048f5009d90693d6aa6424
-export LIBGLTF_TARBALL := libgltf-0.0.2.tar.bz2
+export LIBGLTF_MD5SUM := 63ae962d0c436909979826fce0fca2fd
+export LIBGLTF_TARBALL := libgltf-0.1.0.tar.gz
 export LIBLANGTAG_MD5SUM := 284f120247323a35122ab32b4b359c45
 export LIBLANGTAG_TARBALL := liblangtag-0.6.2.tar.bz2
 export LIBTOMMATH_MD5SUM := da283d2e3e72137d0c600ac36b991c9d
diff --git a/external/Module_external.mk b/external/Module_external.mk
index 1dbf97b..c14e668 100644
--- a/external/Module_external.mk
+++ b/external/Module_external.mk
@@ -38,13 +38,13 @@ $(eval $(call gb_Module_add_moduledirs,external,\
 	$(call gb_Helper_optional,CURL,curl) \
 	$(call gb_Helper_optional,EBOOK,libebook) \
 	$(call gb_Helper_optional,EPM,epm) \
+	$(call gb_Helper_optional,EPOXY,epoxy) \
 	$(call gb_Helper_optional,ETONYEK,libetonyek) \
 	$(call gb_Helper_optional,EXPAT,expat) \
 	$(call gb_Helper_optional,FIREBIRD,firebird) \
 	$(call gb_Helper_optional,FONTCONFIG,fontconfig) \
 	$(call gb_Helper_optional,FREEHAND,libfreehand) \
 	$(call gb_Helper_optional,FREETYPE,freetype) \
-	$(call gb_Helper_optional,GLEW,glew) \
 	$(call gb_Helper_optional,GLM,glm) \
 	$(call gb_Helper_optional,GRAPHITE,graphite) \
 	$(call gb_Helper_optional,HARFBUZZ,harfbuzz) \
diff --git a/external/glew/ExternalPackage_glew.mk b/external/glew/ExternalPackage_glew.mk
deleted file mode 100644
index e6adc8b..0000000
--- a/external/glew/ExternalPackage_glew.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-$(eval $(call gb_ExternalPackage_ExternalPackage,glew,glew))
-
-$(eval $(call gb_ExternalPackage_use_external_project,glew,glew))
-
-ifeq ($(OS)-$(COM),WNT-MSC)
-ifeq ($(CPUNAME),INTEL)
-glew_arch_subdir=Win32
-else ifeq ($(CPUNAME),X86_64)
-glew_arch_subdir=x64
-endif
-endif
-
-ifeq ($(OS),MACOSX)
-$(eval $(call gb_ExternalPackage_add_file,glew,$(LIBO_LIB_FOLDER)/libGLEW.1.12.0.dylib,lib/libGLEW.1.12.0.dylib))
-else ifeq ($(OS)-$(COM),WNT-GCC)
-else ifeq ($(COM),MSC)
-$(eval $(call gb_ExternalPackage_add_files,glew,$(LIBO_LIB_FOLDER), \
-	bin/$(if $(MSVC_USE_DEBUG_RUNTIME),Debug/$(glew_arch_subdir)/glew32d.dll,Release/$(glew_arch_subdir)/glew32.dll) \
-))
-else ifeq ($(DISABLE_DYNLOADING),)
-$(eval $(call gb_ExternalPackage_add_file,glew,$(LIBO_LIB_FOLDER)/libGLEW.so.1.12,lib/libGLEW.so.1.12.0))
-endif
-
-# vim: set noet sw=4 ts=4:
diff --git a/external/glew/ExternalProject_glew.mk b/external/glew/ExternalProject_glew.mk
deleted file mode 100644
index 0d80cd0..0000000
--- a/external/glew/ExternalProject_glew.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-$(eval $(call gb_ExternalProject_ExternalProject,glew))
-
-$(eval $(call gb_ExternalProject_register_targets,glew,\
-	build \
-))
-
-ifeq ($(COM),MSC)
-$(call gb_ExternalProject_get_state_target,glew,build) :
-	$(call gb_ExternalProject_run,build,\
-		$(if $(filter 140,$(VCVER)),$(DEVENV) /Upgrade glew.sln,echo up-to-date) && \
-		msbuild.exe glew_shared.vcxproj /p:Platform=$(if $(filter INTEL,$(CPUNAME)),Win32,x64) /p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) $(if $(filter 140,$(VCVER)),/p:PlatformToolset=v140,/p:PlatformToolset=v120) \
-	,build/vc12) \
-	$(call gb_ExternalProject_run,build,\
-		msbuild.exe glewinfo.vcxproj /p:Platform=$(if $(filter INTEL,$(CPUNAME)),Win32,x64) /p:Configuration=Release $(if $(filter 140,$(VCVER)),/p:PlatformToolset=v140,/p:PlatformToolset=v120) \
-	,build/vc12)
-
-else
-
-$(call gb_ExternalProject_get_state_target,glew,build) :
-	$(call gb_ExternalProject_run,glew,\
-		$(if $(ENABLE_DEBUG),STRIP=) LD="$(CC)" \
-			$(MAKE) STRIP= glew.lib $(if $(filter DESKTOP,$(BUILD_TYPE)),$(if $(ENABLE_DEBUG),debug)) \
-	)
-
-endif
-
-# vim: set noet sw=4 ts=4:
diff --git a/external/glew/Makefile b/external/glew/Makefile
deleted file mode 100644
index e4968cf..0000000
--- a/external/glew/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-
-module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
-
-include $(module_directory)/../../solenv/gbuild/partial_build.mk
-
-# vim: set noet sw=4 ts=4:
diff --git a/external/glew/Module_glew.mk b/external/glew/Module_glew.mk
deleted file mode 100644
index 1d1b9a7..0000000
--- a/external/glew/Module_glew.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-$(eval $(call gb_Module_Module,glew))
-
-$(eval $(call gb_Module_add_targets,glew,\
-	ExternalProject_glew \
-	UnpackedTarball_glew \
-	ExternalPackage_glew \
-))
-
-# vim: set noet sw=4 ts=4:
diff --git a/external/glew/README b/external/glew/README
deleted file mode 100644
index 34b2d24..0000000
--- a/external/glew/README
+++ /dev/null
@@ -1,6 +0,0 @@
-GLEW is the OpenGL Extension Wrangler
-
-GLEW provides efficient run-time mechanisms for determining which OpenGL
-extensions are supported on the target platform.
-
-http://glew.sourceforge.net/
diff --git a/external/glew/UnpackedTarball_glew.mk b/external/glew/UnpackedTarball_glew.mk
deleted file mode 100644
index c47b7a0..0000000
--- a/external/glew/UnpackedTarball_glew.mk
+++ /dev/null
@@ -1,48 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-$(eval $(call gb_UnpackedTarball_UnpackedTarball,glew))
-
-$(eval $(call gb_UnpackedTarball_set_tarball,glew,$(GLEW_TARBALL)))
-
-$(eval $(call gb_UnpackedTarball_set_patchlevel,glew,0))
-
-$(eval $(call gb_UnpackedTarball_fix_end_of_line,glew,\
-	Makefile \
-	include/GL/glew.h \
-))
-
-ifeq ($(OS)$(COM),WNTMSC)
-$(eval $(call gb_UnpackedTarball_set_patchflags,glew,--binary))
-$(eval $(call gb_UnpackedTarball_add_patches,glew,\
-	external/glew/glew-msvc-disable-sse2.patch.1 \
-))
-else
-$(eval $(call gb_UnpackedTarball_add_patches,glew,\
-	external/glew/glew_use_CC_variable.patch.1 \
-))
-endif
-
-ifeq ($(OS),MACOSX)
-$(eval $(call gb_UnpackedTarball_add_patches,glew,\
-	external/glew/glew-macosx-install-name.patch.1 \
-))
-endif
-
-ifeq ($(DISABLE_DYNLOADING),TRUE)
-$(eval $(call gb_UnpackedTarball_add_patches,glew,\
-	external/glew/glew-static-only.patch.1 \
-))
-endif
-
-$(eval $(call gb_UnpackedTarball_add_patches,glew,\
-	external/glew/glew-tmpdir.patch.1 \
-))
-
-# vim: set noet sw=4 ts=4:
diff --git a/external/glew/glew-macosx-install-name.patch.1 b/external/glew/glew-macosx-install-name.patch.1
deleted file mode 100644
index 75e8e7f..0000000
--- a/external/glew/glew-macosx-install-name.patch.1
+++ /dev/null
@@ -1,13 +0,0 @@
--*- Mode:Diff -*-
-diff -ur glew.org/build/glew.rc glew/build/glew.rc
---- glew/config/Makefile.darwin
-+++ glew/config/Makefile.darwin
-@@ -20,7 +20,7 @@
- LIB.DEVLNK    = lib$(NAME).dylib
- LIB.SHARED    = lib$(NAME).$(SO_VERSION).dylib
- LIB.STATIC    = lib$(NAME).a
--LDFLAGS.SO    = -dynamiclib -install_name $(GLEW_DEST)/lib/$(LIB.SHARED) -current_version $(SO_VERSION) -compatibility_version $(SO_MAJOR)
-+LDFLAGS.SO    = -dynamiclib -install_name @__________________________________________________OOO/$(LIB.SHARED) -current_version $(SO_VERSION) -compatibility_version $(SO_MAJOR)
- LIB.SONAME.MX = lib$(NAME)mx.$(SO_MAJOR).dylib
- LIB.DEVLNK.MX = lib$(NAME)mx.dylib
- LIB.SHARED.MX = lib$(NAME)mx.$(SO_VERSION).dylib
diff --git a/external/glew/glew-msvc-disable-sse2.patch.1 b/external/glew/glew-msvc-disable-sse2.patch.1
deleted file mode 100644
index 6b07044..0000000
--- a/external/glew/glew-msvc-disable-sse2.patch.1
+++ /dev/null
@@ -1,10 +0,0 @@
---- glew/build//vc10/common.props.orig	2014-10-02 15:06:57.027060664 +0200
-+++ glew/build//vc10/common.props	2014-10-02 15:06:59.026060509 +0200
-@@ -10,6 +10,7 @@
-   <ItemDefinitionGroup>
-     <ClCompile>
-       <AdditionalIncludeDirectories>$(INCLUDE_DIR)</AdditionalIncludeDirectories>
-+      <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
-     </ClCompile>
-   </ItemDefinitionGroup>
-   <ItemGroup>
diff --git a/external/glew/glew-static-only.patch.1 b/external/glew/glew-static-only.patch.1
deleted file mode 100644
index 14ccff2..0000000
--- a/external/glew/glew-static-only.patch.1
+++ /dev/null
@@ -1,12 +0,0 @@
--*- Mode:Diff -*-
---- glew/Makefile
-+++ glew/Makefile
-@@ -93,7 +93,7 @@
- LIB.SOBJS.MX       := $(addprefix tmp/$(SYSTEM)/mx/shared/,$(LIB.SRCS.NAMES))
- LIB.SOBJS.MX       := $(LIB.SOBJS.MX:.c=.o)
- 
--glew.lib: lib lib/$(LIB.SHARED) lib/$(LIB.STATIC) glew.pc
-+glew.lib: lib lib/$(LIB.STATIC)
- 
- lib:
- 	mkdir lib
diff --git a/external/glew/glew-tmpdir.patch.1 b/external/glew/glew-tmpdir.patch.1
deleted file mode 100644
index 9a2847b..0000000
--- a/external/glew/glew-tmpdir.patch.1
+++ /dev/null
@@ -1,13 +0,0 @@
-diff -ur glew.org/Makefile glew/Makefile
---- glew.org/Makefile	2016-05-02 06:25:53.521291677 +0200
-+++ glew/Makefile	2016-05-02 06:31:10.325035494 +0200
-@@ -55,7 +55,8 @@
- DIST_SRC_TGZ ?= $(shell pwd)/$(DIST_NAME).tgz
- DIST_WIN32   ?= $(shell pwd)/$(DIST_NAME)-win32.zip
- 
--DIST_DIR := $(shell mktemp -d /tmp/glew.XXXXXX)/$(DIST_NAME)
-+TMPDIR ?= /tmp
-+DIST_DIR := $(shell mktemp -d $(TMPDIR)/glew.XXXXXX)/$(DIST_NAME)
- 
- # To disable stripping of binaries either:
- #   - use STRIP= on gmake command-line
diff --git a/external/glew/glew_use_CC_variable.patch.1 b/external/glew/glew_use_CC_variable.patch.1
deleted file mode 100644
index 56e9903..0000000
--- a/external/glew/glew_use_CC_variable.patch.1
+++ /dev/null
@@ -1,24 +0,0 @@
-Use CC variable from environment, don't hardcode "cc".
-
---- glew/config/Makefile.linux.orig	2014-01-29 15:39:43.364972925 +0100
-+++ glew/config/Makefile.linux	2014-01-29 15:44:45.621000941 +0100
-@@ -1,6 +1,6 @@
- NAME = $(GLEW_NAME)
--CC = cc
--LD = cc
-+CC ?= cc
-+LD ?= $(CC)
- M_ARCH ?= $(shell uname -m)
- ARCH64 = false
- ifeq (x86_64,${M_ARCH})
---- glew/config/Makefile.darwin.orig	2014-01-29 15:44:39.541000377 +0100
-+++ glew/config/Makefile.darwin	2014-01-29 15:44:47.548001120 +0100
-@@ -1,6 +1,6 @@
- NAME = $(GLEW_NAME)
--CC = cc
--LD = cc
-+CC ?= cc
-+LD ?= $(CC)
- CFLAGS.EXTRA = -dynamic -fno-common
- #CFLAGS.EXTRA += -no-cpp-precomp
- LDFLAGS.EXTRA =
diff --git a/external/libgltf/ExternalProject_libgltf.mk b/external/libgltf/ExternalProject_libgltf.mk
index 57c01d0..90a1d96 100644
--- a/external/libgltf/ExternalProject_libgltf.mk
+++ b/external/libgltf/ExternalProject_libgltf.mk
@@ -17,7 +17,7 @@ $(eval $(call gb_ExternalProject_register_targets,libgltf,\
 
 $(eval $(call gb_ExternalProject_use_externals,libgltf,\
 	boost_headers \
-	glew \
+	epoxy \
 	glm_headers \
 ))
 
@@ -30,8 +30,8 @@ ifeq ($(SYSTEM_BOOST),)
 libgltf_AdditionalIncludes += "$(call gb_UnpackedTarball_get_dir,boost)"
 endif
 
-ifeq ($(SYSTEM_GLEW),)
-libgltf_AdditionalIncludes += "$(call gb_UnpackedTarball_get_dir,glew)/include"
+ifeq ($(SYSTEM_EPOXY),)
+libgltf_AdditionalIncludes += "$(call gb_UnpackedTarball_get_dir,epoxy)/include"
 endif
 
 ifeq ($(SYSTEM_GLM),)
@@ -45,7 +45,7 @@ $(call gb_ExternalProject_get_state_target,libgltf,build) :
 			$(if $(filter 120,$(VCVER)),/p:PlatformToolset=v120 /p:VisualStudioVersion=12.0 /ToolsVersion:12.0) \
 			$(if $(filter 140,$(VCVER)),/p:PlatformToolset=v140 /p:VisualStudioVersion=14.0 /ToolsVersion:14.0) \
 			'/p:AdditionalIncludeDirectories=$(subst $(WHITESPACE),;,$(subst /,\,$(strip $(libgltf_AdditionalIncludes))))' \
-			/p:AdditionalLibraryDirectories=$(if $(SYSTEM_GLEW),,"$(subst /,\,$(call gb_UnpackedTarball_get_dir,glew))\lib\$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release)\Win32") \
+			/p:AdditionalLibraryDirectories=$(if $(SYSTEM_EPOXY),,"$(subst /,\,$(call gb_UnpackedTarball_get_dir,epoxy))\lib\$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release)\Win32") \
 	,build/win32)
 
 else # !ifeq($(COM),MSC)
@@ -67,7 +67,7 @@ $(call gb_ExternalProject_get_state_target,libgltf,build) :
 			$(if $(ENABLE_DEBUG),--enable-debug,--disable-debug) \
 			--disable-werror \
 			BOOST_CFLAGS="$(BOOST_CPPFLAGS)" \
-			GLEW_CFLAGS="$(if $(SYSTEM_GLEW),$(GLEW_CFLAGS),-I$(call gb_UnpackedTarball_get_dir,glew)/include) -DGLEW_NO_GLU" \
+			EPOXY_CFLAGS="$(if $(SYSTEM_EPOXY),$(EPOXY_CFLAGS),-I$(call gb_UnpackedTarball_get_dir,epoxy)/include)" \
 			GLM_CFLAGS="$(if $(SYSTEM_GLM),$(GLM_CFLAGS),-I$(call gb_UnpackedTarball_get_dir,glm))" \
 			$(if $(libgltf_CPPFLAGS),CPPFLAGS='$(libgltf_CPPFLAGS)') \
 		&& $(MAKE) \
diff --git a/external/libgltf/libgltf-msvc-x64.patch.1 b/external/libgltf/libgltf-msvc-x64.patch.1
index 86417a7..32a831b 100644
--- a/external/libgltf/libgltf-msvc-x64.patch.1
+++ b/external/libgltf/libgltf-msvc-x64.patch.1
@@ -20,7 +20,7 @@ diff -ur libgltf.org/build/win32/libgltf.vcxproj libgltf/build/win32/libgltf.vcx
    </ItemGroup>
    <ItemGroup>
      <ClInclude Include="..\..\inc\libgltf.h" />
-@@ -56,6 +64,12 @@
+@@ -53,6 +61,12 @@
      <CharacterSet>MultiByte</CharacterSet>
      <PlatformToolset>v110</PlatformToolset>
    </PropertyGroup>
@@ -33,7 +33,7 @@ diff -ur libgltf.org/build/win32/libgltf.vcxproj libgltf/build/win32/libgltf.vcx
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
      <ConfigurationType>StaticLibrary</ConfigurationType>
      <UseDebugLibraries>false</UseDebugLibraries>
-@@ -63,15 +77,28 @@
+@@ -60,15 +74,28 @@
      <CharacterSet>MultiByte</CharacterSet>
      <PlatformToolset>v110</PlatformToolset>
    </PropertyGroup>
@@ -62,8 +62,8 @@ diff -ur libgltf.org/build/win32/libgltf.vcxproj libgltf/build/win32/libgltf.vcx
    <PropertyGroup Label="UserMacros" />
    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
      <ClCompile>
-@@ -86,6 +113,19 @@
-       <AdditionalDependencies>opengl32.lib;glew32.lib;$(AdditionalDependencies)</AdditionalDependencies>
+@@ -83,10 +110,42 @@
+       <AdditionalDependencies>opengl32.lib;epoxy32.lib;$(AdditionalDependencies)</AdditionalDependencies>
      </Link>
    </ItemDefinitionGroup>
 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -76,20 +76,13 @@ diff -ur libgltf.org/build/win32/libgltf.vcxproj libgltf/build/win32/libgltf.vcx
 +    <Link>
 +      <GenerateDebugInformation>true</GenerateDebugInformation>
 +      <AdditionalLibraryDirectories>$(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
-+      <AdditionalDependencies>opengl32.lib;glew32.lib;$(AdditionalDependencies)</AdditionalDependencies>
++      <AdditionalDependencies>opengl32.lib;epoxy32.lib;$(AdditionalDependencies)</AdditionalDependencies>
 +    </Link>
 +  </ItemDefinitionGroup>
    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
      <ClCompile>
        <WarningLevel>Level4</WarningLevel>
-@@ -105,6 +145,25 @@
-       <SubSystem>Windows</SubSystem>
-     </Link>
-   </ItemDefinitionGroup>
-+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-+    <ClCompile>
-+      <WarningLevel>Level4</WarningLevel>
-+      <Optimization>MaxSpeed</Optimization>
+       <Optimization>MaxSpeed</Optimization>
 +      <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
 +      <FunctionLevelLinking>true</FunctionLevelLinking>
 +      <IntrinsicFunctions>true</IntrinsicFunctions>
@@ -101,10 +94,14 @@ diff -ur libgltf.org/build/win32/libgltf.vcxproj libgltf/build/win32/libgltf.vcx
 +      <EnableCOMDATFolding>true</EnableCOMDATFolding>
 +      <OptimizeReferences>true</OptimizeReferences>
 +      <AdditionalLibraryDirectories>$(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
-+      <AdditionalDependencies>opengl32.lib;glew32.lib;$(AdditionalDependencies)</AdditionalDependencies>
++      <AdditionalDependencies>opengl32.lib;epoxy32.lib;$(AdditionalDependencies)</AdditionalDependencies>
 +      <SubSystem>Windows</SubSystem>
 +    </Link>
 +  </ItemDefinitionGroup>
-   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-   <ImportGroup Label="ExtensionTargets">
-   </ImportGroup>
++  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
++    <ClCompile>
++      <WarningLevel>Level4</WarningLevel>
++      <Optimization>MaxSpeed</Optimization>
+       <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
+       <FunctionLevelLinking>true</FunctionLevelLinking>
+       <IntrinsicFunctions>true</IntrinsicFunctions>
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index e3e9ce0..ffcd816 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -12,7 +12,7 @@
 
 #include <string.h>
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 
 #include <vcl/dllapi.h>
 #include <vcl/window.hxx>
@@ -158,8 +158,8 @@ private:
     virtual void destroyCurrentContext();
 
 protected:
-    bool InitGLEW();
-    static void InitGLEWDebugging();
+    bool InitGL();
+    static void InitGLDebugging();
     static void InitChildWindow(SystemChildWindow *pChildWindow);
     static void BuffersSwapped();
     virtual GLWindow& getModifiableOpenGLWindow() = 0;
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index 458021f..23b9b79 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -10,7 +10,7 @@
 #ifndef INCLUDED_VCL_OPENGL_OPENGLHELPER_HXX
 #define INCLUDED_VCL_OPENGL_OPENGLHELPER_HXX
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <sal/log.hxx>
 #include <vcl/dllapi.h>
 #include <vcl/bitmapex.hxx>
diff --git a/include/vcl/opengl/OpenGLWrapper.hxx b/include/vcl/opengl/OpenGLWrapper.hxx
index 3b7f6a7..e9fb967 100644
--- a/include/vcl/opengl/OpenGLWrapper.hxx
+++ b/include/vcl/opengl/OpenGLWrapper.hxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-// Fully wrapped methods that have no exotic GL / GLEW header deps.
+// Fully wrapped methods that have no exotic GL header deps.
 
 #ifndef INCLUDED_VCL_OPENGL_OPENGLWRAPPER_HXX
 #define INCLUDED_VCL_OPENGL_OPENGLWRAPPER_HXX
diff --git a/slideshow/Library_OGLTrans.mk b/slideshow/Library_OGLTrans.mk
index b908a0b..fb04596 100644
--- a/slideshow/Library_OGLTrans.mk
+++ b/slideshow/Library_OGLTrans.mk
@@ -34,7 +34,7 @@ $(eval $(call gb_Library_use_libraries,OGLTrans,\
 
 $(eval $(call gb_Library_use_externals,OGLTrans,\
 	boost_headers \
-	glew \
+	epoxy \
 	glm_headers \
 ))
 
@@ -56,13 +56,6 @@ $(eval $(call gb_Library_use_system_win32_libs,OGLTrans,\
     opengl32 \
 ))
 
-else
-
-$(eval $(call gb_Library_add_libs,OGLTrans,\
-	-lGL \
-	-lX11 \
-))
-
 endif
 
 $(eval $(call gb_Library_add_exception_objects,OGLTrans,\
diff --git a/slideshow/Library_slideshow.mk b/slideshow/Library_slideshow.mk
index 3a9aac6..0583f5e 100644
--- a/slideshow/Library_slideshow.mk
+++ b/slideshow/Library_slideshow.mk
@@ -31,7 +31,7 @@ $(eval $(call gb_Library_use_externals,slideshow,\
 ))
 ifeq ($(ENABLE_HEADLESS),)
 $(eval $(call gb_Library_use_externals,slideshow,\
-     glew \
+     epoxy \
  ))
 endif
 
diff --git a/slideshow/source/engine/opengl/TransitionImpl.cxx b/slideshow/source/engine/opengl/TransitionImpl.cxx
index 60ab587..115aaf2 100644
--- a/slideshow/source/engine/opengl/TransitionImpl.cxx
+++ b/slideshow/source/engine/opengl/TransitionImpl.cxx
@@ -26,7 +26,6 @@
  *
  ************************************************************************/
 
-#include <GL/glew.h>
 #include <glm/gtc/matrix_transform.hpp>
 #include <glm/gtc/type_ptr.hpp>
 #include <vcl/opengl/OpenGLHelper.hxx>
diff --git a/slideshow/source/engine/opengl/TransitionImpl.hxx b/slideshow/source/engine/opengl/TransitionImpl.hxx
index 66ecb6b..b739c0c 100644
--- a/slideshow/source/engine/opengl/TransitionImpl.hxx
+++ b/slideshow/source/engine/opengl/TransitionImpl.hxx
@@ -31,8 +31,7 @@
 #include <config_lgpl.h>
 #include <glm/gtc/type_ptr.hpp>
 
-#include <GL/glew.h>
-
+#include <limits>
 #include <memory>
 #include <vector>
 
diff --git a/slideshow/source/engine/opengl/TransitionerImpl.cxx b/slideshow/source/engine/opengl/TransitionerImpl.cxx
index 61a28e9..1434b03 100644
--- a/slideshow/source/engine/opengl/TransitionerImpl.cxx
+++ b/slideshow/source/engine/opengl/TransitionerImpl.cxx
@@ -830,7 +830,7 @@ void buildMipmaps(
     GLint internalFormat, GLsizei width, GLsizei height, GLenum format,
     GLenum type, const void * data)
 {
-    if (GLEW_ARB_framebuffer_object) {
+    if (epoxy_has_gl_extension("GL_ARB_framebuffer_object")) {
         glTexImage2D(
             GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, type,
             data);
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index 557c427..48ecf22 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -88,7 +88,7 @@ $(eval $(call gb_Library_use_externals,svxcore,\
 ))
 ifeq ($(ENABLE_HEADLESS),)
 $(eval $(call gb_Library_use_externals,svxcore,\
-     glew \
+     epoxy \
  ))
 endif
 
diff --git a/toolkit/Library_tk.mk b/toolkit/Library_tk.mk
index 27bd721..b9a42d3 100644
--- a/toolkit/Library_tk.mk
+++ b/toolkit/Library_tk.mk
@@ -27,7 +27,7 @@ $(eval $(call gb_Library_use_externals,tk,\
 
 ifeq ($(ENABLE_HEADLESS),)
 $(eval $(call gb_Library_use_externals,tk,\
-    glew \
+    epoxy \
 ))
 endif
 $(eval $(call gb_Library_set_include,tk,\
diff --git a/vcl/CppunitTest_vcl_bitmap_test.mk b/vcl/CppunitTest_vcl_bitmap_test.mk
index 879c7ac..70ce156 100644
--- a/vcl/CppunitTest_vcl_bitmap_test.mk
+++ b/vcl/CppunitTest_vcl_bitmap_test.mk
@@ -19,7 +19,7 @@ $(eval $(call gb_CppunitTest_use_externals,vcl_bitmap_test,\
 ))
 ifeq ($(ENABLE_HEADLESS),)
 $(eval $(call gb_CppunitTest_use_externals,vcl_bitmap_test,\
-     glew \
+     epoxy \
  ))
 endif
 
diff --git a/vcl/CppunitTest_vcl_wmf_test.mk b/vcl/CppunitTest_vcl_wmf_test.mk
index 44d6851..3b78147 100644
--- a/vcl/CppunitTest_vcl_wmf_test.mk
+++ b/vcl/CppunitTest_vcl_wmf_test.mk
@@ -87,7 +87,7 @@ $(eval $(call gb_CppunitTest_use_externals,vcl_wmf_test,\
 ))
 ifeq ($(ENABLE_HEADLESS),)
 $(eval $(call gb_CppunitTest_use_externals,vcl_wmf_test,\
-     glew \
+     epoxy \
  ))
 endif
 
@@ -136,7 +136,6 @@ $(eval $(call gb_CppunitTest_add_libs,vcl_wmf_test,\
     -lm \
     -ldl \
     -lpthread \
-    -lGL \
     -lX11 \
 ))
 endif
@@ -189,7 +188,6 @@ ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
 $(eval $(call gb_CppunitTest_add_libs,vcl_wmf_test,\
     -lm $(DLOPEN_LIBS) \
     -lpthread \
-    -lGL \
     -lX11 \
     -lXext \
 ))
diff --git a/vcl/Executable_icontest.mk b/vcl/Executable_icontest.mk
index 102697b..cce8feb 100644
--- a/vcl/Executable_icontest.mk
+++ b/vcl/Executable_icontest.mk
@@ -15,7 +15,7 @@ $(eval $(call gb_Executable_use_externals,icontest,\
 ))
 ifeq ($(ENABLE_HEADLESS),)
 $(eval $(call gb_Executable_use_externals,icontest,\
-    glew \
+    epoxy \
 ))
 endif
 
diff --git a/vcl/Executable_vcldemo.mk b/vcl/Executable_vcldemo.mk
index bff091e..a09d3b4 100644
--- a/vcl/Executable_vcldemo.mk
+++ b/vcl/Executable_vcldemo.mk
@@ -21,7 +21,7 @@ $(eval $(call gb_Executable_use_externals,vcldemo,\
 ))
 ifeq ($(ENABLE_HEADLESS),)
 $(eval $(call gb_Executable_use_externals,vcldemo,\
-    glew \
+    epoxy \
 ))
 endif
 
diff --git a/vcl/Executable_visualbackendtest.mk b/vcl/Executable_visualbackendtest.mk
index abf8cbe..8704453 100644
--- a/vcl/Executable_visualbackendtest.mk
+++ b/vcl/Executable_visualbackendtest.mk
@@ -46,7 +46,6 @@ $(eval $(call gb_Executable_add_libs,visualbackendtest,\
 	-lm \
 	-ldl \
 	-lpthread \
-    -lGL \
     -lX11 \
 ))
 
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index a52938b..a911329 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -124,7 +124,7 @@ $(eval $(call gb_Library_use_externals,vcl,\
 ))
 ifeq ($(ENABLE_HEADLESS),)
 $(eval $(call gb_Library_use_externals,vcl,\
-     glew \
+     epoxy \
  ))
 endif
 
@@ -648,7 +648,6 @@ $(eval $(call gb_Library_add_libs,vcl,\
 	-lm \
 	-ldl \
 	-lpthread \
-    -lGL \
     -lX11 \
 ))
 endif
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index f281605..0e1c39c 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -51,7 +51,7 @@ $(eval $(call gb_Library_use_externals,vclplug_gen,\
 	boost_headers \
 	cairo \
 	graphite \
-	glew \
+	epoxy \
 	glm_headers \
 	harfbuzz \
 	icu_headers \
@@ -65,7 +65,6 @@ $(eval $(call gb_Library_add_libs,vclplug_gen,\
 	-lXext \
 	-lSM \
 	-lICE \
-	-lGL \
 ))
 
 $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
diff --git a/vcl/Library_vclplug_gtk.mk b/vcl/Library_vclplug_gtk.mk
index c32a127..67247b7 100644
--- a/vcl/Library_vclplug_gtk.mk
+++ b/vcl/Library_vclplug_gtk.mk
@@ -59,7 +59,7 @@ $(eval $(call gb_Library_use_externals,vclplug_gtk,\
 	cairo \
 	dbus \
 	gio \
-	glew \
+	epoxy \
 	gtk \
 	gthread \
 	icuuc \
diff --git a/vcl/Library_vclplug_gtk3.mk b/vcl/Library_vclplug_gtk3.mk
index 8d013d9..1457c1a 100644
--- a/vcl/Library_vclplug_gtk3.mk
+++ b/vcl/Library_vclplug_gtk3.mk
@@ -75,7 +75,7 @@ $(eval $(call gb_Library_use_libraries,vclplug_gtk3,\
 
 $(eval $(call gb_Library_use_externals,vclplug_gtk3,\
 	boost_headers \
-	glew \
+	epoxy \
 	dbus \
 ))
 
diff --git a/vcl/Library_vclplug_kde4.mk b/vcl/Library_vclplug_kde4.mk
index 30c4069..acd7bd5 100644
--- a/vcl/Library_vclplug_kde4.mk
+++ b/vcl/Library_vclplug_kde4.mk
@@ -54,7 +54,7 @@ $(eval $(call gb_Library_use_externals,vclplug_kde4,\
 	boost_headers \
 	icuuc \
 	kde4 \
-	glew \
+	epoxy \
 ))
 
 $(eval $(call gb_Library_add_libs,vclplug_kde4,\
diff --git a/vcl/inc/opengl/LineRenderUtils.hxx b/vcl/inc/opengl/LineRenderUtils.hxx
index 58ae6a8..e3f375b 100644
--- a/vcl/inc/opengl/LineRenderUtils.hxx
+++ b/vcl/inc/opengl/LineRenderUtils.hxx
@@ -11,7 +11,6 @@
 #ifndef INCLUDED_VCL_INC_OPENGL_LINERENDERUTILS_H
 #define INCLUDED_VCL_INC_OPENGL_LINERENDERUTILS_H
 
-#include <GL/glew.h>
 #include "opengl/VertexUtils.hxx"
 #include "opengl/RenderList.hxx"
 
diff --git a/vcl/inc/opengl/VertexUtils.hxx b/vcl/inc/opengl/VertexUtils.hxx
index f9804ec..de2c070 100644
--- a/vcl/inc/opengl/VertexUtils.hxx
+++ b/vcl/inc/opengl/VertexUtils.hxx
@@ -12,7 +12,7 @@
 #define INCLUDED_VCL_INC_OPENGL_VERTEXUTILS_H
 
 #include <basegfx/numeric/ftools.hxx>
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <glm/gtx/norm.hpp>
 #include <vcl/salgtype.hxx>
 #include <vector>
diff --git a/vcl/inc/opengl/framebuffer.hxx b/vcl/inc/opengl/framebuffer.hxx
index ec7a450..a2dbd1e 100644
--- a/vcl/inc/opengl/framebuffer.hxx
+++ b/vcl/inc/opengl/framebuffer.hxx
@@ -10,7 +10,6 @@
 #ifndef INCLUDED_VCL_INC_OPENGL_FRAMEBUFFER_H
 #define INCLUDED_VCL_INC_OPENGL_FRAMEBUFFER_H
 
-#include <GL/glew.h>
 #include <vcl/dllapi.h>
 
 #include <opengl/texture.hxx>
diff --git a/vcl/inc/opengl/program.hxx b/vcl/inc/opengl/program.hxx
index 73cdb7f..4632ddf 100644
--- a/vcl/inc/opengl/program.hxx
+++ b/vcl/inc/opengl/program.hxx
@@ -14,7 +14,6 @@
 
 #include <list>
 
-#include <GL/glew.h>
 #include <vcl/dllapi.h>
 
 #include <basegfx/point/b2dpoint.hxx>
diff --git a/vcl/inc/opengl/texture.hxx b/vcl/inc/opengl/texture.hxx
index a0c8029..fd4eb97 100644
--- a/vcl/inc/opengl/texture.hxx
+++ b/vcl/inc/opengl/texture.hxx
@@ -20,7 +20,7 @@
 #ifndef INCLUDED_VCL_INC_OPENGL_TEXTURE_H
 #define INCLUDED_VCL_INC_OPENGL_TEXTURE_H
 
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <vcl/dllapi.h>
 #include <vcl/salgtype.hxx>
 #include <rtl/ustring.hxx>
diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx
index 6ef9e2a..a356ae8 100644
--- a/vcl/inc/pch/precompiled_vcl.hxx
+++ b/vcl/inc/pch/precompiled_vcl.hxx
@@ -56,6 +56,7 @@
 #include <boost/math/special_functions/sinc.hpp>
 #include <boost/multi_array.hpp>
 #include <boost/optional.hpp>
+#include <epoxy/gl.h>
 #include <osl/conditn.hxx>
 #include <osl/diagnose.h>
 #include <osl/diagnose.hxx>
@@ -184,7 +185,6 @@
 #include <vcl/virdev.hxx>
 #include <vcl/window.hxx>
 #include <vcl/wrkwin.hxx>
-#include <GL/glew.h>
 #include <PhysicalFontCollection.hxx>
 #include <PhysicalFontFace.hxx>
 #include <PhysicalFontFamily.hxx>
diff --git a/vcl/inc/unx/saldisp.hxx b/vcl/inc/unx/saldisp.hxx
index 64998df..339ba80 100644
--- a/vcl/inc/unx/saldisp.hxx
+++ b/vcl/inc/unx/saldisp.hxx
@@ -28,7 +28,7 @@ class   SalXLib;
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <X11/extensions/Xrender.h>
-#include "GL/glxew.h"
+#include <epoxy/glx.h>
 
 #include <unx/salunx.h>
 #include <unx/saltype.h>
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index b4f87a3..92dd18c 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -32,6 +32,7 @@
 #include <o3tl/lru_map.hxx>
 
 static std::vector<GLXContext> g_vShareList;
+static bool g_bAnyCurrent;
 
 class X11OpenGLContext : public OpenGLContext
 {
@@ -184,23 +185,10 @@ namespace
         return pFBC;
     }
 
-    // we need them before glew can initialize them
-    // glew needs an OpenGL context so we need to get the address manually
-    void initOpenGLFunctionPointers()
-    {
-        glXChooseFBConfig = reinterpret_cast<GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements)>(glXGetProcAddressARB(reinterpret_cast<GLubyte const *>("glXChooseFBConfig")));
-        glXGetVisualFromFBConfig = reinterpret_cast<XVisualInfo*(*)(Display *dpy, GLXFBConfig config)>(glXGetProcAddressARB(reinterpret_cast<GLubyte const *>("glXGetVisualFromFBConfig")));    // try to find a visual for the current set of attributes
-        glXGetFBConfigAttrib = reinterpret_cast<int(*)(Display *dpy, GLXFBConfig config, int attribute, int* value)>(glXGetProcAddressARB(reinterpret_cast<GLubyte const *>("glXGetFBConfigAttrib")));
-        glXCreateContextAttribsARB = reinterpret_cast<GLXContext(*)(Display*, GLXFBConfig, GLXContext, Bool, const int*)>(glXGetProcAddressARB(reinterpret_cast<const GLubyte *>("glXCreateContextAttribsARB")));
-        glXCreatePixmap = reinterpret_cast<GLXPixmap(*)(Display*, GLXFBConfig, Pixmap, const int*)>(glXGetProcAddressARB(reinterpret_cast<const GLubyte *>("glXCreatePixmap")));
-    }
-
     Visual* getVisual(Display* dpy, Window win)
     {
         OpenGLZone aZone;
 
-        initOpenGLFunctionPointers();
-
         XWindowAttributes xattr;
         if( !XGetWindowAttributes( dpy, win, &xattr ) )
         {
@@ -235,7 +223,10 @@ void X11OpenGLContext::resetCurrent()
     OpenGLZone aZone;
 
     if (m_aGLWin.dpy)
+    {
         glXMakeCurrent(m_aGLWin.dpy, None, nullptr);
+        g_bAnyCurrent = false;
+    }
 }
 
 bool X11OpenGLContext::isCurrent()
@@ -247,7 +238,7 @@ bool X11OpenGLContext::isCurrent()
 
 bool X11OpenGLContext::isAnyCurrent()
 {
-    return glXGetCurrentContext() != None;
+    return g_bAnyCurrent && glXGetCurrentContext() != None;
 }
 
 SystemWindowData X11OpenGLContext::generateWinData(vcl::Window* pParent, bool /*bRequestLegacyContext*/)
@@ -266,8 +257,6 @@ SystemWindowData X11OpenGLContext::generateWinData(vcl::Window* pParent, bool /*
     if( dpy == nullptr || !glXQueryExtension( dpy, nullptr, nullptr ) )
         return aWinData;
 
-    initOpenGLFunctionPointers();
-
     int best_fbc = -1;
     GLXFBConfig* pFBC = getFBConfig(dpy, win, best_fbc, true, false);
 
@@ -355,10 +344,13 @@ bool X11OpenGLContext::ImplInit()
 
     if( !glXMakeCurrent( m_aGLWin.dpy, m_aGLWin.win, m_aGLWin.ctx ) )
     {
+        g_bAnyCurrent = false;
         SAL_WARN("vcl.opengl", "unable to select current GLX context");
         return false;
     }
 
+    g_bAnyCurrent = true;
+
     int glxMinor, glxMajor;
     double nGLXVersion = 0;
     if( glXQueryVersion( m_aGLWin.dpy, &glxMajor, &glxMinor ) )
@@ -400,8 +392,8 @@ bool X11OpenGLContext::ImplInit()
         }
     }
 
-    bool bRet = InitGLEW();
-    InitGLEWDebugging();
+    bool bRet = InitGL();
+    InitGLDebugging();
 
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
 
@@ -427,10 +419,12 @@ void X11OpenGLContext::makeCurrent()
     {
         if (!glXMakeCurrent( m_aGLWin.dpy, m_aGLWin.win, m_aGLWin.ctx ))
         {
+            g_bAnyCurrent = false;
             SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent failed "
                      "on drawable " << m_aGLWin.win);
             return;
         }
+        g_bAnyCurrent = true;
     }
 
     registerAsCurrent();
@@ -445,6 +439,7 @@ void X11OpenGLContext::destroyCurrentContext()
             g_vShareList.erase(itr);
 
         glXMakeCurrent(m_aGLWin.dpy, None, nullptr);
+        g_bAnyCurrent = false;
         if( glGetError() != GL_NO_ERROR )
         {
             SAL_WARN("vcl.opengl", "glError: " << glGetError());
diff --git a/vcl/osx/salobj.cxx b/vcl/osx/salobj.cxx
index c75f2a7..9e6e746 100644
--- a/vcl/osx/salobj.cxx
+++ b/vcl/osx/salobj.cxx
@@ -321,8 +321,8 @@ bool AquaOpenGLContext::ImplInit()
     NSOpenGLView* pView = getOpenGLView();
     [[pView openGLContext] makeCurrentContext];
 
-    bool bRet = InitGLEW();
-    InitGLEWDebugging();
+    bool bRet = InitGL();
+    InitGLDebugging();
     return bRet;
 }
 
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index fc12d88..11a0052 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -7,7 +7,6 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include <config_opengl.h>
 #include <chrono>
 
 #include <vcl/opengl/OpenGLContext.hxx>
@@ -205,13 +204,8 @@ extern "C" void
 APIENTRY
 #endif
 debug_callback(GLenum source, GLenum type, GLuint id,
-        GLenum severity, GLsizei , const GLchar* message,
-#if HAVE_GLEW_1_12
-        const GLvoid*
-#else
-        GLvoid*
-#endif
-        )
+               GLenum severity, GLsizei , const GLchar* message,
+               const GLvoid*)
 {
     // ignore Nvidia's 131218: "Program/shader state performance warning: Fragment Shader is going to be recompiled because the shader key based on GL state mismatches."
     // the GLSL compiler is a bit too aggressive in optimizing the state based on the current OpenGL state
@@ -281,30 +275,14 @@ OUString getGLString(GLenum eGlEnum)
     return sString;
 }
 
-bool OpenGLContext::InitGLEW()
+bool OpenGLContext::InitGL()
 {
-    static bool bGlewInit = false;
-    if(!bGlewInit)
-    {
-        OpenGLZone aZone;
-
-        glewExperimental = GL_TRUE;
-        GLenum err = glewInit();
-        if (err != GLEW_OK)
-        {
-            SAL_WARN("vcl.opengl", "Failed to initialize GLEW: " << glewGetErrorString(err));
-            return false;
-        }
-        else
-            bGlewInit = true;
-    }
-
     VCL_GL_INFO("OpenGLContext::ImplInit----end");
     VCL_GL_INFO("Vendor: " << getGLString(GL_VENDOR) << " Renderer: " << getGLString(GL_RENDERER) << " GL version: " << OpenGLHelper::getGLVersion());
     mbInitialized = true;
 
     // I think we need at least GL 3.0
-    if (!GLEW_VERSION_3_0)
+    if (epoxy_gl_version() < 30)
     {
         SAL_WARN("vcl.opengl", "We don't have at least OpenGL 3.0");
         return false;
@@ -320,11 +298,11 @@ bool OpenGLContext::InitGLEW()
     return true;
 }
 
-void OpenGLContext::InitGLEWDebugging()
+void OpenGLContext::InitGLDebugging()
 {
 #ifdef DBG_UTIL
     // only enable debug output in dbgutil build
-    if( GLEW_ARB_debug_output)
+    if (epoxy_has_gl_extension("GL_ARB_debug_output"))
     {
         OpenGLZone aZone;
 
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index e00a93a..6f4a880 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -401,7 +401,7 @@ GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,
         aGeometryShaderSource = getShaderSource(rGeometryShaderName);
 
     GLint bBinaryResult = GL_FALSE;
-    if( GLEW_ARB_get_program_binary && !rDigest.isEmpty() )
+    if (epoxy_has_gl_extension("GL_ARB_get_program_binary") && !rDigest.isEmpty())
     {
         OString aFileName =
                 createFileName(rVertexShaderName, rFragmentShaderName, rGeometryShaderName, rDigest);
@@ -473,7 +473,7 @@ GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,
     if (bHasGeometryShader)
         glAttachShader(ProgramID, GeometryShaderID);
 
-    if( GLEW_ARB_get_program_binary && !rDigest.isEmpty() )
+    if (epoxy_has_gl_extension("GL_ARB_get_program_binary") && !rDigest.isEmpty())
     {
         glProgramParameteri(ProgramID, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
         glLinkProgram(ProgramID);
@@ -1106,14 +1106,14 @@ void OpenGLHelper::debugMsgPrint(const int nType, const char *pFormat, ...)
     {
         OpenGLZone aZone;
 
-        if (GLEW_KHR_debug)
+        if (epoxy_has_gl_extension("GL_KHR_debug"))
             glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION,
                                  GL_DEBUG_TYPE_OTHER,
                                  1, // one[sic] id is as good as another ?
                                  // GL_DEBUG_SEVERITY_NOTIFICATION for >= GL4.3 ?
                                  GL_DEBUG_SEVERITY_LOW,
                                  strlen(pStr), pStr);
-        else if (GLEW_AMD_debug_output)
+        else if (epoxy_has_gl_extension("GL_AMD_debug_output"))
             glDebugMessageInsertAMD(GL_DEBUG_CATEGORY_APPLICATION_AMD,
                                     GL_DEBUG_SEVERITY_LOW_AMD,
                                     1, // one[sic] id is as good as another ?
diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx
index 0bff9b8..34f0e6f 100644
--- a/vcl/unx/generic/app/saldisp.cxx
+++ b/vcl/unx/generic/app/saldisp.cxx
@@ -47,7 +47,6 @@
 #include <X11/extensions/Xinerama.h>
 #endif
 
-#include "GL/glxew.h"
 #include <opengl/zone.hxx>
 
 #include <vcl/svapp.hxx>
diff --git a/vcl/workben/icontest.cxx b/vcl/workben/icontest.cxx
index ae2973b..32d6ae8 100644
--- a/vcl/workben/icontest.cxx
+++ b/vcl/workben/icontest.cxx
@@ -20,8 +20,6 @@
 
 #include <math.h>
 
-#include <GL/glew.h>
-
 #include <glm/gtx/bit.hpp>
 
 #include <com/sun/star/lang/XComponent.hpp>
-- 
2.13.0