Final Platform Layer 1.0.0
Loading...
Searching...
No Matches
Settings & Configuration

FPL is configured through a single fplSettings structure, which is passed to fplPlatformInit() .
It groups all configuration into one container with a sub-structure for each subsystem:

Field Type Configures
window fplWindowSettings Window title, size, position, style, callbacks
video fplVideoSettings Video backend (OpenGL, Vulkan, Software), vsync
audio fplAudioSettings Audio backend, format, device, buffer sizes
input fplInputSettings Input backends, gamepad detection frequency
console fplConsoleSettings Console subsystem configuration
memory fplMemorySettings Custom memory allocator configuration

Creating default settings

You should never use an uninitialized fplSettings structure. FPL provides two ways to obtain a fully populated default configuration.

Use fplMakeDefaultSettings() to get a settings structure by value:

fpl_common_api fplSettings fplMakeDefaultSettings(void)
Creates a full settings structure containing default values.
Stores settings, such as window, video, etc.

Or use fplSetDefaultSettings() to reset an existing structure in place:

fplSettings settings;
fpl_common_api void fplSetDefaultSettings(fplSettings *settings)
Resets the given settings container to default values for window, video, audio, etc.
Note
Neither function changes the active settings - they only fill the structure. The settings only take effect when passed to fplPlatformInit() .

Modifying settings

After creating the defaults, change only the fields you care about, then pass the structure into fplPlatformInit() .

fplCopyString("My Game", settings.window.title, fplArrayCount(settings.window.title));
settings.window.windowSize.width = 1280;
settings.window.windowSize.height = 720;
// ...
}
#define fplArrayCount(arr)
Returns the element count from a static array.
fpl_common_api bool fplPlatformInit(const fplInitFlags initFlags, const fplSettings *initSettings)
Initializes the platform layer.
fpl_common_api void fplPlatformRelease(void)
Releases the resources allocated by the platform layer.
@ fplInitFlags_All
All init flags.
fpl_common_api size_t fplCopyString(const char *source, char *dest, const size_t maxDestLen)
Copies the given source string into a destination string.
fplWindowSettings window
Window settings.
fplWindowSize windowSize
Window size in screen coordinates.
char title[FPL_MAX_NAME_LENGTH]
Window title.
uint32_t width
Width in screen coordinates.
uint32_t height
Height in screen coordinates.

See Initialization with custom settings for the full initialization workflow.

Per-subsystem default helpers

If you only want to reset a single subsystem, FPL provides dedicated helper functions:

Function Resets
fplSetDefaultWindowSettings() fplWindowSettings
fplSetDefaultVideoSettings() fplVideoSettings
fplSetDefaultAudioSettings() fplAudioSettings
fplSetDefaultInputSettings() fplInputSettings
fplSetDefaultConsoleSettings() fplConsoleSettings
fplVideoSettings videoSettings;
fpl_common_api void fplSetDefaultVideoSettings(fplVideoSettings *video)
Resets the given video settings to default values.
Stores video settings such as backend, v-sync, API-settings, etc.

Querying the active settings

Once the platform is initialized, you can retrieve the currently active configuration by calling fplGetCurrentSettings() .
It returns a read-only pointer to the fplSettings used by FPL.

fplConsoleFormatOut("Window size: %dx%d\n",
fpl_common_api void fplConsoleFormatOut(const char *format,...)
Writes the given formatted text to the standard output console buffer.
fpl_common_api const fplSettings * fplGetCurrentSettings(void)
Gets the current settings.
Note
Modifying the returned structure has no effect on the running platform. Settings are applied at fplPlatformInit() time only.