Final Platform Layer 0.9.8-beta
Loading...
Searching...
No Matches
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
}
fpl_common_api bool fplPlatformInit(const fplInitFlags initFlags, const fplSettings *initSettings)
Initializes the platform layer.
fpl_common_api void fplSetDefaultSettings(fplSettings *settings)
Resets the given settings container to default values for window, video, audio, etc.
@ fplInitFlags_Video
Use a video backbuffer (This flag ensures that fplInitFlags_Window is included always)
@ fplOpenGLCompabilityFlags_Core
Use core profile.
@ fplVideoBackendType_OpenGL
OpenGL.
fplOpenGLSettings opengl
OpenGL settings.
uint32_t minorVersion
Desired minor version.
fplOpenGLCompabilityFlags compabilityFlags
Compability flags.
uint32_t majorVersion
Desired major version.
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
fplGraphicsApiSettings graphics
Graphics API settings.

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.