summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2016-05-22 22:11:08 +0200
committerSylvain Munaut <tnt@246tNt.com>2016-05-22 22:34:22 +0200
commit1e4598ff3423190b5bf18819bd27863b334cb2ee (patch)
tree985f2c0115c77de8d5f662459838ee642dc4d8fe
parentdbe239380fe1455a314ca75232969a6adb442eef (diff)
gr-fosphor: On WIN32 platform, link and use GLEW to find GL extensions
The FindGLEW is included because it seems the one shipping by CMake by default fails to find it on windows (which is the only platform where we use it ...) This is based on a patch from Geof Nieboer <gnieboer@corpcomm.net> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rw-r--r--cmake/Modules/FindGLEW.cmake50
-rw-r--r--lib/CMakeLists.txt7
-rw-r--r--lib/base_sink_c_impl.cc12
3 files changed, 69 insertions, 0 deletions
diff --git a/cmake/Modules/FindGLEW.cmake b/cmake/Modules/FindGLEW.cmake
new file mode 100644
index 0000000..14497ee
--- /dev/null
+++ b/cmake/Modules/FindGLEW.cmake
@@ -0,0 +1,50 @@
+#.rst:
+# FindGLEW
+# --------
+#
+# Find the OpenGL Extension Wrangler Library (GLEW)
+#
+# IMPORTED Targets
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines the :prop_tgt:`IMPORTED` target ``GLEW::GLEW``,
+# if GLEW has been found.
+#
+# Result Variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines the following variables:
+#
+# ::
+#
+# GLEW_INCLUDE_DIRS - include directories for GLEW
+# GLEW_LIBRARIES - libraries to link against GLEW
+# GLEW_FOUND - true if GLEW has been found and can be used
+
+#=============================================================================
+# Copyright 2012 Benjamin Eikel
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+find_path(GLEW_INCLUDE_DIR GL/glew.h)
+find_library(GLEW_LIBRARY NAMES GLEW glew64 glew32 glew glew32s PATH_SUFFIXES lib64 x86_64 x86 )
+
+set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR})
+set(GLEW_LIBRARIES ${GLEW_LIBRARY})
+
+if(GLEW_FOUND AND NOT TARGET GLEW::GLEW)
+ add_library(GLEW::GLEW UNKNOWN IMPORTED)
+ set_target_properties(GLEW::GLEW PROPERTIES
+ IMPORTED_LOCATION "${GLEW_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}")
+endif()
+
+mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index db29da7..dc669ab 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -48,6 +48,13 @@ link_directories(
${Boost_LIBRARY_DIRS}
)
+if(WIN32)
+ find_package(GLEW REQUIRED)
+ include_directories(${GLEW_INCLUDE_DIRS})
+ list(APPEND fosphor_libraries ${GLEW_LIBRARIES})
+ add_definitions(-DENABLE_GLEW)
+endif(WIN32)
+
if(ENABLE_PYTHON)
add_definitions(-DENABLE_PYTHON)
include_directories(${PYTHON_INCLUDE_DIRS})
diff --git a/lib/base_sink_c_impl.cc b/lib/base_sink_c_impl.cc
index 725f633..c4af03e 100644
--- a/lib/base_sink_c_impl.cc
+++ b/lib/base_sink_c_impl.cc
@@ -31,6 +31,10 @@
#include "fifo.h"
#include "base_sink_c_impl.h"
+#ifdef ENABLE_GLEW
+# include <GL/glew.h>
+#endif
+
extern "C" {
#include "fosphor/fosphor.h"
#include "fosphor/gl_platform.h"
@@ -88,6 +92,14 @@ void base_sink_c_impl::worker()
/* Init GL context */
this->glctx_init();
+#ifdef ENABLE_GLEW
+ GLenum glew_err = glewInit();
+ if (glew_err != GLEW_OK) {
+ GR_LOG_ERROR(d_logger, boost::format("GLEW initialization error : %s") % glewGetErrorString(glew_err));
+ goto error;
+ }
+#endif
+
/* Init fosphor */
{
/* (prevent // init of multiple instance to be gentle on the OpenCL