-
Notifications
You must be signed in to change notification settings - Fork 13
Initialization Release
- Include the Library
- Entry Point
- Initialization with default settings
- Initialization with custom settings
- Releasing the Platform
- Result/Error checking
- Tips
In one of your C/C++ translation units include this:
#define FPL_IMPLEMENTATION
#include "final_platform_layer.h"You can then include this file in any other C/C++ source or header file as you would with any other header file.
Simply provide the typical main entry point:
int main(int argc, char **argv) {
// code goes here
}Call fplPlatformInit() (inside the main Entry Point) and provide the desired fplInitFlags and fpl_null as arguments, to initialize FPL with default settings.
int main(int argc, char **argv) {
// With defaults (Window, Video, Audio)
(, );
// Only audio
(, );
// Only window and audio
( | , );
return 0;
}It is recommended to always pass a pointer to a fplSettings structure, but you can leave it as fpl_null as well.
Call fplSetDefaultSettings() with a pointer to your local settings container to initialize the settings container with default values.
Call fplPlatformInit() (inside the main Entry Point) and provide the desired fplInitFlags and a pointer to fplSettings argument to initialize FPL with custom settings.
// Overwrite settings
settings;
(&settings);
// or
settings = ();
// change the settings here
(, &settings);Call fplPlatformRelease() when you are done. This will release all internal resources.
();There is no guarantee that fplPlatformInit() will always work with the fplSettings you specified, maybe the audio device does not support a sample rate of 1337 kHz or your video card does not support OpenGL version 3.7 - who knows.
Therefore, you should always check the result using fplGetPlatformResult() !
This returns a fplPlatformResultType enum which is fplPlatformResultType_Success when initialization succeeded.
Also, you should release the platform only when initialization was successful!
If something goes wrong the remaining resources are already cleaned up by FPL automatically.
Also, you should use fplGetLastError() to print out the actual error when the initialization fails!
Very bad: (But will work)
(, );
// your code here
();Bad: (But will work)
if ((, )) {
// your code here
}
();Good:
if ((, )) {
// your code here
();
}Better:
if ((, )) {
// your code here
();
} else {
const char *errStr = ();
("FPL-ERROR: %s\n", errStr);
}Much better:
if ((, )) {
// your code here
();
} else {
initResult = ();
const char *initResultStr = (initResult);
const char *errStr = ();
("FPL-ERROR[%s]: %s\n", initResultStr, errStr);
}See the Error handling page for more details about error handling.
After releasing FPL you can call fplPlatformInit() again if needed - for example: Finding the proper audio device, Testing for OpenGL compatibility, etc. may require you to call fplPlatformInit() and fplPlatformRelease() multiple times.
For more details see Getting started
Optionally you can use fplMakeDefaultSettings to create a default filled fplSettings structure, which can be directly used for fplPlatformInit()
If needed you can get the currently used fplSettings configuration by calling fplGetCurrentSettings()
- Assertion & Debug
- Atomic operations
- Audio functions
- Clipboard functions
- Console functions
- Constants
- Display/Monitor functions
- Dynamic library loading
- Error Handling
- Files/IO functions
- Function macros
- Hardware Infos
- Input types and functions
- Localization functions
- Logging
- Memory Macros
- Memory functions
- Operating system Infos
- Path functions
- Platform functions
- Session Infos
- Settings & Configurations
- Storage class identifiers
- String functions
- Threading and synchronizations routines
- Timing functions
- Video functions
- Window events
- Window functions
- fplARMCPUCapabilities
- fplAudioChannelMap
- fplAudioDeviceID
- fplAudioDeviceInfo
- fplAudioFormat
- fplAudioSettings
- fplColor32
- fplConditionVariable
- fplConsoleSettings
- fplCPUCapabilities
- fplCPUIDLeaf
- fplDateTime
- fplDateTimeCreationResult
- fplDateTimeResult
- fplDisplayInfo
- fplDisplayMode
- fplDynamicLibraryHandle
- fplEndianess
- fplEvent
- fplFileEntry
- fplFileHandle
- fplFilePermissions
- fplFileTimeStamps
- fplGamepadButton
- fplGamepadData
- fplGamepadEvent
- fplGamepadInfo
- fplGamepadInputBinding
- fplGamepadMapping
- fplGamepadSettings
- fplGamepadState
- fplGamepadStates
- fplGraphicsApiSettings
- fplImageSource
- fplInputBackendMask
- fplInputBackendSupport
- fplInputDevice
- fplInputDeviceGuid
- fplInputSettings
- fplInternalConditionVariable
- fplInternalDynamicLibraryHandle
- fplInternalFileEntryHandle
- fplInternalFileHandle
- fplInternalFileRootInfo
- fplInternalMutexHandle
- fplInternalSemaphoreHandle
- fplInternalSignalHandle
- fplInternalThreadHandle
- fplKeyboardEvent
- fplKeyboardState
- fplLogSettings
- fplLogWriter
- fplLogWriterConsole
- fplLogWriterCustom
- fplMemoryAllocationSettings
- fplMemoryBlock
- fplMemoryInfos
- fplMemorySettings
- fplMouseEvent
- fplMouseState
- fplMutexHandle
- fplOpenGLSettings
- fplOSVersionInfos
- fplSemaphoreHandle
- fplSettings
- fplSignalHandle
- fplSpecificAudioSettings
- fplThreadHandle
- fplThreadParameters
- fplTimestamp
- fplVersionInfo
- fplVideoBackBuffer
- fplVideoRect
- fplVideoRequirements
- fplVideoRequirementsVulkan
- fplVideoSettings
- fplVideoSurface
- fplVideoSurfaceOpenGL
- fplVideoSurfaceVulkan
- fplVideoWindow
- fplVulkanSettings
- fplWindowCallbacks
- fplWindowDropFiles
- fplWindowEvent
- fplWindowPosition
- fplWindowSettings
- fplWindowSize
- fplX86CPUCapabilities