Skip to content
This repository has been archived by the owner on Nov 18, 2018. It is now read-only.

Commit

Permalink
eglconvenience: Ensure we can query all GL functions
Browse files Browse the repository at this point in the history
Follow changed from qtbase 5e9a5246fb688a33ff27bed010226595f579f23d
to reduce or remove OS dependant code paths.
  • Loading branch information
plfiorini committed Apr 10, 2016
1 parent e95926e commit 691801f
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 1 deletion.
102 changes: 102 additions & 0 deletions cmake/FindLibdl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#.rst:
# FindLibdl
# ---------
#
# Try to find libdl on a Unix system.
#
# This will define the following variables:
#
# ``Libdl_FOUND``
# True if (the requested version of) libdl is available
# ``Libdl_LIBRARIES``
# This can be passed to target_link_libraries() instead of the ``Libdl::Libdl``
# target
# ``Libdl_INCLUDE_DIRS``
# This should be passed to target_include_directories() if the target is not
# used for linking
#
# If ``Libdl_FOUND`` is TRUE, it will also define the following imported target:
#
# ``Libdl::Libdl``
# The libdl library
#
# In general we recommend using the imported target, as it is easier to use.
# Bear in mind, however, that if the target is in the link interface of an
# exported library, it must be made available by the package config file.

#=============================================================================
# Copyright 2016 Pier Luigi Fiorini <[email protected]>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================

if(CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "CMake 2.8.12 is required by FindLibdl.cmake")
endif()
if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindLibdl.cmake")
endif()

if(UNIX)
find_path(Libdl_INCLUDE_DIR
NAMES
dlfcn.h
)
find_library(Libdl_LIBRARY
NAMES
dl libdl ltdl libltdl
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libdl
FOUND_VAR
Libdl_FOUND
REQUIRED_VARS
Libdl_LIBRARY
Libdl_INCLUDE_DIR
)

if(Libdl_FOUND AND NOT TARGET Libdl::Libdl)
add_library(Libdl::Libdl UNKNOWN IMPORTED)
set_target_properties(Libdl::Libdl PROPERTIES
IMPORTED_LOCATION "${Libdl_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${Libdl_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${Libdl_INCLUDE_DIR}"
)
endif()

mark_as_advanced(Libdl_LIBRARY Libdl_INCLUDE_DIR)

# compatibility variables
set(Libdl_LIBRARIES ${Libdl_LIBRARY})
set(Libdl_INCLUDE_DIRS ${Libdl_INCLUDE_DIR})
else()
message(STATUS "FindLibdl.cmake can find libdl only on UNIX systems.")
set(Libdl_FOUND FALSE)
endif()

include(FeatureSummary)
set_package_properties(Libdl PROPERTIES
DESCRIPTION "Programming interface to dynamic linking loader."
)
8 changes: 8 additions & 0 deletions src/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ set_package_properties(Libinput PROPERTIES
# gio
pkg_check_modules(gio gio-2.0 REQUIRED)

# libdl
find_package(Libdl REQUIRED)
set_package_properties(Libdl PROPERTIES
TYPE REQUIRED
PURPOSE "Required to load GL functions")

# Qt5PlatformSupport
find_package(Qt5PlatformSupport REQUIRED)
find_package(Freetype REQUIRED)
Expand Down Expand Up @@ -77,6 +83,7 @@ target_include_directories(GreenIslandPlatform
${CMAKE_BINARY_DIR}/headers/GreenIsland
${Qt5Core_PRIVATE_INCLUDE_DIRS}
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
${Libdl_INCLUDE_DIR}
)

target_link_libraries(GreenIslandPlatform
Expand All @@ -90,6 +97,7 @@ target_link_libraries(GreenIslandPlatform
${gio_LIBRARIES}
PRIVATE
Libinput::Libinput
Libdl::Libdl
${FONTCONFIG_LIBRARIES}
${FREETYPE_LIBRARIES}
Qt5PlatformSupport::Qt5PlatformSupport
Expand Down
11 changes: 10 additions & 1 deletion src/platform/eglconvenience/eglplatformcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
#include <QtCore/private/qjnihelpers_p.h>
#endif

#ifndef Q_OS_WIN
#include <dlfcn.h>
#endif

#include "logging.h"
#include "eglplatformcontext.h"
#include "eglconvenience.h"
Expand Down Expand Up @@ -446,7 +450,12 @@ void EGLPlatformContext::swapBuffers(QPlatformSurface *surface)
QFunctionPointer EGLPlatformContext::getProcAddress(const char *procName)
{
eglBindAPI(m_api);
return eglGetProcAddress(procName);
QFunctionPointer proc = (QFunctionPointer) eglGetProcAddress(procName);
#ifndef Q_OS_WIN
if (!proc)
proc = (QFunctionPointer) dlsym(RTLD_DEFAULT, procName);
#endif
return proc;
}
#else
void (*EGLPlatformContext::getProcAddress(const QByteArray &procName)) ()
Expand Down

0 comments on commit 691801f

Please sign in to comment.