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>
This commit is contained in:
Sylvain Munaut 2016-05-22 22:11:08 +02:00
parent dbe239380f
commit 1e4598ff34
3 changed files with 69 additions and 0 deletions

View File

@ -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)

View File

@ -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})

View File

@ -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