Final Platform Layer 0.9.8-beta
Loading...
Searching...
No Matches
Initialization & Overview

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

// ... your code here
}
fpl_common_api bool fplPlatformInit(const fplInitFlags initFlags, const fplSettings *initSettings)
Initializes the platform layer.
@ fplInitFlags_Video
Use a video backbuffer (This flag ensures that fplInitFlags_Window is included always)

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.

fplSettings settings;
fplVideoSettings &videoSettings = settings.video;
// Forcing the video backend to be OpenGL
// ... your code here
}
fpl_common_api void fplSetDefaultSettings(fplSettings *settings)
Resets the given settings container to default values for window, video, audio, etc.
@ fplVideoBackendType_OpenGL
OpenGL.
A structure containing settings, such as window, video, etc.
fplVideoSettings video
Video settings.
A structure that contains video settings such as backend, v-sync, API-settings, etc.
fplVideoBackendType backend
video backend type

Enable/Disable Vertical Synchronisation

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 synchronisation!

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
Final Platform Layer (FPL) - A C99 Single-Header-File Platform Abstraction Library.

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
Note
Keep in mind that this is not useful for window-based applications!
If you writing a console application and don't want any video output whatsoever you set the 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.