Author: Douglas Mencken <dougmencken@gmail.com>
Date:   Sun Aug 24 14:20:09 2014 -0400

    Don't force OpenGL requirement as "must have"
    
    enable_opengl is not only about "slide transitions and canvas"
    
    * enable glTF only when OpenGL is enabled
    * use glew only when OpenGL is enabled
    * make Library_vclopengl and Library_chartopengl depend on ENABLE_OPENGL
    * svx(svxcore), chart2, sc: don't build OpenGL stuff when it is not enabled
    
    Change-Id: If42f9c6a68b50bc590ace4a22d64f67e9cc02e95

diff --git a/Library_merged.mk b/Library_merged.mk
index 533acb0a..0d70cb2 100644
--- a/Library_merged.mk
+++ b/Library_merged.mk
@@ -62,7 +62,7 @@ $(eval $(call gb_Library_use_externals,merged,\
 	liblangtag \
 	libxml2 \
 	libxslt \
-	mesa_headers \
+	$(call gb_Helper_optional,ENABLE_OPENGL,mesa_headers) \
 	mythes \
 	nss3 \
 	$(call gb_Helper_optional,COLLADA2GLTF,opencollada_parser) \
@@ -102,8 +102,8 @@ ifeq ($(OS),LINUX)
 $(eval $(call gb_Library_add_libs,merged,\
 	-lm \
 	-ldl \
-	-lGL \
-	-lGLU \
+	$(call gb_Helper_optional,ENABLE_OPENGL,-lGL) \
+	$(call gb_Helper_optional,ENABLE_OPENGL,-lGLU) \
 	-lpthread \
 	-lrt \
 	-lX11 \
@@ -115,14 +115,14 @@ $(eval $(call gb_Library_use_system_win32_libs,merged,\
 	advapi32 \
 	gdi32 \
 	gdiplus \
-	glu32 \
+	$(call gb_Helper_optional,ENABLE_OPENGL,glu32) \
 	imm32 \
 	mpr \
 	msimg32 \
 	oldnames \
 	ole32 \
 	oleaut32 \
-	opengl32 \
+	$(call gb_Helper_optional,ENABLE_OPENGL,opengl32) \
 	shell32 \
 	shlwapi \
 	user32 \
@@ -151,7 +151,7 @@ $(eval $(call gb_Library_use_system_darwin_frameworks,merged,\
 	Cocoa \
 	CoreFoundation \
 	CoreServices \
-	OpenGL \
+	$(call gb_Helper_optional,ENABLE_OPENGL,OpenGL) \
 	QuickTime \
 ))
 endif
diff --git a/Repository.mk b/Repository.mk
index 7ed4be5..1b14d7d 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -237,9 +237,11 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,math, \
 	smd \
 ))
 
+ifeq ($(ENABLE_OPENGL),TRUE)
 $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ogltrans, \
 	OGLTrans \
 ))
+endif
 
 $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
 	acc \
@@ -260,7 +262,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
 	canvastools \
 	chartcore \
 	chartcontroller \
-	chartopengl \
+	$(if $(ENABLE_OPENGL),chartopengl) \
 	$(if $(filter $(OS),WNT),,cmdmail) \
 	cppcanvas \
 	configmgr \
@@ -395,7 +397,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
 	$(if $(DISABLE_SCRIPTING),,vbahelper) \
 	vcl \
 	vclcanvas \
-	vclopengl \
+	$(if $(ENABLE_OPENGL),vclopengl) \
 	$(if $(and $(filter unx,$(GUIBASE)),$(filter-out MACOSX,$(OS))), \
 		vclplug_gen \
 		$(if $(ENABLE_TDE),vclplug_tde) \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 05e1e05..3aa4c74 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -29,6 +29,8 @@
 
 # External headers
 
+ifneq ($(ENABLE_OPENGL),)
+
 ifneq ($(SYSTEM_MESA_HEADERS),)
 
 gb_LinkTarget__use_mesa_headers :=
@@ -45,6 +47,12 @@ endef
 
 endif # SYSTEM_MESA_HEADERS
 
+else # !ENABLE_OPENGL
+
+gb_LinkTarget__use_mesa_headers :=
+
+endif # ENABLE_OPENGL
+
 ifneq ($(SYSTEM_NPAPI_HEADERS),)
 
 # yes this uses internal headers too...
@@ -234,6 +242,8 @@ endef
 
 endif # SYSTEM_CPPUNIT
 
+ifneq ($(ENABLE_OPENGL),)
+
 ifneq ($(SYSTEM_GLEW),)
 
 define gb_LinkTarget__use_glew
@@ -279,6 +289,12 @@ endef
 
 endif # SYSTEM_GLEW
 
+else # !ENABLE_OPENGL
+
+gb_ExternalProject__use_glew :=
+
+endif # ENABLE_OPENGL
+
 define gb_LinkTarget__use_iconv
 $(call gb_LinkTarget_add_libs,$(1),-liconv)
 
diff --git a/avmedia/Library_avmedia.mk b/avmedia/Library_avmedia.mk
index 7cc08fa..a87676b 100644
--- a/avmedia/Library_avmedia.mk
+++ b/avmedia/Library_avmedia.mk
@@ -21,12 +21,13 @@ $(eval $(call gb_Library_use_sdk_api,avmedia,))
 
 $(eval $(call gb_Library_add_defs,avmedia,\
 	-DAVMEDIA_DLLIMPLEMENTATION \
+	$(if $(ENABLE_OPENGL),-DENABLE_OPENGL) \
 ))
 
 $(eval $(call gb_Library_use_externals,avmedia,\
 	boost_headers \
-	glew \
-	mesa_headers \
+	$(call gb_Helper_optional,ENABLE_OPENGL,glew) \
+	$(call gb_Helper_optional,ENABLE_OPENGL,mesa_headers) \
 ))
 
 $(eval $(call gb_Library_use_libraries,avmedia,\
@@ -42,7 +43,7 @@ $(eval $(call gb_Library_use_libraries,avmedia,\
 	tl \
 	utl \
 	vcl \
-	vclopengl \
+	$(call gb_Helper_optional,ENABLE_OPENGL,vclopengl) \
 	$(gb_UWINAPI) \
 ))
 
diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx
index b608b85..93a8adc 100644
--- a/avmedia/source/viewer/mediawindow_impl.cxx
+++ b/avmedia/source/viewer/mediawindow_impl.cxx
@@ -39,7 +39,9 @@
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/media/XManager.hpp>
 #include <vcl/sysdata.hxx>
+#ifdef ENABLE_OPENGL
 #include <vcl/opengl/OpenGLContext.hxx>
+#endif
 
 using namespace ::com::sun::star;
 
diff --git a/canvas/Module_canvas.mk b/canvas/Module_canvas.mk
index a655ed1..e127794 100644
--- a/canvas/Module_canvas.mk
+++ b/canvas/Module_canvas.mk
@@ -24,7 +24,7 @@ $(eval $(call gb_Module_add_targets,canvas,\
 	Library_canvastools \
 	Library_simplecanvas \
 	Library_vclcanvas \
-	Package_opengl \
+	$(call gb_Helper_optional,ENABLE_OPENGL,Package_opengl) \
 ))
 
 ifeq ($(ENABLE_CAIRO_CANVAS),TRUE)
diff --git a/chart2/Library_chartcontroller.mk b/chart2/Library_chartcontroller.mk
index f77ef70..c2edc52 100644
--- a/chart2/Library_chartcontroller.mk
+++ b/chart2/Library_chartcontroller.mk
@@ -22,6 +22,10 @@ $(eval $(call gb_Library_use_external,chartcontroller,boost_headers))
 
 $(eval $(call gb_Library_use_sdk_api,chartcontroller))
 
+ifeq ($(ENABLE_OPENGL),TRUE)
+$(eval $(call gb_Library_add_defs,chartcontroller,-DENABLE_OPENGL))
+endif
+
 $(eval $(call gb_Library_use_libraries,chartcontroller,\
     basegfx \
     chartcore \
@@ -75,7 +79,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\
     chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty \
     chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties \
     chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty \
-    chart2/source/controller/chartapiwrapper/WrappedGL3DProperties \
+    $(call gb_Helper_optional,ENABLE_OPENGL,chart2/source/controller/chartapiwrapper/WrappedGL3DProperties) \
     chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty \
     chart2/source/controller/chartapiwrapper/WrappedScaleProperty \
     chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties \
@@ -88,7 +92,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\
     chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty \
     chart2/source/controller/dialogs/ChangingResource \
     chart2/source/controller/dialogs/ChartTypeDialogController \
-    chart2/source/controller/dialogs/GL3DBarChartDialogController \
+    $(call gb_Helper_optional,ENABLE_OPENGL,chart2/source/controller/dialogs/GL3DBarChartDialogController) \
     chart2/source/controller/dialogs/DataBrowser \
     chart2/source/controller/dialogs/DataBrowserModel \
     chart2/source/controller/dialogs/DialogModel \
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 094762d..7f3abe4 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_Library_set_include,chartcore,\
 $(eval $(call gb_Library_add_defs,chartcore,\
     -DOOO_DLLIMPLEMENTATION_CHARTTOOLS \
     -DOOO_DLLIMPLEMENTATION_CHARTVIEW \
+    $(if $(ENABLE_OPENGL),-DENABLE_OPENGL) \
 ))
 
 $(eval $(call gb_Library_set_precompiled_header,chartcore,$(SRCDIR)/chart2/inc/pch/precompiled_chartcore))
@@ -28,8 +29,8 @@ $(eval $(call gb_Library_set_precompiled_header,chartcore,$(SRCDIR)/chart2/inc/p
 $(eval $(call gb_Library_use_externals,chartcore,\
 	boost_headers \
 	glm_headers \
-	glew \
-	mesa_headers \
+	$(call gb_Helper_optional,ENABLE_OPENGL,glew) \
+	$(call gb_Helper_optional,ENABLE_OPENGL,mesa_headers) \
 ))
 
 $(eval $(call gb_Library_use_custom_headers,chartcore,\
@@ -57,8 +58,7 @@ $(eval $(call gb_Library_use_libraries,chartcore,\
     ucbhelper \
     utl \
     vcl \
-    $(if $(filter FREEBSD LINUX MACOSX WNT,$(OS)), \
-        vclopengl) \
+        $(call gb_Helper_optional,ENABLE_OPENGL,vclopengl) \
 	$(gb_UWINAPI) \
 ))
 
@@ -85,7 +85,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
     chart2/source/view/axes/VPolarCoordinateSystem \
     chart2/source/view/axes/VPolarGrid \
     chart2/source/view/axes/VPolarRadiusAxis \
-    chart2/source/view/charttypes/GL3DBarChart \
+    $(call gb_Helper_optional,ENABLE_OPENGL,chart2/source/view/charttypes/GL3DBarChart) \
     chart2/source/view/charttypes/AreaChart \
     chart2/source/view/charttypes/BarChart \
     chart2/source/view/charttypes/BarPositionHelper \
@@ -97,14 +97,14 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
     chart2/source/view/charttypes/Splines \
     chart2/source/view/charttypes/VSeriesPlotter \
     chart2/source/view/diagram/VDiagram \
-    chart2/source/view/main/3DChartObjects \
+    $(call gb_Helper_optional,ENABLE_OPENGL,chart2/source/view/main/3DChartObjects) \
     chart2/source/view/main/ChartItemPool \
     chart2/source/view/main/ChartView \
     chart2/source/view/main/Clipping \
     chart2/source/view/main/DataPointSymbolSupplier \
     chart2/source/view/main/DrawModelWrapper \
-    chart2/source/view/main/GL3DPlotterBase \
-    chart2/source/view/main/GL3DRenderer \
+    $(call gb_Helper_optional,ENABLE_OPENGL,chart2/source/view/main/GL3DPlotterBase) \
+    $(call gb_Helper_optional,ENABLE_OPENGL,chart2/source/view/main/GL3DRenderer) \
     chart2/source/view/main/LabelPositionHelper \
     chart2/source/view/main/Linear3DTransformation \
     chart2/source/view/main/PlotterBase \
@@ -161,8 +161,8 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
     chart2/source/model/template/ColumnLineDataInterpreter \
     chart2/source/model/template/DataInterpreter \
     chart2/source/model/template/FilledNetChartType \
-    chart2/source/model/template/GL3DBarChartType \
-    chart2/source/model/template/GL3DBarChartTypeTemplate \
+    $(call gb_Helper_optional,ENABLE_OPENGL,chart2/source/model/template/GL3DBarChartType) \
+    $(call gb_Helper_optional,ENABLE_OPENGL,chart2/source/model/template/GL3DBarChartTypeTemplate) \
     chart2/source/model/template/LineChartType \
     chart2/source/model/template/LineChartTypeTemplate \
     chart2/source/model/template/NetChartType \
@@ -199,7 +199,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
     chart2/source/tools/ExponentialRegressionCurveCalculator \
     chart2/source/tools/FillProperties \
     chart2/source/tools/FormattedStringHelper \
-    chart2/source/tools/GL3DHelper \
+    $(call gb_Helper_optional,ENABLE_OPENGL,chart2/source/tools/GL3DHelper) \
     chart2/source/tools/ImplOPropertySet \
     chart2/source/tools/InternalData \
     chart2/source/tools/InternalDataProvider \
diff --git a/chart2/Module_chart2.mk b/chart2/Module_chart2.mk
index 16a74a1..b206148 100644
--- a/chart2/Module_chart2.mk
+++ b/chart2/Module_chart2.mk
@@ -12,8 +12,8 @@ $(eval $(call gb_Module_Module,chart2))
 $(eval $(call gb_Module_add_targets,chart2,\
     Library_chartcontroller \
     Library_chartcore \
-    Library_chartopengl \
-    Package_opengl \
+    $(call gb_Helper_optional,ENABLE_OPENGL,Library_chartopengl) \
+    $(call gb_Helper_optional,ENABLE_OPENGL,Package_opengl) \
 ))
 
 $(eval $(call gb_Module_add_l10n_targets,chart2,\
diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx
index 5ec13f1..3bb6fed 100644
--- a/chart2/inc/ChartModel.hxx
+++ b/chart2/inc/ChartModel.hxx
@@ -50,18 +50,29 @@
 
 #include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/chart2/XTitled.hpp>
+#ifdef ENABLE_OPENGL
 #include <com/sun/star/chart2/X3DChartWindowProvider.hpp>
+#endif
 
 #include <com/sun/star/frame/XLoadable.hpp>
 #include <com/sun/star/embed/XEmbeddedObject.hpp>
 #include <com/sun/star/embed/XStorage.hpp>
 #include <com/sun/star/datatransfer/XTransferable.hpp>
 
+#ifdef ENABLE_OPENGL
 #ifndef INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_23
 #define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_23
 #define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 23
 #include "comphelper/implbase_var.hxx"
 #endif
+#else
+#ifndef INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22
+#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22
+#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 22
+#include "comphelper/implbase_var.hxx"
+#endif
+#endif
+
 #include <osl/mutex.hxx>
 #include <rtl/ref.hxx>
 #include <cppuhelper/interfacecontainer.hxx>
@@ -79,7 +90,11 @@ namespace impl
 {
 
 // Note: needed for queryInterface (if it calls the base-class implementation)
+#ifdef ENABLE_OPENGL
 typedef ::comphelper::WeakImplHelper23<
+#else
+typedef ::comphelper::WeakImplHelper22<
+#endif
 //       ::com::sun::star::frame::XModel        //comprehends XComponent (required interface), base of XChartDocument
          ::com::sun::star::util::XCloseable     //comprehends XCloseBroadcaster
         ,::com::sun::star::frame::XStorable2    //(extension of XStorable)
@@ -102,7 +117,9 @@ typedef ::comphelper::WeakImplHelper23<
         ,::com::sun::star::document::XDocumentPropertiesSupplier
         ,::com::sun::star::chart2::data::XDataSource
         ,::com::sun::star::document::XUndoManagerSupplier
+#ifdef ENABLE_OPENGL
         ,::com::sun::star::chart2::X3DChartWindowProvider
+#endif
         ,::com::sun::star::qa::XDumper
         >
     ChartModel_Base;
@@ -580,9 +597,11 @@ public:
     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences()
         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
 
+#ifdef ENABLE_OPENGL
     // X3DChartWindowProvider
     virtual void SAL_CALL setWindow( sal_uInt64 nWindowPtr )
         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+#endif
 
     virtual void SAL_CALL update()
         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
@@ -603,13 +622,17 @@ public:
     void getNextTimePoint();
     void setTimeBasedRange(sal_Int32 nStart, sal_Int32 nEnd);
 
+#ifdef ENABLE_OPENGL
     OpenGLWindow* getOpenGLWindow() { return mpOpenGLWindow;}
+#endif
 
 private:
     sal_Int32 mnStart;
     sal_Int32 mnEnd;
     bool bSet;
+#ifdef ENABLE_OPENGL
     OpenGLWindow* mpOpenGLWindow;
+#endif
 };
 
 }  // namespace chart
diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx
index 4f2b961..7907cfa 100644
--- a/chart2/inc/ChartView.hxx
+++ b/chart2/inc/ChartView.hxx
@@ -54,8 +54,10 @@ class VCoordinateSystem;
 class DrawModelWrapper;
 class SeriesPlotterContainer;
 class VDataSeries;
+#ifdef ENABLE_OPENGL
 class GL3DPlotterBase;
 class GL2DRenderer;
+#endif
 
 enum TimeBasedMode
 {
@@ -104,7 +106,9 @@ class ChartView : public ::cppu::WeakImplHelper10<
         , public ExplicitValueProvider
         , private SfxListener
 {
+#ifdef ENABLE_OPENGL
     friend class GL2DRenderer;
+#endif
 private:
     void init();
 
@@ -197,14 +201,18 @@ public:
                   std::exception) SAL_OVERRIDE;
 
     void setViewDirty();
+#ifdef ENABLE_OPENGL
     void updateOpenGLWindow();
+#endif
 
 private: //methods
     ChartView();
 
     void createShapes();
+#ifdef ENABLE_OPENGL
     void createShapes3D();
     bool isReal3DChart();
+#endif
     void getMetaFile( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutStream
                       , bool bUseHighContrast );
     SdrPage* getSdrPage();
@@ -217,7 +225,9 @@ private: //methods
 
     void impl_updateView();
 
+#ifdef ENABLE_OPENGL
     void render();
+#endif
 
     ::com::sun::star::awt::Rectangle impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlotterContainer
         , const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes>& xDiagramPlusAxes_Shapes
@@ -277,10 +287,12 @@ private: //member
 
     ::com::sun::star::awt::Rectangle m_aResultingDiagramRectangleExcludingAxes;
 
-    boost::shared_ptr<GL3DPlotterBase> m_pGL3DPlotter;
     TimeBasedInfo maTimeBased;
     osl::Mutex maTimeMutex;
+#ifdef ENABLE_OPENGL
+    boost::shared_ptr<GL3DPlotterBase> m_pGL3DPlotter;
     boost::scoped_ptr<GL2DRenderer> mp2DRenderer;
+#endif
 };
 
 }
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index 695ecb1..af97995 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -91,7 +91,9 @@ enum eServiceType
     SERVICE_NAME_STOCK_DIAGRAM,
     SERVICE_NAME_XY_DIAGRAM,
     SERVICE_NAME_BUBBLE_DIAGRAM,
+#ifdef ENABLE_OPENGL
     SERVICE_NAME_GL3DBAR_DIAGRAM,
+#endif
 
     SERVICE_NAME_DASH_TABLE,
     SERVICE_NAME_GARDIENT_TABLE,
@@ -122,7 +124,9 @@ tServiceNameMap & lcl_getStaticServiceNameMap()
         ( "com.sun.star.chart.StockDiagram",                   SERVICE_NAME_STOCK_DIAGRAM )
         ( "com.sun.star.chart.XYDiagram",                      SERVICE_NAME_XY_DIAGRAM )
         ( "com.sun.star.chart.BubbleDiagram",                  SERVICE_NAME_BUBBLE_DIAGRAM )
+#ifdef ENABLE_OPENGL
         ( "com.sun.star.chart.GL3DBarDiagram",                 SERVICE_NAME_GL3DBAR_DIAGRAM )
+#endif
 
         ( "com.sun.star.drawing.DashTable",                    SERVICE_NAME_DASH_TABLE )
         ( "com.sun.star.drawing.GradientTable",                SERVICE_NAME_GARDIENT_TABLE )
@@ -1269,6 +1273,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance(
                     bCreateDiagram = true;
                 }
                 break;
+#ifdef ENABLE_OPENGL
             case SERVICE_NAME_GL3DBAR_DIAGRAM:
                 if( xManagerFact.is())
                 {
@@ -1278,6 +1283,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance(
                     bCreateDiagram = true;
                 }
                 break;
+#endif
 
             case SERVICE_NAME_DASH_TABLE:
             case SERVICE_NAME_GARDIENT_TABLE:
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index fba08df..5b56b9c 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -39,7 +39,9 @@
 #include "WrappedSplineProperties.hxx"
 #include "WrappedStockProperties.hxx"
 #include "WrappedSceneProperty.hxx"
+#ifdef ENABLE_OPENGL
 #include "WrappedGL3DProperties.hxx"
+#endif
 #include "RelativePositionHelper.hxx"
 #include "ContainerHelper.hxx"
 #include "ControllerLockGuard.hxx"
@@ -472,7 +474,9 @@ private:
         WrappedSplineProperties::addProperties( aProperties );
         WrappedStockProperties::addProperties( aProperties );
         WrappedAutomaticPositionProperties::addProperties( aProperties );
+#ifdef ENABLE_OPENGL
         WrappedGL3DProperties::addProperties(aProperties);
+#endif
 
         ::std::sort( aProperties.begin(), aProperties.end(),
                      ::chart::PropertyNameLess() );
@@ -526,8 +530,10 @@ OUString lcl_getDiagramType( const OUString & rTemplateServiceName )
     {
         const OUString aName( rTemplateServiceName.copy( aPrefix.getLength()));
 
+#if ENABLE_GL3D_BARCHART
         if (aName.indexOf("GL3DBar") != -1)
             return OUString("com.sun.star.chart.GL3DBarDiagram");
+#endif
 
         // "Area" "StackedArea" "PercentStackedArea" "ThreeDArea"
         // "StackedThreeDArea" "PercentStackedThreeDArea"
@@ -604,7 +610,9 @@ const tMakeStringStringMap& lcl_getChartTypeNameMap()
         ( "com.sun.star.chart2.NetChartType", "com.sun.star.chart.NetDiagram" )
         ( "com.sun.star.chart2.CandleStickChartType", "com.sun.star.chart.StockDiagram" )
         ( "com.sun.star.chart2.BubbleChartType", "com.sun.star.chart.BubbleDiagram" )
+#if ENABLE_GL3D_BARCHART
         ( "com.sun.star.chart2.GL3DBarChartType", "com.sun.star.chart.GL3DBarDiagram" )
+#endif
         ;
     return g_aChartTypeNameMap;
 }
@@ -2047,7 +2055,9 @@ const std::vector< WrappedProperty* > DiagramWrapper::createWrappedProperties()
     WrappedSplineProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
     WrappedStockProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
     WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties );
+#ifdef ENABLE_OPENGL
     WrappedGL3DProperties::addWrappedProperties(aWrappedProperties, m_spChart2ModelContact);
+#endif
 
     aWrappedProperties.push_back( new WrappedDataRowSourceProperty( m_spChart2ModelContact ) );
     aWrappedProperties.push_back( new WrappedStackingProperty( StackMode_Y_STACKED,m_spChart2ModelContact ) );
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index b57045d..44d3a52 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -43,7 +43,9 @@
 #include "DrawCommandDispatch.hxx"
 #include "ShapeController.hxx"
 #include "UndoActions.hxx"
+#ifdef ENABLE_OPENGL
 #include <GL3DHelper.hxx>
+#endif
 
 #include <comphelper/InlineContainer.hxx>
 
diff --git a/chart2/source/inc/macros.hxx b/chart2/source/inc/macros.hxx
index 2319afe..3a778b3 100644
--- a/chart2/source/inc/macros.hxx
+++ b/chart2/source/inc/macros.hxx
@@ -30,7 +30,11 @@
     typeid( ex ).name() << ", Message: " << \
     ex.Message )
 
+#ifdef ENABLE_OPENGL
 #define ENABLE_GL3D_BARCHART 1
+#else
+#define ENABLE_GL3D_BARCHART 0
+#endif
 
 #endif
 
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index f65f540..5491390 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -33,7 +33,9 @@
 #include "UndoManager.hxx"
 #include "ChartView.hxx"
 
+#ifdef ENABLE_OPENGL
 #include <vcl/openglwin.hxx>
+#endif
 
 #include <com/sun/star/chart/ChartDataRowSource.hpp>
 
@@ -108,7 +110,9 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
     , mnStart(0)
     , mnEnd(0)
     ,bSet(false)
+#ifdef ENABLE_OPENGL
     , mpOpenGLWindow(NULL)
+#endif
 {
     OSL_TRACE( "ChartModel: CTOR called" );
 
@@ -154,7 +158,9 @@ ChartModel::ChartModel( const ChartModel & rOther )
     , mnStart(rOther.mnStart)
     , mnEnd(rOther.mnEnd)
     , bSet(false)
+#ifdef ENABLE_OPENGL
     , mpOpenGLWindow(NULL)
+#endif
 {
     OSL_TRACE( "ChartModel: Copy-CTOR called" );
 
@@ -1407,6 +1413,7 @@ void ChartModel::setTimeBasedRange(sal_Int32 nStart, sal_Int32 nEnd)
     mbTimeBased = true;
 }
 
+#ifdef ENABLE_OPENGL
 void ChartModel::setWindow( const sal_uInt64 nWindowPtr )
     throw (uno::RuntimeException, std::exception)
 {
@@ -1415,6 +1422,7 @@ void ChartModel::setWindow( const sal_uInt64 nWindowPtr )
     assert(pWindow);
     mpOpenGLWindow = pWindow;
 }
+#endif
 
 void ChartModel::update()
     throw (uno::RuntimeException, std::exception)
@@ -1428,7 +1436,9 @@ void ChartModel::update()
     {
         mpChartView->setViewDirty();
         mpChartView->update();
+#ifdef ENABLE_OPENGL
         mpChartView->updateOpenGLWindow();
+#endif
     }
 }
 
diff --git a/chart2/source/model/template/ChartTypeManager.cxx b/chart2/source/model/template/ChartTypeManager.cxx
index f6ebbee..9537022 100644
--- a/chart2/source/model/template/ChartTypeManager.cxx
+++ b/chart2/source/model/template/ChartTypeManager.cxx
@@ -33,7 +33,9 @@
 #include "StockChartTypeTemplate.hxx"
 #include "NetChartTypeTemplate.hxx"
 #include "BubbleChartTypeTemplate.hxx"
+#ifdef ENABLE_OPENGL
 #include "GL3DBarChartTypeTemplate.hxx"
+#endif
 #include <cppuhelper/component_context.hxx>
 #include <comphelper/InlineContainer.hxx>
 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
@@ -122,8 +124,10 @@ enum TemplateId
     TEMPLATE_STOCKVOLUMELOWHIGHCLOSE,
     TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE,
     TEMPLATE_BUBBLE,
+#ifdef ENABLE_OPENGL
     TEMPLATE_GL3DBAR,
     TEMPLATE_GL3DBAR_ROUNDED_RECTANGLE,
+#endif
 //    TEMPLATE_SURFACE,
 //     TEMPLATE_ADDIN,
     TEMPLATE_NOT_FOUND = 0xffff
@@ -199,8 +203,10 @@ const tTemplateMapType & lcl_DefaultChartTypeMap()
         ( "com.sun.star.chart2.template.StockVolumeLowHighClose",        TEMPLATE_STOCKVOLUMELOWHIGHCLOSE )
         ( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose",    TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE )
         ( "com.sun.star.chart2.template.Bubble",                         TEMPLATE_BUBBLE )
+#ifdef ENABLE_OPENGL
         ( "com.sun.star.chart2.template.GL3DBar",                        TEMPLATE_GL3DBAR )
         ( "com.sun.star.chart2.template.GL3DBarRoundedRectangle",        TEMPLATE_GL3DBAR_ROUNDED_RECTANGLE )
+#endif
 //      ( "com.sun.star.chart2.template.Surface",                        TEMPLATE_SURFACE )
 //      ( "com.sun.star.chart2.template.Addin",                          TEMPLATE_ADDIN )
         );
@@ -534,12 +540,14 @@ uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance(
                 xTemplate.set( new BubbleChartTypeTemplate( m_xContext, aServiceSpecifier ));
                 break;
 
+#ifdef ENABLE_OPENGL
             case TEMPLATE_GL3DBAR:
                 xTemplate.set(new GL3DBarChartTypeTemplate(m_xContext, aServiceSpecifier));
                 break;
             case TEMPLATE_GL3DBAR_ROUNDED_RECTANGLE:
                 xTemplate.set(new GL3DBarChartTypeTemplate(m_xContext, aServiceSpecifier));
                 break;
+#endif
 
 //            case TEMPLATE_SURFACE:
 //            case TEMPLATE_ADDIN:
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 902705b..2ab33aa 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -50,8 +50,10 @@
 #include "DateHelper.hxx"
 #include "defines.hxx"
 #include <unonames.hxx>
+#ifdef ENABLE_OPENGL
 #include <GL3DBarChart.hxx>
 #include <GL3DHelper.hxx>
+#endif
 
 #include <rtl/uuid.h>
 #include <comphelper/scopeguard.hxx>
@@ -65,8 +67,10 @@
 #include <vcl/svapp.hxx>
 #include <osl/mutex.hxx>
 #include <svx/unofill.hxx>
+#ifdef ENABLE_OPENGL
 #include <vcl/openglwin.hxx>
 #include <vcl/opengl/OpenGLContext.hxx>
+#endif
 
 #include <drawinglayer/XShapeDumper.hxx>
 
@@ -129,6 +133,7 @@ class theExplicitValueProviderUnoTunnelId  : public rtl::Static<UnoTunnelIdInit,
 
 }
 
+#ifdef ENABLE_OPENGL
 class GL2DRenderer : public IRenderer
 {
 public:
@@ -203,6 +208,7 @@ void GL2DRenderer::updateOpenGLWindow()
     }
     mpWindow = pWindow;
 }
+#endif ENABLE_OPENGL
 
 const uno::Sequence<sal_Int8>& ExplicitValueProvider::getUnoTunnelId()
 {
@@ -245,7 +251,9 @@ ChartView::ChartView(
     , m_nScaleYDenominator(1)
     , m_bSdrViewIsInEditMode(false)
     , m_aResultingDiagramRectangleExcludingAxes(0,0,0,0)
+#ifdef ENABLE_OPENGL
     , mp2DRenderer(new GL2DRenderer(this))
+#endif
 {
     init();
 }
@@ -2429,6 +2437,7 @@ void ChartView::impl_refreshAddIn()
     }
 }
 
+#ifdef ENABLE_OPENGL
 /**
  * Is it a real 3D chart with a true 3D scene or a 3D chart in a 2D scene.
  */
@@ -2438,6 +2447,7 @@ bool ChartView::isReal3DChart()
 
     return GL3DHelper::isGL3DDiagram(xDiagram);
 }
+#endif
 
 void ChartView::createShapes()
 {
@@ -2481,6 +2491,7 @@ void ChartView::createShapes()
     pShapeFactory->clearPage(mxRootShape);
 
 #if HAVE_FEATURE_DESKTOP
+#ifdef ENABLE_OPENGL
     if(isReal3DChart())
     {
         createShapes3D();
@@ -2496,6 +2507,7 @@ void ChartView::createShapes()
             pWindow->Show(false);
     }
 #endif
+#endif
 
     {
         SolarMutexGuard aSolarGuard;
@@ -2642,7 +2654,9 @@ void ChartView::createShapes()
         //cleanup: remove all empty group shapes to avoid grey border lines:
         lcl_removeEmptyGroupShapes( mxRootShape );
 
+#ifdef ENABLE_OPENGL
         render();
+#endif
 
         if(maTimeBased.bTimeBased && maTimeBased.nFrame % 60 == 0)
         {
@@ -2696,6 +2710,7 @@ void ChartView::createShapes()
     }
 }
 
+#ifdef ENABLE_OPENGL
 void ChartView::render()
 {
     AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory);
@@ -2709,6 +2724,7 @@ void ChartView::render()
         pShapeFactory->postRender(pWindow);
     }
 }
+#endif
 
 // util::XEventListener (base of XCloseListener)
 void SAL_CALL ChartView::disposing( const lang::EventObject& /* rSource */ )
@@ -3153,6 +3169,7 @@ IMPL_LINK_NOARG(ChartView, UpdateTimeBased)
     return 0;
 }
 
+#ifdef ENABLE_OPENGL
 void ChartView::createShapes3D()
 {
     OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow();
@@ -3215,12 +3232,15 @@ void ChartView::createShapes3D()
 
     m_pGL3DPlotter->render();
 }
+#endif
 
+#ifdef ENABLE_OPENGL
 void ChartView::updateOpenGLWindow()
 {
     if(!isReal3DChart())
         mp2DRenderer->updateOpenGLWindow();
 }
+#endif
 
 } //namespace chart
 
diff --git a/configure.ac b/configure.ac
index 370ae6e..5142795 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1086,7 +1086,7 @@ AC_ARG_ENABLE(cairo-canvas,
 
 AC_ARG_ENABLE(opengl,
     AS_HELP_STRING([--disable-opengl],
-        [Determines whether to build the OpenGL 3D slide transitions and canvas component.]))
+        [Determines whether to build the OpenGL support.]))
 
 AC_ARG_ENABLE(opencl,
     AS_HELP_STRING([--disable-opencl],
@@ -8812,11 +8812,6 @@ fi
 AC_SUBST([SYSTEM_GLM])
 
 dnl ===================================================================
-dnl Check for system glew
-dnl ===================================================================
-libo_CHECK_SYSTEM_MODULE([glew], [GLEW], [glew >= 1.10.0])
-
-dnl ===================================================================
 dnl Check for system vigra
 dnl ===================================================================
 AC_MSG_CHECKING([which vigra to use])
@@ -10497,7 +10492,7 @@ dnl ===================================================================
 dnl Check whether the OpenGL libraries are available
 dnl ===================================================================
 
-AC_MSG_CHECKING([whether to build the OpenGL Transitions component])
+AC_MSG_CHECKING([whether to build the OpenGL support])
 ENABLE_OPENGL=
 
 if test -z "$enable_opengl"; then
@@ -10594,15 +10589,15 @@ dnl Check whether to enable glTF support
 dnl ===================================================================
 AC_MSG_CHECKING([whether to enable glTF support])
 ENABLE_GLTF=
-if test "x$enable_gltf" != "xno" -a $_os != iOS -a $_os != Android; then
+if test "x$enable_gltf" != "xno" -a "$ENABLE_OPENGL" = "TRUE" -a $_os != iOS -a $_os != Android; then
     ENABLE_GLTF=TRUE
     AC_MSG_RESULT([yes])
     AC_DEFINE(HAVE_FEATURE_GLTF,1)
     if test "$with_system_libgltf" = "yes"; then
-	SYSTEM_LIBGLTF=TRUE
-	PKG_CHECK_MODULES( LIBGLTF, libgltf-0.0 )
+        SYSTEM_LIBGLTF=TRUE
+        PKG_CHECK_MODULES( LIBGLTF, libgltf-0.0 )
     else
-    	BUILD_TYPE="$BUILD_TYPE LIBGLTF"
+        BUILD_TYPE="$BUILD_TYPE LIBGLTF"
     fi
 else
     AC_MSG_RESULT([no])
@@ -10627,6 +10622,17 @@ else
 fi
 AC_SUBST(ENABLE_COLLADA)
 
+dnl ===================================================================
+dnl Check whether to use glew
+dnl ===================================================================
+AC_MSG_CHECKING([whether to use glew])
+if test "$ENABLE_OPENGL" = "TRUE" ; then
+    AC_MSG_RESULT([yes])
+    libo_CHECK_SYSTEM_MODULE([glew], [GLEW], [glew >= 1.10.0])
+else
+    AC_MSG_RESULT([no])
+fi
+
 # pdf import?
 AC_MSG_CHECKING([whether to build the PDF import feature])
 ENABLE_PDFIMPORT=
diff --git a/include/svx/unoshape.hxx b/include/svx/unoshape.hxx
index cf9b40a..ad0075a 100644
--- a/include/svx/unoshape.hxx
+++ b/include/svx/unoshape.hxx
@@ -67,7 +67,9 @@ class SdrModel;
 class SvxDrawPage;
 class SvGlobalName;
 class Pair;
+#ifdef ENABLE_OPENGL
 class IOpenGLRenderer;
+#endif
 
 // Dimension arrows change size/position on save/reload (#i59051#)
 namespace basegfx
@@ -882,6 +884,7 @@ private:
     OUString referer_;
 };
 
+#ifdef ENABLE_OPENGL
 class SVX_DLLPUBLIC SvxOpenGLObject : public SvxShape
 {
 public:
@@ -891,6 +894,7 @@ public:
     void setRenderer(IOpenGLRenderer* pRenderer);
     IOpenGLRenderer* getRenderer();
 };
+#endif
 
 /*
  * This is a really ugly hack for the chart2 OpenGL backend
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index b317d8c..be043b2 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2005,7 +2005,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/chart2,\
 	SymbolStyle \
 	TickmarkStyle \
 	TransparencyStyle \
-	X3DChartWindowProvider \
+	$(call gb_Helper_optional,ENABLE_OPENGL,X3DChartWindowProvider) \
 	XAnyDescriptionAccess \
 	XAxis \
 	XChartDocument \
diff --git a/sc/CppunitTest_sc_ucalc.mk b/sc/CppunitTest_sc_ucalc.mk
index 48adfbd..7ed0669 100644
--- a/sc/CppunitTest_sc_ucalc.mk
+++ b/sc/CppunitTest_sc_ucalc.mk
@@ -69,7 +69,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_ucalc, \
     utl \
     vbahelper \
     vcl \
-    vclopengl \
+    $(call gb_Helper_optional,ENABLE_OPENGL,vclopengl) \
     xo \
 	$(gb_UWINAPI) \
 ))
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 639946a..137c684 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -27,6 +27,7 @@ $(eval $(call gb_Library_set_include,sc,\
 $(eval $(call gb_Library_add_defs,sc,\
     -DSC_DLLIMPLEMENTATION \
     -DSC_INFO_OSVERSION=\"$(OS)\" \
+    $(if $(ENABLE_OPENGL),-DENABLE_OPENGL) \
 ))
 
 $(eval $(call gb_Library_use_custom_headers,sc,\
@@ -88,7 +89,7 @@ $(eval $(call gb_Library_use_libraries,sc,\
     $(if $(filter TRUE,$(DISABLE_SCRIPTING)),, \
         vbahelper) \
     vcl \
-	vclopengl \
+    $(call gb_Helper_optional,ENABLE_OPENGL,vclopengl) \
     xo \
     $(gb_UWINAPI) \
 ))
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index fa9dbfd..24c47db 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -56,7 +56,9 @@
 #include <com/sun/star/chart2/data/XDataProvider.hpp>
 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
 #include <com/sun/star/chart2/XChartDocument.hpp>
+#ifdef ENABLE_OPENGL
 #include <com/sun/star/chart2/X3DChartWindowProvider.hpp>
+#endif
 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
@@ -544,6 +546,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
     ScDocument& rScDoc   = pScDocSh->GetDocument();
     bool bUndo (rScDoc.IsUndoEnabled());
 
+#ifdef ENABLE_OPENGL
     Window* pParentWindow = rData.GetActiveWin();
     OpenGLWindow* pChildWindow = new OpenGLWindow(pParentWindow);
     Size aWindowSize = pChildWindow->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) );
@@ -559,6 +562,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
     }
     else
         SAL_WARN("sc", "not a grid window. You are in serious trouble");
+#endif
 
     if( pReqArgs )
     {
@@ -634,7 +638,9 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
         // get chart position (from window size and data range)
         aStart = pViewSh->GetChartInsertPos( aSize, aPositionRange );
     }
+#ifdef ENABLE_OPENGL
     pChildWindow->SetPosPixel(pChildWindow->LogicToPixel(aStart, MapMode(MAP_100TH_MM)));
+#endif
 
     Rectangle aRect (aStart, aSize);
     SdrOle2Obj* pObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect);
@@ -729,7 +735,9 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
                     sal_Int16 nDialogRet = xDialog->execute();
                     if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL )
                     {
+#ifdef ENABLE_OPENGL
                         pGridWindow->DeleteChildWindow(pChildWindow);
+#endif
                         // leave OLE inplace mode and unmark
                         OSL_ASSERT( pViewShell );
                         OSL_ASSERT( pView );
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index d29222f..71180c6 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -189,7 +189,9 @@ private:
     void          DoReadUserDataSequence( const ::com::sun::star::uno::Sequence<
                                      ::com::sun::star::beans::PropertyValue >& rSettings );
 
+#ifdef ENABLE_OPENGL
     void AddOpenGLChartWindows();
+#endif
 
     DECL_LINK( SimpleRefClose, void* );
     DECL_LINK( SimpleRefDone, OUString* );
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 2fc3849..f1a9d46 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -39,7 +39,9 @@
 #include <unotools/moduleoptions.hxx>
 #include <tools/urlobj.hxx>
 #include <sfx2/docfile.hxx>
+#ifdef ENABLE_OPENGL
 #include <vcl/openglwin.hxx>
+#endif
 
 #include "tabvwsh.hxx"
 #include "sc.hrc"
@@ -92,7 +94,9 @@
 #include <gridwin.hxx>
 
 #include <com/sun/star/document/XDocumentProperties.hpp>
+#ifdef ENABLE_OPENGL
 #include <com/sun/star/chart2/X3DChartWindowProvider.hpp>
+#endif
 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
@@ -540,6 +544,7 @@ namespace {
 
 bool isGL3DDiagram( const css::uno::Reference<css::chart2::XDiagram>& xDiagram )
 {
+#ifdef ENABLE_OPENGL
     uno::Reference<chart2::XCoordinateSystemContainer> xCooSysContainer(xDiagram, uno::UNO_QUERY);
 
     if (!xCooSysContainer.is())
@@ -565,12 +570,14 @@ bool isGL3DDiagram( const css::uno::Reference<css::chart2::XDiagram>& xDiagram )
                 return true;
         }
     }
+#endif
 
     return false;
 }
 
 }
 
+#ifdef ENABLE_OPENGL
 void ScTabViewShell::AddOpenGLChartWindows()
 {
     ScDocument* pDoc = GetViewData().GetDocument();
@@ -603,6 +610,7 @@ void ScTabViewShell::AddOpenGLChartWindows()
         }
     }
 }
+#endif
 
 // DoReadUserData is also called from ctor when switching from print preview
 
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index 858bfa7..d175f79 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -246,7 +246,9 @@ ErrCode ScTabViewShell::DoVerb(long nVerb)
 
 void ScTabViewShell::Initialize()
 {
+#ifdef ENABLE_OPENGL
     AddOpenGLChartWindows();
+#endif
 }
 
 void ScTabViewShell::DeactivateOle()
diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk
index 93aba69..2cf3a29 100644
--- a/sd/Module_sd.mk
+++ b/sd/Module_sd.mk
@@ -14,7 +14,7 @@ $(eval $(call gb_Module_add_targets,sd,\
     Library_sdd \
     Library_sdfilt \
     $(call gb_Helper_optional,DESKTOP,Library_sdui) \
-    Package_opengl \
+    $(call gb_Helper_optional,ENABLE_OPENGL,Package_opengl) \
     Package_web \
     Package_xml \
 ))
diff --git a/slideshow/Library_slideshow.mk b/slideshow/Library_slideshow.mk
index d5af9a1..3d4bd74 100644
--- a/slideshow/Library_slideshow.mk
+++ b/slideshow/Library_slideshow.mk
@@ -22,6 +22,7 @@ $(eval $(call gb_Library_add_defs,slideshow,\
 ifneq ($(strip $(debug)$(DEBUG)),)
 $(eval $(call gb_Library_add_defs,slideshow,\
     -DBOOST_SP_ENABLE_DEBUG_HOOKS \
+    $(if $(ENABLE_OPENGL),-DENABLE_OPENGL) \
 ))
 endif
 
@@ -29,8 +30,8 @@ $(eval $(call gb_Library_set_precompiled_header,slideshow,$(SRCDIR)/slideshow/in
 
 $(eval $(call gb_Library_use_externals,slideshow,\
 	boost_headers \
-	glew \
-	mesa_headers \
+	$(call gb_Helper_optional,ENABLE_OPENGL,glew) \
+	$(call gb_Helper_optional,ENABLE_OPENGL,mesa_headers) \
 ))
 
 $(eval $(call gb_Library_use_sdk_api,slideshow))
@@ -48,7 +49,7 @@ $(eval $(call gb_Library_use_libraries,slideshow,\
     tl \
     utl \
     vcl \
-    vclopengl \
+    $(call gb_Helper_optional,ENABLE_OPENGL,vclopengl) \
     $(gb_UWINAPI) \
 ))
 
diff --git a/slideshow/Module_slideshow.mk b/slideshow/Module_slideshow.mk
index 5d9978b..9e936db 100644
--- a/slideshow/Module_slideshow.mk
+++ b/slideshow/Module_slideshow.mk
@@ -12,7 +12,7 @@ $(eval $(call gb_Module_Module,slideshow))
 $(eval $(call gb_Module_add_targets,slideshow,\
     $(if $(filter TRUE,$(ENABLE_OPENGL)),Library_OGLTrans) \
     Library_slideshow \
-	Package_opengl \
+    $(if $(filter TRUE,$(ENABLE_OPENGL)),Package_opengl) \
 ))
 
 # not working
diff --git a/slideshow/source/engine/shapes/viewmediashape.cxx b/slideshow/source/engine/shapes/viewmediashape.cxx
index 9ebc014..8a00af3 100644
--- a/slideshow/source/engine/shapes/viewmediashape.cxx
+++ b/slideshow/source/engine/shapes/viewmediashape.cxx
@@ -48,7 +48,9 @@
 #include <avmedia/mediawindow.hxx>
 #include <avmedia/modeltools.hxx>
 
+#ifdef ENABLE_OPENGL
 #include <vcl/opengl/OpenGLContext.hxx>
+#endif
 
 #include <com/sun/star/media/XManager.hpp>
 #include <com/sun/star/media/XPlayer.hpp>
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index 960650b..c7cb4f6 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -47,6 +47,7 @@ $(eval $(call gb_Library_set_precompiled_header,svxcore,$(SRCDIR)/svx/inc/pch/pr
 $(eval $(call gb_Library_add_defs,svxcore,\
     -DSVX_DLLIMPLEMENTATION \
     -DBOOST_SPIRIT_USE_OLD_NAMESPACE \
+    $(if $(ENABLE_OPENGL),-DENABLE_OPENGL) \
 ))
 
 $(eval $(call gb_Library_use_libraries,svxcore,\
@@ -74,7 +75,7 @@ $(eval $(call gb_Library_use_libraries,svxcore,\
     ucbhelper \
     utl \
     vcl \
-    vclopengl \
+    $(call gb_Helper_optional,ENABLE_OPENGL,vclopengl) \
     xo \
 	$(gb_UWINAPI) \
 ))
@@ -83,8 +84,8 @@ $(eval $(call gb_Library_use_externals,svxcore,\
 	boost_headers \
 	icuuc \
 	icu_headers \
-	mesa_headers \
-	glew \
+	$(call gb_Helper_optional,ENABLE_OPENGL,mesa_headers) \
+	$(call gb_Helper_optional,ENABLE_OPENGL,glew) \
 ))
 
 $(eval $(call gb_Library_add_exception_objects,svxcore,\
@@ -163,7 +164,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
     svx/source/sdr/contact/viewobjectcontactofpageobj \
     svx/source/sdr/contact/viewobjectcontactofe3dscene \
     svx/source/sdr/contact/viewcontactofgraphic \
-    svx/source/sdr/contact/viewcontactofopenglobj \
+    $(call gb_Helper_optional,ENABLE_OPENGL,svx/source/sdr/contact/viewcontactofopenglobj) \
     svx/source/sdr/contact/viewobjectcontactredirector \
     svx/source/sdr/contact/viewcontactofsdrcircobj \
     svx/source/sdr/contact/viewcontactofgroup \
@@ -198,7 +199,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
     svx/source/sdr/contact/viewcontactofsdrmeasureobj \
     svx/source/sdr/contact/objectcontactofobjlistpainter \
     svx/source/sdr/contact/viewobjectcontactofe3d \
-    svx/source/sdr/contact/viewobjectcontactofopenglobj \
+    $(call gb_Helper_optional,ENABLE_OPENGL,svx/source/sdr/contact/viewobjectcontactofopenglobj) \
     svx/source/sdr/event/eventhandler \
     svx/source/sdr/overlay/overlayline \
     svx/source/sdr/overlay/overlaycrosshair \
@@ -298,7 +299,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
     svx/source/svdraw/svdomeas \
     svx/source/svdraw/svdomedia \
     svx/source/svdraw/svdoole2 \
-    svx/source/svdraw/svdoopengl \
+    $(call gb_Helper_optional,ENABLE_OPENGL,svx/source/svdraw/svdoopengl) \
     svx/source/svdraw/svdopage \
     svx/source/svdraw/svdopath \
     svx/source/svdraw/svdorect \
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index dc2d8d8..9a530ee 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -128,7 +128,9 @@
 #include <svx/xlnwtit.hxx>
 #include <svx/xpoly.hxx>
 #include <rtl/strbuf.hxx>
+#ifdef ENABLE_OPENGL
 #include <svdoopengl.hxx>
+#endif
 #include <boost/scoped_ptr.hpp>
 
 using namespace ::com::sun::star;
@@ -3300,7 +3302,9 @@ SdrObject* SdrObjFactory::MakeNewObject(sal_uInt32 nInvent, sal_uInt16 nIdent, S
             case sal_uInt16(OBJ_MEDIA      ): pObj=new SdrMediaObj();               break;
 #endif
             case sal_uInt16(OBJ_TABLE      ): pObj=new ::sdr::table::SdrTableObj(pModel);   break;
+#ifdef ENABLE_OPENGL
             case sal_uInt16(OBJ_OPENGL     ): pObj=new SdrOpenGLObj;                break;
+#endif
         }
     }
 
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index cdce0f0..67ef41f9 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -806,9 +806,11 @@ SvxShape* SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt3
                 case OBJ_TABLE:
                     pRet = new SvxTableShape( pObj );
                     break;
+#ifdef ENABLE_OPENGL
                 case OBJ_OPENGL:
                     pRet = new SvxOpenGLObject( pObj );
                     break;
+#endif
                 default: // unbekanntes 2D-Objekt auf der Page
                     OSL_FAIL("Nicht implementierter Starone-Shape erzeugt! [CL]");
                     pRet = new SvxShapeText( pObj );
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index 655fa27..56fa12c 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -845,7 +845,9 @@ const UHashMapImpl& GetUHashImpl()
             { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DLatheObject"),   E3D_LATHEOBJ_ID   | E3D_INVENTOR_FLAG },
             { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DExtrudeObject"), E3D_EXTRUDEOBJ_ID | E3D_INVENTOR_FLAG },
             { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DPolygonObject"), E3D_POLYGONOBJ_ID | E3D_INVENTOR_FLAG },
+#ifdef ENABLE_OPENGL
             { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenGLObject"),         OBJ_OPENGL },
+#endif
         };
 
         for (sal_uInt32 i = 0; i < sizeof(aInit)/sizeof(aInit[0]); i++)
diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
index a05f61e..f83f6b3 100644
--- a/svx/source/unodraw/unoshap4.cxx
+++ b/svx/source/unodraw/unoshap4.cxx
@@ -50,7 +50,9 @@
 #include "svx/svdview.hxx"
 #include "svdglob.hxx"
 #include "svx/svdstr.hrc"
+#ifdef ENABLE_OPENGL
 #include <svdoopengl.hxx>
+#endif
 #include <vcl/wmf.hxx>
 #include <svtools/embedhlp.hxx>
 
@@ -975,6 +977,7 @@ SvxDummyShapeContainer::~SvxDummyShapeContainer() throw()
 {
 }
 
+#ifdef ENABLE_OPENGL
 void SvxOpenGLObject::setRenderer(IOpenGLRenderer* pRenderer)
 {
     static_cast<SdrOpenGLObj*>(GetSdrObject())->setRenderer(pRenderer);
@@ -984,5 +987,6 @@ IOpenGLRenderer* SvxOpenGLObject::getRenderer()
 {
     return static_cast<SdrOpenGLObj*>(GetSdrObject())->getRenderer();
 }
+#endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index acf8ccb..50cdfc3 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -30,7 +30,7 @@ $(eval $(call gb_Module_add_targets,vcl,\
         Executable_svptest \
         Executable_svpclient \
         Executable_vcldemo) \
-    Library_vclopengl \
+    $(call gb_Helper_optional,ENABLE_OPENGL,Library_vclopengl) \
 ))
 
 $(eval $(call gb_Module_add_l10n_targets,vcl,\
