Final Platform Layer 0.9.8-beta
Loading...
Searching...
No Matches
Window basics

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.

#define fpl_null
Null.
fpl_common_api bool fplPlatformInit(const fplInitFlags initFlags, const fplSettings *initSettings)
Initializes the platform layer.
@ fplInitFlags_Window
Create a single window.
@ fplInitFlags_Video
Use a video backbuffer (This flag ensures that fplInitFlags_Window is included always)

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 them.
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 (fplWindowUpdate()) {
while (fplPollEvent(&ev)) {
// ... Handle event here
}
}
fpl_platform_api bool fplWindowUpdate()
Clears the internal event queue and updates input devices if needed.
fpl_platform_api bool fplPollEvent(fplEvent *ev)
Polls the next event from the internal event queue or from the OS, handles them, and removes it from ...
A structure containing event data for all event types (Window, Keyboard, Mouse, etc....

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 shutdown 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.