Skip to content

Initialization Overview

Finalspace edited this page May 29, 2026 · 2 revisions

Table of Contents

Initialize a video context

To initialize either software or hardware video output, you have to set the fplInitFlags_Video flag in the fplPlatformInit() call and ensure that video is not disabled by a preprocessor directive FPL_NO_VIDEO.

Also setting the fplInitFlags_Video flag ensures that the fplInitFlags_Window flag is appended automatically.

Default video output

If you don't specify any settings then the video backend is automatically detected, depending on your operating system and supported hardware and software.

By default, this is most likely legacy OpenGL - which is supported on almost every video card on any OS.

But this is not the recommended way to initialize video output, because you are responsible for handling any video output yourself.

if (()) {
    // ... your code here
}

Setting the video backend

It is recommended to set at least the video backend manually, to ensure that you get either initialized with that backend properly or an error when your configuration is not supported.

You do that by simply setting the fplVideoBackendType field in your fplVideoSettings structure which is included in the fplSettings structure to the fplPlatformInit() call.

 settings;
(&settings);
 &videoSettings = settings.;

// Forcing the video backend to be OpenGL
videoSettings. = ;

if ((, &settings)) {
    // ... your code here
}

Enable/Disable Vertical Synchronization

If you want to enable/disable vertical synchronization you simply set the fplVideoSettings.isVSync field respectively.

Note: There is no guarantee that vertical synchronization is supported by your video device or selected backend.

Software video output does not support vertical synchronization!

Disable unneeded video backends

To compile out certain video backends, you simply specify the FPL_NO_VIDEO_[Name of the video backend] preprocessor directive.

But the fplVideoBackendType in question is never removed from the enumeration - keep that in mind!

Example (Disable OpenGL video backend):

#define FPL_NO_VIDEO_OPENGL
#define FPL_IMPLEMENTATION
#include <final_platform_layer.h>

Disable all Video Output

To compile out all video output code you define the FPL_NO_VIDEO preprocessor directive.

#define FPL_NO_VIDEO
#define FPL_IMPLEMENTATION
#include <final_platform_layer.h>

Note: Keep in mind that this is not useful for window-based applications!

If you are writing a console application and don't want any video output whatsoever, set

FPL_NO_WINDOW which automatically disables any video devices as well.

Notes

Backend types stored in the fplVideoBackendType enumeration are not filtered away, even when you disable it by a preprocessor directive!

Keep that in mind when you initialize the video backend.

If needed you can use fplSetDefaultVideoSettings() to fill in just the default video settings inside the fplVideoSettings structure.

Final Platform Layer

Pages

Topics

Data Structures

Clone this wiki locally