Final Platform Layer  0.9.6-beta
Modern OpenGL

Initialize a modern OpenGL Rendering Context

To initialize a modern OpenGL (3.0+) rendering context, you simply set the fplInitFlags_Video flag in the fplPlatformInit() call and change the video backend type to fplVideoBackendType_OpenGL and setup the following parameters:

fplSettings settings;
fplVideoSettings &videoSettings = settings.video;
// Forcing the video backend to be modern OpenGL with Core profile and for GL version 3.3
videoSettings.graphics.opengl.majorVersion = 3;
videoSettings.graphics.opengl.minorVersion = 3;
// ... modern context is ready
}

Usage

Extensions loader

To use modern OpenGL, you need some sort of a OpenGL extension loader which gives you access to the constants and functions like glCreateProgram().
You can either use a third-party C/C++ Library for doing that for you or use/write your own OpenGL loader. FPL should work in both ways.

List of tested OpenGL loaders:

Presenting your frame

Call fplVideoFlip() to present the frame to the screen.
Its recommend to call this after each draw call of your frame at the end of the main-loop.

Multisample anti-aliasing (MSAA)

In a modern OpenGL context, you can activate multi-sampling-antialiasing (MSAA) to get smooth edges with few performance costs out-of-the-box.
By default, multisampling is disabled. To enable it, you simply set your desired multi-sampling count in fplOpenGLSettings::multiSamplingCount .

fplSettings settings;
fplVideoSettings &videoSettings = settings.video;
// Forcing the video backend to be modern OpenGL with Core profile and for GL version 3.3
videoSettings.graphics.opengl.majorVersion = 3;
videoSettings.graphics.opengl.minorVersion = 3;
// Use 4x MSAA
videoSettings.opengl.multiSamplingCount = 4;
// ... modern context is ready
}

Notes

FPL does not provide any OpenGL types, prototypes, or functions - it's fully up to the caller how to handle this.
Keep in mind that FPL does not work with platform abstraction libraries like GLFW or GLUT, but GLEW for example will work just fine.

fplOpenGLSettings::compabilityFlags
fplOpenGLCompabilityFlags compabilityFlags
Compability flags.
Definition: final_platform_layer.h:3478
fplSettings
A structure containing settings, such as window, video, etc.
Definition: final_platform_layer.h:3930
fplVideoBackendType_OpenGL
OpenGL.
Definition: final_platform_layer.h:3452
fplVideoSettings::backend
fplVideoBackendType backend
video backend type
Definition: final_platform_layer.h:3565
fplPlatformInit
fpl_common_api bool fplPlatformInit(const fplInitFlags initFlags, const fplSettings *initSettings)
Initializes the platform layer.
fplVideoSettings::graphics
fplGraphicsApiSettings graphics
Graphics API settings.
Definition: final_platform_layer.h:3563
fplOpenGLSettings::majorVersion
uint32_t majorVersion
Desired major version.
Definition: final_platform_layer.h:3480
fplSettings::video
fplVideoSettings video
Video settings.
Definition: final_platform_layer.h:3934
fplInitFlags_Video
Use a video backbuffer (This flag ensures that fplInitFlags_Window is included always)
Definition: final_platform_layer.h:3384
fplOpenGLCompabilityFlags_Core
Use core profile.
Definition: final_platform_layer.h:3468
fplVideoSettings
A structure that contains video settings such as backend, v-sync, API-settings, etc.
Definition: final_platform_layer.h:3561
fplOpenGLSettings::minorVersion
uint32_t minorVersion
Desired minor version.
Definition: final_platform_layer.h:3482
fplGraphicsApiSettings::opengl
fplOpenGLSettings opengl
OpenGL settings.
Definition: final_platform_layer.h:3550
fplSetDefaultSettings
fpl_common_api void fplSetDefaultSettings(fplSettings *settings)
Resets the given settings container to default values for window, video, audio, etc.