diff --git a/CMakeLists.txt b/CMakeLists.txt index b0853ba78..17a27416c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,10 +17,10 @@ cmake_dependent_option(WITH_PRIMITIVES "Builf Primitives library" OFF "NOT WITH_ cmake_dependent_option(WITH_SCENEGRAPH "Build SceneGraph library" OFF "NOT WITH_EVERYTHING;NOT WITH_PHYSICS" ON) cmake_dependent_option(WITH_SHADERS "Build Shaders library" OFF "NOT WITH_EVERYTHING;NOT WITH_PHYSICS" ON) -option(WITH_GLXWINDOWCONTEXT "Build GlxWindowContext library" OFF) -cmake_dependent_option(WITH_XEGLWINDOWCONTEXT "Build XEglWindowContext library" OFF "TARGET_GLES" OFF) -cmake_dependent_option(WITH_GLUTWINDOWCONTEXT "Build GlutWindowContext library" OFF "NOT TARGET_GLES" OFF) -option(WITH_SDL2WINDOWCONTEXT "Build Sdl2WindowContext library" OFF) +option(WITH_GLXAPPLICATION "Build GlxApplication library" OFF) +cmake_dependent_option(WITH_XEGLAPPLICATION "Build XEglApplication library" OFF "TARGET_GLES" OFF) +cmake_dependent_option(WITH_GLUTAPPLICATION "Build GlutApplication library" OFF "NOT TARGET_GLES" OFF) +option(WITH_SDL2APPLICATION "Build Sdl2Application library" OFF) option(BUILD_TESTS "Build unit tests." OFF) diff --git a/README.md b/README.md index 9ed0bed4f..3eb2cc4fa 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ Features: * Plugin-based data exchange framework for importing image, mesh, material and scene data in various formats. * Collection of pre-made graphic primitives and shaders for testing purposes. - * Classes for easy creation of OpenGL context with various toolkits, methods - for querying supported OpenGL version and available extensions. + * Classes for creating OpenGL-enabled applications with various toolkits, + methods for querying supported OpenGL version and available extensions. * Comprehensive use of C++11 features for safety, performance and ease of development. All code which doesn't directly interact with OpenGL is covered with unit tests. @@ -45,13 +45,13 @@ Minimal dependencies Compilation, installation ------------------------- -The library (for example with GLUT window context) can be built and installed -using these four commands: +The library (for example with support for GLUT applications) can be built and +installed using these four commands: mkdir -p build && cd build cmake .. \ -DCMAKE_INSTALL_PREFIX=/usr \ - -DWITH_GLUTWINDOWCONTEXT=ON + -DWITH_GLUTAPPLICATION=ON make make install diff --git a/doc/building.dox b/doc/building.dox index a3beb30d6..52a1c25ad 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -37,14 +37,14 @@ subdirectory: git submodule update @section building-compilation Compilation, installation -The library (for example with GLUT window context) can be built and installed -using these four commands. See below for more information about optional -features. +The library (for example with support for GLUT applications) can be built and +installed using these four commands. See below for more information about +optional features. mkdir -p build && cd build cmake .. \ -DCMAKE_INSTALL_PREFIX=/usr \ - -DWITH_GLUTWINDOWCONTEXT=ON + -DWITH_GLUTAPPLICATION=ON make make install @@ -57,7 +57,7 @@ OpenGL ES, set `TARGET_GLES` to `ON` or pass `-DTARGET_GLES=ON` to CMake. Note that some features are available for desktop OpenGL only, see @ref requires-gl. By default the engine is built with everything except -@ref Contexts "context libraries". Using `WITH_*` CMake parameters you can +@ref Platform "application libraries". Using `WITH_*` CMake parameters you can specify which parts will be built and which not: - `WITH_EVERYTHING` - Defaults to `ON`, builds everything except window @@ -68,16 +68,16 @@ specify which parts will be built and which not: - `WITH_PRIMITIVES` - Primitives library. - `WITH_SHADERS` - Shaders library. -None of the window context libraries is built by default, regardless to +None of the application libraries is built by default, regardless to `WITH_EVERYTHING` is enabled or not: - - `WITH_XEGLWINDOWCONTEXT` - X/EGL window context, available only if - targeting OpenGL ES (see above). Requires **X11** and **EGL** libraries. - - `WITH_GLXWINDOWCONTEXT` - GLX window context. Requires **X11** and **GLX** + - `WITH_XEGLAPPLICATION` - X/EGL application, available only if targeting + OpenGL ES (see above). Requires **X11** and **EGL** libraries. + - `WITH_GLXAPPLICATION` - GLX application. Requires **X11** and **GLX** libraries. - - `WITH_GLUTWINDOWCONTEXT` - GLUT window context, available only if targeting + - `WITH_GLUTAPPLICATION` - GLUT application, available only if targeting desktop OpenGL. Requires **GLUT** library. - - `WITH_SDL2WINDOWCONTEXT` - SDL2 window context. Requires **SDL2** library. + - `WITH_SDL2APPLICATION` - SDL2 application. Requires **SDL2** library. @subsection building-tests Building and running unit tests If you want to build also unit tests (which are not built by default), pass diff --git a/doc/mainpage.dox b/doc/mainpage.dox index 3894d8a1f..b262155a7 100644 --- a/doc/mainpage.dox +++ b/doc/mainpage.dox @@ -21,7 +21,7 @@ Features: material and scene data in various formats. - Collection of pre-made @ref Primitives "graphic primitives" and @ref Shaders "shaders" for testing purposes. -- Classes for easy creation of OpenGL context with @ref Contexts +- Classes for creating OpenGL-enabled applications with @ref Platform "various toolkits", methods for querying @ref Context "supported OpenGL version and available extensions". - Comprehensive use of C++11 features for safety, performance and ease of @@ -41,7 +41,7 @@ Guide @ref building "how to download and build Magnum" on different platforms. To get up and running, you must first subclass one of the provided window context classes and implement required functions. %Magnum provides implementations for the most common toolkits (such as GLUT, Xlib, or SDL2) in -Contexts namespace. +Platform namespace. Then you can either draw your meshes directly or use SceneGraph which will help you with object hierarchy, transformations and resource management. diff --git a/doc/namespaces.dox b/doc/namespaces.dox index 4794c670e..7e0f7c08e 100644 --- a/doc/namespaces.dox +++ b/doc/namespaces.dox @@ -10,13 +10,13 @@ Contains classes for interacting with OpenGL. */ -/** @dir Contexts - * @brief Namespace Magnum::Contexts +/** @dir Platform + * @brief Namespace Magnum::Platform */ -/** @namespace Magnum::Contexts -@brief Context creation +/** @namespace Magnum::Platform +@brief Platform-specific application and context creation -Base classes for creating OpenGL contexts with various toolkits. +Base classes for creating applications with various toolkits. */ /** @dir Math diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 24fb74479..d325250f6 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -21,13 +21,13 @@ # Primitives - Library with stock geometric primitives (static) # SceneGraph - Scene graph library # Shaders - Library with stock shaders -# GlxContext - GLX context (depends on X11 libraries) -# XEglContext - X/EGL context (depends on EGL and X11 libraries) -# GlutContext - GLUT context (depends on GLUT library) -# Sdl2Context - SDL2 context (depends on SDL2 library) +# GlxApplication - GLX application (depends on X11 libraries) +# XEglApplication - X/EGL application (depends on EGL and X11 libraries) +# GlutApplication - GLUT application (depends on GLUT library) +# Sdl2Application - SDL2 application (depends on SDL2 library) # Example usage with specifying additional components is: # find_package(Magnum [REQUIRED|COMPONENTS] -# MeshTools Primitives GlutContext) +# MeshTools Primitives GlutApplication) # For each component is then defined: # MAGNUM_*_FOUND - Whether the component was found # MAGNUM_*_LIBRARIES - Component library and dependent libraries @@ -92,8 +92,8 @@ else() find_package(OpenGLES2 REQUIRED) endif() -# On Windows, *WindowContext libraries need to have ${MAGNUM_LIBRARY} listed -# in dependencies also after *WindowContext.lib static library name to avoid +# On Windows, *Application libraries need to have ${MAGNUM_LIBRARY} listed +# in dependencies also after *Application.lib static library name to avoid # linker errors if(WIN32) set(_WINDOWCONTEXT_MAGNUM_LIBRARY_DEPENDENCY ${MAGNUM_LIBRARY}) @@ -108,13 +108,13 @@ foreach(component ${Magnum_FIND_COMPONENTS}) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX ${component}) - # Window contexts - if(${component} MATCHES .+WindowContext) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Contexts) + # Applications + if(${component} MATCHES .+Application) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Platform) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES ${component}.h) - # GLUT window context dependencies - if(${component} STREQUAL GlutWindowContext) + # GLUT application dependencies + if(${component} STREQUAL GlutApplication) find_package(GLUT) if(GLUT_FOUND) set(_MAGNUM_${_COMPONENT}_LIBRARIES ${GLUT_LIBRARIES} ${_WINDOWCONTEXT_MAGNUM_LIBRARY_DEPENDENCY}) @@ -123,8 +123,8 @@ foreach(component ${Magnum_FIND_COMPONENTS}) endif() endif() - # SDL2 window context dependencies - if(${component} STREQUAL Sdl2WindowContext) + # SDL2 application dependencies + if(${component} STREQUAL Sdl2Application) find_package(SDL2) if(SDL2_FOUND) set(_MAGNUM_${_COMPONENT}_LIBRARIES ${SDL2_LIBRARY} ${_WINDOWCONTEXT_MAGNUM_LIBRARY_DEPENDENCY}) @@ -134,8 +134,8 @@ foreach(component ${Magnum_FIND_COMPONENTS}) endif() endif() - # GLX window context dependencies - if(${component} STREQUAL GlxWindowContext) + # GLX application dependencies + if(${component} STREQUAL GlxApplication) find_package(X11) if(X11_FOUND) set(_MAGNUM_${_COMPONENT}_LIBRARIES ${X11_LIBRARIES} ${_WINDOWCONTEXT_MAGNUM_LIBRARY_DEPENDENCY}) @@ -144,8 +144,8 @@ foreach(component ${Magnum_FIND_COMPONENTS}) endif() endif() - # X/EGL window context dependencies - if(${component} STREQUAL XEglWindowContext) + # X/EGL application dependencies + if(${component} STREQUAL XEglApplication) find_package(EGL) find_package(X11) if(EGL_FOUND AND X11_FOUND) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ac2aac236..bc81ad9f1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -124,7 +124,7 @@ install(FILES ${Magnum_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}) # Install also configure file install(FILES ${CMAKE_CURRENT_BINARY_DIR}/magnumConfigure.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}) -add_subdirectory(Contexts) +add_subdirectory(Platform) add_subdirectory(Math) add_subdirectory(Trade) diff --git a/src/Contexts/CMakeLists.txt b/src/Contexts/CMakeLists.txt deleted file mode 100644 index f11098375..000000000 --- a/src/Contexts/CMakeLists.txt +++ /dev/null @@ -1,93 +0,0 @@ -# Extension wrangler -add_library(MagnumContextsExtensionWrangler OBJECT ExtensionWrangler.cpp) - -set(MagnumContexts_HEADERS - AbstractContextHandler.h - AbstractWindowContext.h - ExtensionWrangler.h) -install(FILES ${MagnumContexts_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) - -# GLUT window context -if(WITH_GLUTWINDOWCONTEXT) - find_package(GLUT) - if(GLUT_FOUND) - add_library(MagnumGlutWindowContext STATIC - GlutWindowContext.cpp - $) - install(FILES GlutWindowContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) - install(TARGETS MagnumGlutWindowContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - else() - message(FATAL_ERROR "GLUT library, required by GlutWindowContext, was not found. Set WITH_GLUTWINDOWCONTEXT to OFF to skip building it.") - endif() -endif() - -# SDL2 window context -if(WITH_SDL2WINDOWCONTEXT) - find_package(SDL2) - if(SDL2_FOUND) - include_directories(${SDL2_INCLUDE_DIR}) - add_library(MagnumSdl2WindowContext STATIC - Sdl2WindowContext.cpp - $) - install(FILES Sdl2WindowContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) - install(TARGETS MagnumSdl2WindowContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - else() - message(FATAL_ERROR "SDL2 library, required by Sdl2WindowContext, was not found. Set WITH_SDL2WINDOWCONTEXT to OFF to skip building it.") - endif() -endif() - -# GLX window context -if(WITH_GLXWINDOWCONTEXT) - set(NEED_ABSTRACTXWINDOWCONTEXT 1) - set(NEED_GLXCONTEXT 1) - add_library(MagnumGlxWindowContext STATIC - $ - $ - $) - install(FILES GlxWindowContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) - install(TARGETS MagnumGlxWindowContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) -endif() - -# X/EGL window context -if(WITH_XEGLWINDOWCONTEXT) - set(NEED_ABSTRACTXWINDOWCONTEXT 1) - set(NEED_EGLCONTEXT 1) - add_library(MagnumXEglWindowContext STATIC - $ - $ - $) - install(FILES XEglWindowContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) - install(TARGETS MagnumXEglWindowContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) -endif() - -# Abstract X window context -if(NEED_ABSTRACTXWINDOWCONTEXT) - find_package(X11) - if(NOT X11_FOUND) - message(FATAL_ERROR "X11 library, required by some contexts, was not found. Set WITH_*X*WINDOWCONTEXT to OFF to skip building them.") - endif() - add_library(MagnumAbstractXWindowContext OBJECT AbstractXWindowContext.cpp) - # X11 macros are a mess, disable warnings for C-style casts - set_target_properties(MagnumAbstractXWindowContext PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") - install(FILES AbstractXWindowContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) -endif() - -# GLX context -if(NEED_GLXCONTEXT) - add_library(MagnumGlxContextHandler OBJECT GlxContextHandler.cpp) - # X11 macros are a mess, disable warnings for C-style casts - set_target_properties(MagnumGlxContextHandler PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") - install(FILES GlxContextHandler.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) -endif() - -# EGL context -if(NEED_EGLCONTEXT) - find_package(EGL) - if(NOT EGL_FOUND) - message(FATAL_ERROR "EGL library, required by some window contexts, was not found. Set WITH_*EGL*WINDOWCONTEXT to OFF to skip building them.") - endif() - add_library(MagnumEglContextHandler OBJECT EglContextHandler.cpp) - # X11 macros are a mess, disable warnings for C-style casts - set_target_properties(MagnumEglContextHandler PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") - install(FILES EglContextHandler.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) -endif() diff --git a/src/Contexts/AbstractWindowContext.h b/src/Platform/AbstractApplication.h similarity index 64% rename from src/Contexts/AbstractWindowContext.h rename to src/Platform/AbstractApplication.h index 8d5b0ba78..5a5025818 100644 --- a/src/Contexts/AbstractWindowContext.h +++ b/src/Platform/AbstractApplication.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Contexts_AbstractWindowContext_h -#define Magnum_Contexts_AbstractWindowContext_h +#ifndef Magnum_Platform_AbstractApplication_h +#define Magnum_Platform_AbstractApplication_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,18 +16,18 @@ */ /** @file - * @brief Class Magnum::Contexts::AbstractWindowContext + * @brief Class Magnum::Platform::AbstractApplication */ -namespace Magnum { namespace Contexts { +namespace Magnum { namespace Platform { /** -@brief Base class for context creation +@brief Base class for applications -See subclasses documentation for more information. Context classes subclasses -are meant to be used directly in `main()`, for example: +See subclasses documentation for more information. Subclasses are meant to be +used directly in `main()`, for example: @code -class MyContext: public Magnum::Contexts::GlutWindowContext { +class MyContext: public Magnum::Platform::GlutApplication { // implement required methods... }; int main(int argc, char** argv) { @@ -36,9 +36,9 @@ int main(int argc, char** argv) { } @endcode */ -class AbstractWindowContext { +class AbstractApplication { public: - virtual inline ~AbstractWindowContext() {} + virtual inline ~AbstractApplication() {} /** * @brief Execute main loop diff --git a/src/Contexts/AbstractContextHandler.h b/src/Platform/AbstractContextHandler.h similarity index 89% rename from src/Contexts/AbstractContextHandler.h rename to src/Platform/AbstractContextHandler.h index ba73aa940..81adb561b 100644 --- a/src/Contexts/AbstractContextHandler.h +++ b/src/Platform/AbstractContextHandler.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Contexts_AbstractContextHandler_h -#define Magnum_Contexts_AbstractContextHandler_h +#ifndef Magnum_Platform_AbstractContextHandler_h +#define Magnum_Platform_AbstractContextHandler_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,12 +16,12 @@ */ /** @file - * @brief Class Magnum::Contexts::AbstractContextHandler + * @brief Class Magnum::Platform::AbstractContextHandler */ #include "ExtensionWrangler.h" -namespace Magnum { namespace Contexts { +namespace Magnum { namespace Platform { /** @brief Base for OpenGL context handlers */ template class AbstractContextHandler { diff --git a/src/Contexts/AbstractXWindowContext.cpp b/src/Platform/AbstractXApplication.cpp similarity index 91% rename from src/Contexts/AbstractXWindowContext.cpp rename to src/Platform/AbstractXApplication.cpp index 0fbb95a9e..50948e61b 100644 --- a/src/Contexts/AbstractXWindowContext.cpp +++ b/src/Platform/AbstractXApplication.cpp @@ -13,7 +13,7 @@ GNU Lesser General Public License version 3 for more details. */ -#include "AbstractXWindowContext.h" +#include "AbstractXApplication.h" #include "Context.h" #include "ExtensionWrangler.h" @@ -25,9 +25,9 @@ using namespace std; -namespace Magnum { namespace Contexts { +namespace Magnum { namespace Platform { -AbstractXWindowContext::AbstractXWindowContext(AbstractContextHandler* contextHandler, int&, char**, const string& title, const Math::Vector2& size): contextHandler(contextHandler), viewportSize(size), flags(Flag::Redraw) { +AbstractXApplication::AbstractXApplication(AbstractContextHandler* contextHandler, int&, char**, const string& title, const Math::Vector2& size): contextHandler(contextHandler), viewportSize(size), flags(Flag::Redraw) { /* Get default X display */ display = XOpenDisplay(0); @@ -75,7 +75,7 @@ AbstractXWindowContext::AbstractXWindowContext(AbstractContextHandler @@ -16,7 +16,7 @@ */ /** @file - * @brief Class Magnum::Contexts::AbstractXWindowContext + * @brief Class Magnum::Platform::AbstractXApplication */ #include @@ -30,7 +30,7 @@ #undef Always #include "Math/Vector2.h" -#include "AbstractWindowContext.h" +#include "AbstractApplication.h" #include "AbstractContextHandler.h" #include "magnumCompatibility.h" @@ -39,16 +39,16 @@ namespace Magnum { class Context; -namespace Contexts { +namespace Platform { /** @nosubgrouping -@brief Base for X11-based contexts +@brief Base for X11-based applications Supports keyboard and mouse handling. @note Not meant to be used directly, see subclasses. */ -class AbstractXWindowContext: public AbstractWindowContext { +class AbstractXApplication: public AbstractApplication { public: /** * @brief Constructor @@ -60,14 +60,14 @@ class AbstractXWindowContext: public AbstractWindowContext { * * Creates window with double-buffered OpenGL ES 2 context. */ - AbstractXWindowContext(AbstractContextHandler* contextHandler, int& argc, char** argv, const std::string& title = "Magnum X window context", const Math::Vector2& size = Math::Vector2(800, 600)); + AbstractXApplication(AbstractContextHandler* contextHandler, int& argc, char** argv, const std::string& title = "Magnum X application", const Math::Vector2& size = Math::Vector2(800, 600)); /** * @brief Destructor * * Deletes context and destroys the window. */ - virtual ~AbstractXWindowContext() = 0; + virtual ~AbstractXApplication() = 0; int exec() override; @@ -77,16 +77,16 @@ class AbstractXWindowContext: public AbstractWindowContext { /** @{ @name Drawing functions */ protected: - /** @copydoc GlutWindowContext::viewportEvent() */ + /** @copydoc GlutApplication::viewportEvent() */ virtual void viewportEvent(const Math::Vector2& size) = 0; - /** @copydoc GlutWindowContext::drawEvent() */ + /** @copydoc GlutApplication::drawEvent() */ virtual void drawEvent() = 0; - /** @copydoc GlutWindowContext::swapBuffers() */ + /** @copydoc GlutApplication::swapBuffers() */ inline void swapBuffers() { contextHandler->swapBuffers(); } - /** @copydoc GlutWindowContext::redraw() */ + /** @copydoc GlutApplication::redraw() */ inline void redraw() { flags |= Flag::Redraw; } /*@}*/ @@ -293,15 +293,15 @@ class AbstractXWindowContext: public AbstractWindowContext { Flags flags; }; -CORRADE_ENUMSET_OPERATORS(AbstractXWindowContext::Modifiers) -CORRADE_ENUMSET_OPERATORS(AbstractXWindowContext::Flags) +CORRADE_ENUMSET_OPERATORS(AbstractXApplication::Modifiers) +CORRADE_ENUMSET_OPERATORS(AbstractXApplication::Flags) /* Implementations for inline functions with unused parameters */ -inline void AbstractXWindowContext::keyPressEvent(Key, Modifiers, const Math::Vector2&) {} -inline void AbstractXWindowContext::keyReleaseEvent(Key, Modifiers, const Math::Vector2&) {} -inline void AbstractXWindowContext::mousePressEvent(MouseButton, Modifiers, const Math::Vector2&) {} -inline void AbstractXWindowContext::mouseReleaseEvent(MouseButton, Modifiers, const Math::Vector2&) {} -inline void AbstractXWindowContext::mouseMotionEvent(Modifiers, const Math::Vector2&) {} +inline void AbstractXApplication::keyPressEvent(Key, Modifiers, const Math::Vector2&) {} +inline void AbstractXApplication::keyReleaseEvent(Key, Modifiers, const Math::Vector2&) {} +inline void AbstractXApplication::mousePressEvent(MouseButton, Modifiers, const Math::Vector2&) {} +inline void AbstractXApplication::mouseReleaseEvent(MouseButton, Modifiers, const Math::Vector2&) {} +inline void AbstractXApplication::mouseMotionEvent(Modifiers, const Math::Vector2&) {} }} diff --git a/src/Platform/CMakeLists.txt b/src/Platform/CMakeLists.txt new file mode 100644 index 000000000..9099367f2 --- /dev/null +++ b/src/Platform/CMakeLists.txt @@ -0,0 +1,93 @@ +# Extension wrangler +add_library(MagnumPlatformExtensionWrangler OBJECT ExtensionWrangler.cpp) + +set(MagnumPlatform_HEADERS + AbstractContextHandler.h + AbstractApplication.h + ExtensionWrangler.h) +install(FILES ${MagnumPlatform_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + +# GLUT application +if(WITH_GLUTAPPLICATION) + find_package(GLUT) + if(GLUT_FOUND) + add_library(MagnumGlutApplication STATIC + GlutApplication.cpp + $) + install(FILES GlutApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(TARGETS MagnumGlutApplication DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) + else() + message(FATAL_ERROR "GLUT library, required by GlutApplication, was not found. Set WITH_GLUTWINDOWCONTEXT to OFF to skip building it.") + endif() +endif() + +# SDL2 application +if(WITH_SDL2APPLICATION) + find_package(SDL2) + if(SDL2_FOUND) + include_directories(${SDL2_INCLUDE_DIR}) + add_library(MagnumSdl2Application STATIC + Sdl2Application.cpp + $) + install(FILES Sdl2Application.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(TARGETS MagnumSdl2Application DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) + else() + message(FATAL_ERROR "SDL2 library, required by Sdl2Application, was not found. Set WITH_SDL2WINDOWCONTEXT to OFF to skip building it.") + endif() +endif() + +# GLX application +if(WITH_GLXAPPLICATION) + set(NEED_ABSTRACTXAPPLICATION 1) + set(NEED_GLXCONTEXT 1) + add_library(MagnumGlxApplication STATIC + $ + $ + $) + install(FILES GlxApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(TARGETS MagnumGlxApplication DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) +endif() + +# X/EGL window context +if(WITH_XEGLWINDOWCONTEXT) + set(NEED_ABSTRACTXAPPLICATION 1) + set(NEED_EGLCONTEXT 1) + add_library(MagnumXEglApplication STATIC + $ + $ + $) + install(FILES XEglApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(TARGETS MagnumXEglApplication DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) +endif() + +# Abstract X application +if(NEED_ABSTRACTXAPPLICATION) + find_package(X11) + if(NOT X11_FOUND) + message(FATAL_ERROR "X11 library, required by some contexts, was not found. Set WITH_*X*WINDOWCONTEXT to OFF to skip building them.") + endif() + add_library(MagnumAbstractXApplication OBJECT AbstractXApplication.cpp) + # X11 macros are a mess, disable warnings for C-style casts + set_target_properties(MagnumAbstractXApplication PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") + install(FILES AbstractXApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) +endif() + +# GLX context +if(NEED_GLXCONTEXT) + add_library(MagnumGlxContextHandler OBJECT GlxContextHandler.cpp) + # X11 macros are a mess, disable warnings for C-style casts + set_target_properties(MagnumGlxContextHandler PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") + install(FILES GlxContextHandler.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) +endif() + +# EGL context +if(NEED_EGLCONTEXT) + find_package(EGL) + if(NOT EGL_FOUND) + message(FATAL_ERROR "EGL library, required by some window contexts, was not found. Set WITH_*EGL*WINDOWCONTEXT to OFF to skip building them.") + endif() + add_library(MagnumEglContextHandler OBJECT EglContextHandler.cpp) + # X11 macros are a mess, disable warnings for C-style casts + set_target_properties(MagnumEglContextHandler PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") + install(FILES EglContextHandler.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) +endif() diff --git a/src/Contexts/EglContextHandler.cpp b/src/Platform/EglContextHandler.cpp similarity index 98% rename from src/Contexts/EglContextHandler.cpp rename to src/Platform/EglContextHandler.cpp index e237b1714..6f0c9884d 100644 --- a/src/Contexts/EglContextHandler.cpp +++ b/src/Platform/EglContextHandler.cpp @@ -19,7 +19,7 @@ #include "Context.h" -namespace Magnum { namespace Contexts { +namespace Magnum { namespace Platform { EglContextHandler::~EglContextHandler() { eglDestroyContext(display, context); diff --git a/src/Contexts/EglContextHandler.h b/src/Platform/EglContextHandler.h similarity index 88% rename from src/Contexts/EglContextHandler.h rename to src/Platform/EglContextHandler.h index b05c68f69..1198695d0 100644 --- a/src/Contexts/EglContextHandler.h +++ b/src/Platform/EglContextHandler.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Contexts_EglContextHandler_h -#define Magnum_Contexts_EglContextHandler_h +#ifndef Magnum_Platform_EglContextHandler_h +#define Magnum_Platform_EglContextHandler_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,7 +16,7 @@ */ /** @file - * @brief Class Magnum::Contexts::EglContextHandler + * @brief Class Magnum::Platform::EglContextHandler */ #include "Magnum.h" @@ -33,7 +33,7 @@ #include "magnumCompatibility.h" -namespace Magnum { namespace Contexts { +namespace Magnum { namespace Platform { #ifndef DOXYGEN_GENERATING_OUTPUT /* EGL returns visual ID as int, but Xorg expects long unsigned int */ @@ -45,9 +45,9 @@ typedef EGLInt VisualId; #endif /** -@brief EGL interface +@brief EGL context -Used in XEglWindowContext. +Used in XEglApplication. */ class EglContextHandler: public AbstractContextHandler { public: diff --git a/src/Contexts/ExtensionWrangler.cpp b/src/Platform/ExtensionWrangler.cpp similarity index 96% rename from src/Contexts/ExtensionWrangler.cpp rename to src/Platform/ExtensionWrangler.cpp index 927b66628..c84795546 100644 --- a/src/Contexts/ExtensionWrangler.cpp +++ b/src/Platform/ExtensionWrangler.cpp @@ -19,7 +19,7 @@ #include "Magnum.h" -namespace Magnum { namespace Contexts { +namespace Magnum { namespace Platform { void ExtensionWrangler::initialize(ExperimentalFeatures experimentalFeatures) { #ifndef MAGNUM_TARGET_GLES diff --git a/src/Contexts/ExtensionWrangler.h b/src/Platform/ExtensionWrangler.h similarity index 84% rename from src/Contexts/ExtensionWrangler.h rename to src/Platform/ExtensionWrangler.h index 04dba65d3..f9353b3fc 100644 --- a/src/Contexts/ExtensionWrangler.h +++ b/src/Platform/ExtensionWrangler.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Contexts_ExtensionWrangler_h -#define Magnum_Contexts_ExtensionWrangler_h +#ifndef Magnum_Platform_ExtensionWrangler_h +#define Magnum_Platform_ExtensionWrangler_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,10 +16,10 @@ */ /** @file - * @brief Class Magnum::Contexts::ExtensionWrangler + * @brief Class Magnum::Platform::ExtensionWrangler */ -namespace Magnum { namespace Contexts { +namespace Magnum { namespace Platform { /** @brief Extension wrangler interface */ class ExtensionWrangler { diff --git a/src/Contexts/GlutWindowContext.cpp b/src/Platform/GlutApplication.cpp similarity index 80% rename from src/Contexts/GlutWindowContext.cpp rename to src/Platform/GlutApplication.cpp index f06f4b38f..321d51c2b 100644 --- a/src/Contexts/GlutWindowContext.cpp +++ b/src/Platform/GlutApplication.cpp @@ -13,16 +13,16 @@ GNU Lesser General Public License version 3 for more details. */ -#include "GlutWindowContext.h" +#include "GlutApplication.h" #include "Context.h" #include "ExtensionWrangler.h" -namespace Magnum { namespace Contexts { +namespace Magnum { namespace Platform { -GlutWindowContext* GlutWindowContext::instance = nullptr; +GlutApplication* GlutApplication::instance = nullptr; -GlutWindowContext::GlutWindowContext(int& argc, char** argv, const std::string& title, const Math::Vector2& size) { +GlutApplication::GlutApplication(int& argc, char** argv, const std::string& title, const Math::Vector2& size) { /* Save global instance */ instance = this; @@ -43,7 +43,7 @@ GlutWindowContext::GlutWindowContext(int& argc, char** argv, const std::string& c = new Context; } -GlutWindowContext::~GlutWindowContext() { +GlutApplication::~GlutApplication() { delete c; } diff --git a/src/Contexts/GlutWindowContext.h b/src/Platform/GlutApplication.h similarity index 90% rename from src/Contexts/GlutWindowContext.h rename to src/Platform/GlutApplication.h index 8cd016cb7..07ae26987 100644 --- a/src/Contexts/GlutWindowContext.h +++ b/src/Platform/GlutApplication.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Contexts_GlutWindowContext_h -#define Magnum_Contexts_GlutWindowContext_h +#ifndef Magnum_Platform_GlutApplication_h +#define Magnum_Platform_GlutApplication_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,7 +16,7 @@ */ /** @file - * @brief Class Magnum::Contexts::GlutWindowContext + * @brief Class Magnum::Platform::GlutApplication */ #include @@ -26,7 +26,7 @@ #include -#include "AbstractWindowContext.h" +#include "AbstractApplication.h" #include "magnumCompatibility.h" @@ -34,10 +34,10 @@ namespace Magnum { class Context; -namespace Contexts { +namespace Platform { /** @nosubgrouping -@brief GLUT context +@brief GLUT application Supports keyboard handling for limited subset of keys, mouse handling with support for changing cursor and mouse tracking and warping. @@ -45,7 +45,7 @@ support for changing cursor and mouse tracking and warping. You need to implement at least drawEvent() and viewportEvent() to be able to draw on the screen. */ -class GlutWindowContext: public AbstractWindowContext { +class GlutApplication: public AbstractApplication { public: /** * @brief Constructor @@ -56,9 +56,9 @@ class GlutWindowContext: public AbstractWindowContext { * * Creates double-buffered RGBA window with depth and stencil buffers. */ - GlutWindowContext(int& argc, char** argv, const std::string& title = "Magnum GLUT window context", const Math::Vector2& size = Math::Vector2(800, 600)); + GlutApplication(int& argc, char** argv, const std::string& title = "Magnum GLUT application", const Math::Vector2& size = Math::Vector2(800, 600)); - ~GlutWindowContext(); + ~GlutApplication(); inline int exec() override { glutMainLoop(); @@ -250,16 +250,16 @@ class GlutWindowContext: public AbstractWindowContext { instance->drawEvent(); } - static GlutWindowContext* instance; + static GlutApplication* instance; Context* c; }; /* Implementations for inline functions with unused parameters */ -inline void GlutWindowContext::keyPressEvent(Key, const Math::Vector2&) {} -inline void GlutWindowContext::mousePressEvent(MouseButton, const Math::Vector2&) {} -inline void GlutWindowContext::mouseReleaseEvent(MouseButton, const Math::Vector2&) {} -inline void GlutWindowContext::mouseMotionEvent(const Math::Vector2&) {} +inline void GlutApplication::keyPressEvent(Key, const Math::Vector2&) {} +inline void GlutApplication::mousePressEvent(MouseButton, const Math::Vector2&) {} +inline void GlutApplication::mouseReleaseEvent(MouseButton, const Math::Vector2&) {} +inline void GlutApplication::mouseMotionEvent(const Math::Vector2&) {} }} diff --git a/src/Contexts/GlxWindowContext.h b/src/Platform/GlxApplication.h similarity index 66% rename from src/Contexts/GlxWindowContext.h rename to src/Platform/GlxApplication.h index f69f6f7d7..90b15ad44 100644 --- a/src/Contexts/GlxWindowContext.h +++ b/src/Platform/GlxApplication.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Contexts_GlxWindowContext_h -#define Magnum_Contexts_GlxWindowContext_h +#ifndef Magnum_Platform_GlxApplication_h +#define Magnum_Platform_GlxApplication_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,20 +16,20 @@ */ /** @file - * @brief Class Magnum::Contexts::GlxWindowContext + * @brief Class Magnum::Platform::GlxApplication */ -#include "AbstractXWindowContext.h" +#include "AbstractXApplication.h" #include "GlxContextHandler.h" -namespace Magnum { namespace Contexts { +namespace Magnum { namespace Platform { /** -@brief GLX context +@brief GLX application Uses GlxContextHandler. */ -class GlxWindowContext: public AbstractXWindowContext { +class GlxApplication: public AbstractXApplication { public: /** * @brief Constructor @@ -41,7 +41,7 @@ class GlxWindowContext: public AbstractXWindowContext { * Creates window with double-buffered OpenGL 3.2 core context or * OpenGL ES 2.0 context, if targetting OpenGL ES. */ - inline GlxWindowContext(int& argc, char** argv, const std::string& title = "Magnum GLX window context", const Math::Vector2& size = Math::Vector2(800, 600)): AbstractXWindowContext(new GlxContextHandler, argc, argv, title, size) {} + inline GlxApplication(int& argc, char** argv, const std::string& title = "Magnum GLX application", const Math::Vector2& size = Math::Vector2(800, 600)): AbstractXApplication(new GlxContextHandler, argc, argv, title, size) {} }; }} diff --git a/src/Contexts/GlxContextHandler.cpp b/src/Platform/GlxContextHandler.cpp similarity index 98% rename from src/Contexts/GlxContextHandler.cpp rename to src/Platform/GlxContextHandler.cpp index ebc478b6c..cc6ab5698 100644 --- a/src/Contexts/GlxContextHandler.cpp +++ b/src/Platform/GlxContextHandler.cpp @@ -22,7 +22,7 @@ #define None 0L // redef Xlib nonsense -namespace Magnum { namespace Contexts { +namespace Magnum { namespace Platform { VisualID GlxContextHandler::getVisualId(Display* nativeDisplay) { display = nativeDisplay; diff --git a/src/Contexts/GlxContextHandler.h b/src/Platform/GlxContextHandler.h similarity index 88% rename from src/Contexts/GlxContextHandler.h rename to src/Platform/GlxContextHandler.h index 32ba4a81f..e59eb8083 100644 --- a/src/Contexts/GlxContextHandler.h +++ b/src/Platform/GlxContextHandler.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Contexts_GlxContextHandler_h -#define Magnum_Contexts_GlxContextHandler_h +#ifndef Magnum_Platform_GlxContextHandler_h +#define Magnum_Platform_GlxContextHandler_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,7 +16,7 @@ */ /** @file - * @brief Class Magnum::Contexts::GlxContextHandler + * @brief Class Magnum::Platform::GlxContextHandler */ #include "Magnum.h" @@ -29,15 +29,15 @@ #include "magnumCompatibility.h" -namespace Magnum { namespace Contexts { +namespace Magnum { namespace Platform { /** -@brief GLX interface +@brief GLX context Creates OpenGL 3.2 core context or OpenGL ES 2.0 context, if targetting OpenGL ES. -Used in GlxWindowContext. +Used in GlxApplication. */ class GlxContextHandler: public AbstractContextHandler { public: diff --git a/src/Contexts/Sdl2WindowContext.cpp b/src/Platform/Sdl2Application.cpp similarity index 93% rename from src/Contexts/Sdl2WindowContext.cpp rename to src/Platform/Sdl2Application.cpp index f87e33b06..00dfaee4d 100644 --- a/src/Contexts/Sdl2WindowContext.cpp +++ b/src/Platform/Sdl2Application.cpp @@ -13,14 +13,14 @@ GNU Lesser General Public License version 3 for more details. */ -#include "Sdl2WindowContext.h" +#include "Sdl2Application.h" #include "Context.h" #include "ExtensionWrangler.h" -namespace Magnum { namespace Contexts { +namespace Magnum { namespace Platform { -Sdl2WindowContext::Sdl2WindowContext(int, char**, const std::string& name, const Math::Vector2& size): _redraw(true) { +Sdl2Application::Sdl2Application(int, char**, const std::string& name, const Math::Vector2& size): _redraw(true) { if(SDL_Init(SDL_INIT_VIDEO) < 0) { Error() << "Cannot initialize SDL."; exit(1); @@ -58,7 +58,7 @@ Sdl2WindowContext::Sdl2WindowContext(int, char**, const std::string& name, const c = new Context; } -Sdl2WindowContext::~Sdl2WindowContext() { +Sdl2Application::~Sdl2Application() { delete c; SDL_GL_DeleteContext(context); @@ -66,7 +66,7 @@ Sdl2WindowContext::~Sdl2WindowContext() { SDL_Quit(); } -int Sdl2WindowContext::exec() { +int Sdl2Application::exec() { for(;;) { SDL_Event event; diff --git a/src/Contexts/Sdl2WindowContext.h b/src/Platform/Sdl2Application.h similarity index 83% rename from src/Contexts/Sdl2WindowContext.h rename to src/Platform/Sdl2Application.h index 1a215a2b7..0ce360313 100644 --- a/src/Contexts/Sdl2WindowContext.h +++ b/src/Platform/Sdl2Application.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Contexts_Sdl2WindowContext_h -#define Magnum_Contexts_Sdl2WindowContext_h +#ifndef Magnum_Platform_Sdl2Application_h +#define Magnum_Platform_Sdl2Application_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,7 +16,7 @@ */ /** @file - * @brief Class Magnum::Contexts::Sdl2WindowContext + * @brief Class Magnum::Platform::Sdl2Application */ #include "Math/Vector2.h" @@ -26,7 +26,7 @@ #include #include -#include "AbstractWindowContext.h" +#include "AbstractApplication.h" #include "magnumCompatibility.h" @@ -34,17 +34,17 @@ namespace Magnum { class Context; -namespace Contexts { +namespace Platform { /** @nosubgrouping -@brief SDL2 context +@brief SDL2 application Supports keyboard and mouse handling. You need to implement at least drawEvent() and viewportEvent() to be able to draw on the screen. */ -class Sdl2WindowContext: public AbstractWindowContext { +class Sdl2Application: public AbstractApplication { public: /** * @brief Constructor @@ -56,30 +56,30 @@ class Sdl2WindowContext: public AbstractWindowContext { * Creates centered non-resizable window with double-buffered * OpenGL 3.2 context with 24bit depth buffer. */ - Sdl2WindowContext(int argc, char** argv, const std::string& title = "Magnum SDL2 window context", const Math::Vector2& size = Math::Vector2(800, 600)); + Sdl2Application(int argc, char** argv, const std::string& title = "Magnum SDL2 application", const Math::Vector2& size = Math::Vector2(800, 600)); /** * @brief Destructor * * Deletes context and destroys the window. */ - ~Sdl2WindowContext(); + ~Sdl2Application(); int exec() override; /** @{ @name Drawing functions */ protected: - /** @copydoc GlutWindowContext::viewportEvent() */ + /** @copydoc GlutApplication::viewportEvent() */ virtual void viewportEvent(const Math::Vector2& size) = 0; - /** @copydoc GlutWindowContext::drawEvent() */ + /** @copydoc GlutApplication::drawEvent() */ virtual void drawEvent() = 0; - /** @copydoc GlutWindowContext::swapBuffers() */ + /** @copydoc GlutApplication::swapBuffers() */ inline void swapBuffers() { SDL_GL_SwapWindow(window); } - /** @copydoc GlutWindowContext::redraw() */ + /** @copydoc GlutApplication::redraw() */ inline void redraw() { _redraw = true; } /*@}*/ @@ -203,14 +203,14 @@ class Sdl2WindowContext: public AbstractWindowContext { bool _redraw; }; -CORRADE_ENUMSET_OPERATORS(Sdl2WindowContext::Modifiers) +CORRADE_ENUMSET_OPERATORS(Sdl2Application::Modifiers) /* Implementations for inline functions with unused parameters */ -inline void Sdl2WindowContext::keyPressEvent(Key, Modifiers, const Math::Vector2&) {} -inline void Sdl2WindowContext::keyReleaseEvent(Key, Modifiers, const Math::Vector2&) {} -inline void Sdl2WindowContext::mousePressEvent(MouseButton, Modifiers, const Math::Vector2&) {} -inline void Sdl2WindowContext::mouseReleaseEvent(MouseButton, Modifiers, const Math::Vector2&) {} -inline void Sdl2WindowContext::mouseMotionEvent(Modifiers, const Math::Vector2&) {} +inline void Sdl2Application::keyPressEvent(Key, Modifiers, const Math::Vector2&) {} +inline void Sdl2Application::keyReleaseEvent(Key, Modifiers, const Math::Vector2&) {} +inline void Sdl2Application::mousePressEvent(MouseButton, Modifiers, const Math::Vector2&) {} +inline void Sdl2Application::mouseReleaseEvent(MouseButton, Modifiers, const Math::Vector2&) {} +inline void Sdl2Application::mouseMotionEvent(Modifiers, const Math::Vector2&) {} }} diff --git a/src/Contexts/XEglWindowContext.h b/src/Platform/XEglApplication.h similarity index 64% rename from src/Contexts/XEglWindowContext.h rename to src/Platform/XEglApplication.h index 94f0ac034..0478b0921 100644 --- a/src/Contexts/XEglWindowContext.h +++ b/src/Platform/XEglApplication.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Contexts_XEglWindowContext_h -#define Magnum_Contexts_XEglWindowContext_h +#ifndef Magnum_Platform_XEglApplication_h +#define Magnum_Platform_XEglApplication_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,20 +16,20 @@ */ /** @file - * @brief Class Magnum::Contexts::XEglWindowContext + * @brief Class Magnum::Platform::XEglApplication */ -#include "AbstractXWindowContext.h" +#include "AbstractXApplication.h" #include "EglContextHandler.h" -namespace Magnum { namespace Contexts { +namespace Magnum { namespace Platform { /** -@brief X/EGL context +@brief X/EGL application Uses EglContextHandler. */ -class XEglWindowContext: public AbstractXWindowContext { +class XEglApplication: public AbstractXApplication { public: /** * @brief Constructor @@ -40,7 +40,7 @@ class XEglWindowContext: public AbstractXWindowContext { * * Creates window with double-buffered OpenGL ES 2 context. */ - inline XEglWindowContext(int& argc, char** argv, const std::string& title = "Magnum X/EGL window context", const Math::Vector2& size = Math::Vector2(800, 600)): AbstractXWindowContext(new EglContextHandler, argc, argv, title, size) {} + inline XEglApplication(int& argc, char** argv, const std::string& title = "Magnum X/EGL application", const Math::Vector2& size = Math::Vector2(800, 600)): AbstractXApplication(new EglContextHandler, argc, argv, title, size) {} }; }} diff --git a/src/Profiler.h b/src/Profiler.h index 3be943bd6..d17ef663b 100644 --- a/src/Profiler.h +++ b/src/Profiler.h @@ -32,7 +32,7 @@ namespace Magnum { @brief Measuring elapsed time in each frame Measures time passed during specified sections of each frame. It's meant to be -used in rendering and event loops (e.g. Contexts::GlutContext::drawEvent()), +used in rendering and event loops (e.g. Platform::GlutApplication::drawEvent()), but it's possible to use it standalone elsewhere. Example usage: @code Profiler p;