template<class Application>
Magnum::Platform::BasicScreenedApplication class

Base for applications with screen management.

Manages list of screens and propagates events to them. If exactly one application header is included, this class is also aliased to Platform::ScreenedApplication.

When you derive from this class, you're not allowed to implement any usual application event handlers — instead, these are propagated to Screen instances that get added using addScreen(). Each Screen specifies which set of events should be propagated to it using BasicScreen::setPropagatedEvents(). When the application gets an event, they are propagated to the screens:

For the actual application, at the very least you need to implement globalDrawEvent(), and in case your application is resizable, globalViewportEvent() as well. The global draw event gets called after all Screen::drawEvent() in order to make it possible for you to do a buffer swap, while the global viewport event gets called before all Screen::viewportEvent(), in this case to make it possible to handle viewport changes on the default framebuffer:

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();
}

Uses Corrade::Containers::LinkedList for efficient screen management. Traversing front-to-back through the list of screens can be done using range-based for:

MyApplication app;
for(Platform::Screen& screen: app.screens()) {
    ;
}

Or, if you need more flexibility, like in the following code. Traversing back-to-front can be done using Corrade::Containers::LinkedList::last() and BasicScreen::nextNearerScreen().

for(Platform::Screen* s = app.screens().first(); s; s = s->nextFartherScreen()) {
    // ...
}

Explicit template specializations

The following specialization are explicitly compiled into each particular *Application library. For other specializations you have to use the ScreenedApplication.hpp implementation file to avoid linker errors. See Template headers and implementation files for more information.

Constructors, destructors, conversion operators

BasicScreenedApplication(const typename Application::Arguments& arguments, const typename Application::Configuration& configuration, const typename Application::GLConfiguration& glConfiguration) explicit
Construct with given configuration for OpenGL context.
BasicScreenedApplication(const typename Application::Arguments& arguments, const typename Application::Configuration& configuration = typename Application::Configuration{}) explicit
Construct with given configuration.
BasicScreenedApplication(const typename Application::Arguments& arguments, NoCreateT) explicit
Constructor.

Public functions

auto addScreen(BasicScreen<Application>& screen) -> BasicScreenedApplication<Application>&
Add screen to application.
auto removeScreen(BasicScreen<Application>& screen) -> BasicScreenedApplication<Application>&
Remove screen from application.
auto focusScreen(BasicScreen<Application>& screen) -> BasicScreenedApplication<Application>&
Focus screen.
auto screens() -> Containers::LinkedList<BasicScreen<Application>>&
Application screens.
auto screens() const -> const Containers::LinkedList<BasicScreen<Application>>&

Private functions

void globalViewportEvent(typename Application::ViewportEvent& size) virtual
Global viewport event.
void globalBeforeDrawEvent() virtual new in 2020.06
Before draw event.
void globalDrawEvent() pure virtual
Draw event.

Function documentation

template<class Application>
Magnum::Platform::BasicScreenedApplication<Application>::BasicScreenedApplication(const typename Application::Arguments& arguments, const typename Application::Configuration& configuration, const typename Application::GLConfiguration& glConfiguration) explicit

Construct with given configuration for OpenGL context.

Passes the arguments through to a particular application constructor.

template<class Application>
Magnum::Platform::BasicScreenedApplication<Application>::BasicScreenedApplication(const typename Application::Arguments& arguments, const typename Application::Configuration& configuration = typename Application::Configuration{}) explicit

Construct with given configuration.

Passes the arguments through to a particular application constructor.

template<class Application>
Magnum::Platform::BasicScreenedApplication<Application>::BasicScreenedApplication(const typename Application::Arguments& arguments, NoCreateT) explicit

Constructor.

Parameters
arguments Application arguments

Unlike above, the context is not created and must be created later with create() or tryCreate().

template<class Application>
BasicScreenedApplication<Application>& Magnum::Platform::BasicScreenedApplication<Application>::addScreen(BasicScreen<Application>& screen)

Add screen to application.

Returns Reference to self (for method chaining)

The new screen is added as backmost. If this is the first screen added, BasicScreen::focusEvent() is called. If not, neither BasicScreen::blurEvent() nor BasicScreen::focusEvent() is called (i.e. the screen default state is used).

Alternatively, a screen can be created using the BasicScreen::BasicScreen(BasicScreenedApplication<Application>&, PropagatedEvents) constructor. In that case, the first BasicScreen::focusEvent() is not called, assuming the screen is put into desired state already during construction.

template<class Application>
BasicScreenedApplication<Application>& Magnum::Platform::BasicScreenedApplication<Application>::removeScreen(BasicScreen<Application>& screen)

Remove screen from application.

Returns Reference to self (for method chaining)

The screen is blurred before removing. Deleting the object is left up to the user.

template<class Application>
BasicScreenedApplication<Application>& Magnum::Platform::BasicScreenedApplication<Application>::focusScreen(BasicScreen<Application>& screen)

Focus screen.

Returns Reference to self (for method chaining)

Moves the screen to front. Previously focused screen is blurred and this screen is focused.

template<class Application>
Containers::LinkedList<BasicScreen<Application>>& Magnum::Platform::BasicScreenedApplication<Application>::screens()

Application screens.

The screens are sorted front-to-back.

template<class Application>
const Containers::LinkedList<BasicScreen<Application>>& Magnum::Platform::BasicScreenedApplication<Application>::screens() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class Application>
void Magnum::Platform::BasicScreenedApplication<Application>::globalViewportEvent(typename Application::ViewportEvent& size) virtual private

Global viewport event.

Called when window size changes, before all screens' viewportEvent(). Default implementation does nothing. See *Application::viewportEvent() for more information.

template<class Application>
void Magnum::Platform::BasicScreenedApplication<Application>::globalBeforeDrawEvent() virtual private new in 2020.06

Before draw event.

Called before all screens' drawEvent(). Unlike globalDrawEvent() doesn't need to be implemented.

template<class Application>
void Magnum::Platform::BasicScreenedApplication<Application>::globalDrawEvent() pure virtual private

Draw event.

Called after all screens' drawEvent(). You should call at least swapBuffers(). If you want to draw immediately again, call also redraw(). See also globalBeforeDrawEvent().