Skip to content

Window basics

Finalspace edited this page May 29, 2026 · 2 revisions

Table of Contents

Initialization

To create a window, you add the fplInitFlags_Window flag to the fplInitFlags argument in the fplPlatformInit() call. It makes no sense to create a window alone, so we combine it at least with something else, like for example a video context or audio playback.

( | , );

Main loop

After you initialize FPL with a window, you have to create some sort of a loop to keep the window open until you close it. This is required because the operating systems use an event-based system to communicate with the window and your application. If no communication happens with your window and your app, the window will no longer be responsive - so make sure to communicate properly. To solve this, you have to use fplWindowUpdate() and fplPollEvent() respectively. First, you need to call fplWindowUpdate() for every 'tick' for your application. This will clear the internal event queue and update input devices properly. After that, you have to poll all events from the operating systems event queue using fplPollEvent() .

while (()) {
     ev;
    while ((&ev)) {
        // ... Handle event here
    }
}

See Window events for more details.

Attention: All window-based calls are required to be executed from the main-thread only!

Shutdown the window

Simply call fplWindowShutdown to shut down the window while it is still running. You can also query the running state of the window by calling fplIsWindowRunning() .

Note: The window is not immediately shut-down, one tick of window/input events may still be executed after that.

To forcefully terminate the window, use

fplPlatformRelease() instead.

Final Platform Layer

Pages

Topics

Data Structures

Clone this wiki locally