We are currently in the process of converting the website to the new design. Some pages, like this one, are still broken. We appreciate your patience.
Final Platform Layer»Forums
64 posts
None
compiling a the minimal example of FPL on linux
Edited by albatros on Reason: Initial post
Hello there, I'm trying out FPL on linux.

My main.c contains the basic example for window + opengl from the FPL file :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#define FPL_IMPLEMENTATION
#include "final_platform_layer.h"

int main(int argc, char **args){
        fplSettings settings;
        fplSetDefaultSettings(&settings);
        fplVideoSettings videoSettings = settings.video;

        videoSettings.driver = fplVideoDriverType_OpenGL;

        // Legacy OpenGL                                                                                                                                                                       
        // videoSettings.opengl.compabilityFlags = fplOpenGLCompabilityFlags_Legacy;

        // or                                                                                                                                                                                  

        // Modern OpenGL                                                                                                                                                                       
        videoSettings.opengl.compabilityFlags = fplOpenGLCompabilityFlags_Core;
        videoSettings.opengl.majorVersion = 3;
        videoSettings.opengl.minorVersion = 3;

        if (fplPlatformInit(fplInitFlags_Video, &settings)) {
                // Event/Main loop                                                                                                                                                             
                while (fplWindowUpdate()) {
                        // Handle actual window events                                                                                                                                         
                        fplEvent ev;
                        while (fplPollEvent(ev)) {
                                /// ...                                                                                                                                                        
                        }

                        // your code goes here                                                                                                                                                 

                        fplVideoFlip();
                }
                fplPlatformRelease();
                return 0;
        } else {
                return -1;
        }
}


This is the command I use to compile :
1
gcc main.c -ldl && ./a.out 


Theses are the errors I get.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
main.c: In function ‘main’:
main.c:17:15: error: ‘fplVideoSettings {aka struct fplVideoSettings}’ has no member named ‘opengl’
  videoSettings.opengl.compabilityFlags = fplOpenGLCompabilityFlags_Core;
               ^
main.c:18:15: error: ‘fplVideoSettings {aka struct fplVideoSettings}’ has no member named ‘opengl’
  videoSettings.opengl.majorVersion = 3;
               ^
main.c:19:15: error: ‘fplVideoSettings {aka struct fplVideoSettings}’ has no member named ‘opengl’
  videoSettings.opengl.minorVersion = 3;
               ^
main.c:26:24: error: incompatible type for argument 1 of ‘fplPollEvent’
    while (fplPollEvent(ev)) {
                        ^
In file included from main.c:2:0:
final_platform_layer.h:7187:21: note: expected ‘fplEvent * {aka struct fplEvent *}’ but argument is of type ‘fplEvent {aka struct fplEvent}’
 fpl_common_api bool fplPollEvent(fplEvent *ev) {


I've got to admit, I have no clue on how to get past this. Any idea ?
513 posts
compiling a the minimal example of FPL on linux
final_platform_layer.h:7187:21: note: expected ‘fplEvent * {aka struct fplEvent *}’ but argument is of type ‘fplEvent {aka struct fplEvent}’
fpl_common_api bool fplPollEvent(fplEvent *ev) {

means that the function wants a pointer but you passed a struct: fix by doing fplPollEvent(&ev) instead

fplVideoSettings doesn't have a member opengl, it does have a member graphics that has a opengl member: fix by replacing videoSettings.opengl with videoSettings.graphics.opengl
64 posts
None
compiling a the minimal example of FPL on linux
Indeed, that worked ! :D
Many thanks !
152 posts / 1 project
I am finalspace and do programming since more than 25 years, started on C64 and got serious with borland delphi. Nowadays i use C/C++ only.
compiling a the minimal example of FPL on linux
I did a few api changes in the recent releases, so the documentation may be a little off.
The doxygen code sections will never get validated, so you never know if there is something wrong in the code snippets there :-(

So i will correct this in the next release.

But great that you got the problem solved ;)