From 081f784836f08d67e42c3165b0a73bafa7ea9858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 2 Aug 2019 13:27:27 +0200 Subject: [PATCH] Platform: improve ScreenedApplication docs. --- doc/snippets/MagnumPlatform.cpp | 51 +++++++++++++++++++++++ src/Magnum/Platform/Screen.h | 7 ++-- src/Magnum/Platform/ScreenedApplication.h | 47 ++++++++++++--------- 3 files changed, 81 insertions(+), 24 deletions(-) diff --git a/doc/snippets/MagnumPlatform.cpp b/doc/snippets/MagnumPlatform.cpp index 380452a6c..04a323444 100644 --- a/doc/snippets/MagnumPlatform.cpp +++ b/doc/snippets/MagnumPlatform.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include @@ -144,3 +146,52 @@ MyApplication::MyApplication(const Arguments& arguments): /* [trycreatecontext] */ } + +namespace F { + +int argc = 0; +struct MyApplication: Platform::ScreenedApplication { + MyApplication(): Platform::ScreenedApplication{Arguments{argc, nullptr}} {} + + void globalViewportEvent(ViewportEvent& event) override; + void globalDrawEvent() override; +}; + +/* [ScreenedApplication-global-events] */ +void MyApplication::globalViewportEvent(ViewportEvent& event) { + GL::defaultFramebuffer.setViewport({{}, event.framebufferSize()}); + + // Other stuff that should be done *before* all other event handlers ... +} + +void MyApplication::globalDrawEvent() { + // Other stuff that should be done *after* all other event handlers ... + + swapBuffers(); +} +/* [ScreenedApplication-global-events] */ + +void foo(); +void foo() { +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" +#endif +/* [ScreenedApplication-for-range] */ +MyApplication app; +for(Platform::Screen& screen: app.screens()) { + // ... +} +/* [ScreenedApplication-for-range] */ + +/* [ScreenedApplication-for] */ +for(Platform::Screen* s = app.screens().first(); s; s = s->nextFartherScreen()) { + // ... +} +/* [ScreenedApplication-for] */ +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif +} + +} diff --git a/src/Magnum/Platform/Screen.h b/src/Magnum/Platform/Screen.h index 9f993c866..3cdd1914f 100644 --- a/src/Magnum/Platform/Screen.h +++ b/src/Magnum/Platform/Screen.h @@ -101,15 +101,14 @@ template class ScreenTextEditingEventMixin @m_keywords{Screen} -See @ref BasicScreenedApplication for more information. - -If exactly one application header is included, this class is also aliased to +See @ref BasicScreenedApplication for more information. If exactly one +application header is included, this class is also aliased to @cpp Platform::Screen @ce. @section Platform-BasicScreen-template-specializations Explicit template specializations The following specialization are explicitly compiled into each particular -`*Application` library. For other specializations you have to use +`*Application` library. For other specializations you have to use the @ref ScreenedApplication.hpp implementation file to avoid linker errors. See @ref compilation-speedup-hpp for more information. diff --git a/src/Magnum/Platform/ScreenedApplication.h b/src/Magnum/Platform/ScreenedApplication.h index d9445af17..2ee242ce2 100644 --- a/src/Magnum/Platform/ScreenedApplication.h +++ b/src/Magnum/Platform/ScreenedApplication.h @@ -105,14 +105,16 @@ template struct ApplicationTextEditingEventMixinnextFartherScreen()) { - // ... -} -@endcode +@snippet MagnumPlatform.cpp ScreenedApplication-for @section Platform-ScreenedApplication-template-specializations Explicit template specializations The following specialization are explicitly compiled into each particular -`*Application` library. For other specializations you have to use +`*Application` library. For other specializations you have to use the @ref ScreenedApplication.hpp implementation file to avoid linker errors. See @ref compilation-speedup-hpp for more information.