Browse Source

Platform: added publicly usable *Context libraries.

They contain the same platform-specific stub as is used in *Application
libraries to load GL function pointers.
pull/68/head
Vladimír Vondruš 12 years ago
parent
commit
c7e4f92f1c
  1. 3
      CMakeLists.txt
  2. 8
      doc/building.dox
  3. 12
      doc/cmake.dox
  4. 29
      doc/platform.dox
  5. 38
      modules/FindMagnum.cmake
  6. 39
      src/Magnum/Platform/CMakeLists.txt

3
CMakeLists.txt

@ -61,16 +61,19 @@ elseif(CORRADE_TARGET_ANDROID)
# OS X-specific application libraries
elseif(CORRADE_TARGET_APPLE)
cmake_dependent_option(WITH_WINDOWLESSCGLAPPLICATION "Build WindowlessCglApplication library" OFF "NOT WITH_MAGNUMINFO;NOT WITH_FONTCONVERTER;NOT WITH_DISTANCEFIELDCONVERTER" ON)
cmake_dependent_option(WITH_CGLCONTEXT "Build CglContext library" OFF "NOT TARGET_GLES" OFF)
# X11, GLX and EGL-specific application libraries
elseif(CORRADE_TARGET_UNIX)
option(WITH_GLXAPPLICATION "Build GlxApplication library" OFF)
cmake_dependent_option(WITH_WINDOWLESSGLXAPPLICATION "Build WindowlessGlxApplication library" OFF "NOT WITH_MAGNUMINFO;NOT WITH_FONTCONVERTER;NOT WITH_DISTANCEFIELDCONVERTER" ON)
cmake_dependent_option(WITH_XEGLAPPLICATION "Build XEglApplication library" OFF "TARGET_GLES" OFF)
cmake_dependent_option(WITH_GLXCONTEXT "Build GlxContext library" OFF "NOT TARGET_GLES" OFF)
# Windows-specific application libraries
elseif(CORRADE_TARGET_WINDOWS)
cmake_dependent_option(WITH_WINDOWLESSWGLAPPLICATION "Build WindowlessWglApplication library" OFF "NOT WITH_MAGNUMINFO;NOT WITH_FONTCONVERTER;NOT WITH_DISTANCEFIELDCONVERTER" ON)
cmake_dependent_option(WITH_WGLCONTEXT "Build WglContext library" OFF "NOT TARGET_GLES" OFF)
endif()
# Platform-independent (almost) application libraries

8
doc/building.dox

@ -205,6 +205,14 @@ platform best:
- `WITH_WINDOWLESSNACLAPPLICATION` - @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication"
- `WITH_WINDOWLESSWGLAPPLICATION` - @ref Platform::WindowlessWglApplication "WindowlessWglApplication"
None of the context libraries is built by default. You need them only if you
choose to not use any application library (see @ref platform-custom for more
information):
- `WITH_CGLCONTEXT` -- CGL context
- `WITH_GLXCONTEXT` -- GLX context
- `WITH_WGLCONTEXT` -- WGL context
There are also a few command-line utilities. They are currently available only
on Linux, Mac OS X and Windows, also disabled by default:

12
doc/cmake.dox

@ -102,6 +102,13 @@ Platform namespace is split into more components:
- `%WindowlessNaClApplication` -- @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication"
- `%WindowlessWglApplication` -- @ref Platform::WindowlessWglApplication "WindowlessWglApplication"
For manual context creation (without application wrappers) there are also
platform-specific context libraries:
- `CglContext` -- CGL context
- `GlxContext` -- GLX context
- `WglContext` -- WGL context
The library also contains a set of plugins for importing essential file
formats. Additional plugins are provided in separate plugin repository, see
@ref cmake-plugins for more information. If you are going to use dynamic
@ -143,7 +150,10 @@ If exactly one `*Application` or exactly one `Windowless*Application` component
is requested and found, its libraries and include dirs are available in
convenience aliases `MAGNUM_APPLICATION_LIBRARIES` /
`MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES` and `MAGNUM_APPLICATION_INCLUDE_DIRS`
/ `MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS` to simplify porting.
/ `MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS` to simplify porting. Similarly,
if exactly one `*Context` component is requested and found, its libraries and
include dirs are available in convenience aliases `MAGNUM_CONTEXT_LIBRARIES`
and `MAGNUM_CONTEXT_INCLUDE_DIRS`.
The package is found if either debug or release version of each requested
library (or plugin) is found. If both debug and release libraries (or plugins)

29
doc/platform.dox

@ -287,6 +287,35 @@ int main(int argc, char** argv) {
}
@endcode
On majority of platforms the @ref Platform::Context class does GL function
pointer loading using platform-specific APIs. In that case you also need to
find particular `*Context` library, add its include dir and then link to it.
These platform-specific libraries are available:
- `CglContext` -- CGL context
- `GlxContext` -- GLX context
- `WglContext` -- WGL context
Systems not listed here (such as Emscripten or NaCl) don't need any Context
library, because dynamic function pointer loading is not available on these.
For example, when you create the OpenGL context using GLX, you need to find
`GlxContext` component, include `${MAGNUM_GLCCONTEXT_INCLUDE_DIRS}` and link to
`${MAGNUM_GLXCONTEXT_LIBRARIES}`. Similarly to application libraries, you can
also use generic `${MAGNUM_CONTEXT_INCLUDE_DIRS}` and `${MAGNUM_CONTEXT_LIBRARIES}`,
providing you requested only one `*Context` component in the `find_package()`
call. Complete example:
@code
find_package(Magnum REQUIRED GlxContext)
include_directories(${MAGNUM_INCLUDE_DIRS} ${MAGNUM_CONTEXT_INCLUDE_DIRS})
add_executable(myapplication MyCustomApplication.cpp)
target_link_libraries(myapplication
${MAGNUM_LIBRARIES}
${MAGNUM_CONTEXT_LIBRARIES})
@endcode
- Next page: @ref types
*/
}}

38
modules/FindMagnum.cmake

@ -60,6 +60,9 @@
# WindowlessGlxApplication - Windowless GLX application
# WindowlessNaClApplication - Windowless NaCl application
# WindowlessWglApplication - Windowless WGL application
# CglContext - CGL context
# GlxContext - GLX context
# WglContext - WGL context
# Example usage with specifying additional components is:
# find_package(Magnum [REQUIRED|COMPONENTS]
# MeshTools Primitives GlutApplication)
@ -71,7 +74,10 @@
# component is requested and found, its libraries and include dirs are
# available in convenience aliases MAGNUM_APPLICATION_LIBRARIES /
# MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES and MAGNUM_APPLICATION_INCLUDE_DIRS
# / MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS to simplify porting.
# / MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS to simplify porting. Similarly,
# if exactly one *Context component is requested and found, its libraries and
# include dirs are available in convenience aliases MAGNUM_CONTEXT_LIBRARIES
# and MAGNUM_CONTEXT_INCLUDE_DIRS.
#
# The package is found if either debug or release version of each requested
# library (or plugin) is found. If both debug and release libraries (or
@ -409,6 +415,24 @@ foreach(component ${Magnum_FIND_COMPONENTS})
${_MAGNUM_${_COMPONENT}_LIBRARIES}
${_WINDOWCONTEXT_MAGNUM_LIBRARIES_DEPENDENCY})
# Context libraries
elseif(${component} MATCHES .+Context)
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform)
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Context.h)
# GLX context dependencies
if(${component} STREQUAL GlxStub)
find_package(X11)
if(X11_FOUND)
set(_MAGNUM_${_COMPONENT}_LIBRARIES ${X11_LIBRARIES})
else()
unset(MAGNUM_${_COMPONENT}_LIBRARY)
endif()
endif()
# No additional dependencies for CGL context
# No additional dependencies for WGL context
# Audio library
elseif(${component} STREQUAL Audio)
find_package(OpenAL)
@ -475,6 +499,18 @@ foreach(component ${Magnum_FIND_COMPONENTS})
unset(MAGNUM_APPLICATION_INCLUDE_DIRS)
endif()
endif()
# Global aliases for *Context components. If already set, unset them to
# avoid ambiguity.
if(${component} MATCHES .+Context)
if(NOT DEFINED MAGNUM_CONTEXT_LIBRARIES AND NOT DEFINED MAGNUM_CONTEXT_INCLUDE_DIRS)
set(MAGNUM_CONTEXT_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES})
set(MAGNUM_CONTEXT_INCLUDE_DIRS ${MAGNUM_${_COMPONENT}_INCLUDE_DIRS})
else()
unset(MAGNUM_CONTEXT_LIBRARIES)
unset(MAGNUM_CONTEXT_INCLUDE_DIRS)
endif()
endif()
else()
set(Magnum_${component}_FOUND FALSE)
endif()

39
src/Magnum/Platform/CMakeLists.txt

@ -365,19 +365,52 @@ if(NOT MAGNUM_TARGET_GLES)
endif()
# CGL context
if(NEED_CGLCONTEXT)
if(NEED_CGLCONTEXT OR WITH_CGLCONTEXT)
add_library(MagnumCglContextObjects OBJECT ${MagnumContext_SRCS})
# Also create proper static library, if requested
if(WITH_CGLCONTEXT)
# CMake-generated XCode projects had some problems when library
# consisted only of $<TARGET_OBJECTS> entries, thus compiling the
# sources again in this case
add_library(MagnumCglContext STATIC ${MagnumContext_SRCS})
set_target_properties(MagnumCglContext PROPERTIES DEBUG_POSTFIX "-d")
install(TARGETS MagnumCglContext
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
endif()
endif()
# GLX context
if(NEED_GLXCONTEXT)
if(NEED_GLXCONTEXT OR WITH_GLXCONTEXT)
add_library(MagnumGlxContextObjects OBJECT ${MagnumContext_SRCS})
set_target_properties(MagnumGlxContextObjects PROPERTIES COMPILE_DEFINITIONS "MAGNUM_PLATFORM_USE_GLX")
# Also create proper static library, if requested
if(WITH_GLXCONTEXT)
add_library(MagnumGlxContext STATIC $<TARGET_OBJECTS:MagnumGlxContextObjects>)
set_target_properties(MagnumGlxContext PROPERTIES DEBUG_POSTFIX "-d")
install(TARGETS MagnumGlxContext
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
endif()
endif()
# WGL context
if(NEED_WGLCONTEXT)
if(NEED_WGLCONTEXT OR WITH_WGLCONTEXT)
add_library(MagnumWglContextObjects OBJECT ${MagnumContext_SRCS})
# Also create proper static library, if requested
if(WITH_GLXCONTEXT)
add_library(MagnumWglContext STATIC $<TARGET_OBJECTS:MagnumWglContextObjects>)
set_target_properties(MagnumWglContext PROPERTIES DEBUG_POSTFIX "-d")
install(TARGETS MagnumWglContext
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
endif()
endif()
# Magnum Info

Loading…
Cancel
Save