Skip to content

Platform Layer

Alex Link edited this page Jan 9, 2024 · 1 revision

With motor, I decided to move all system/platform specific code into a single layer. The platform layer.

Graphics

OGL, GLX and GCC issues

After moving all the window specific OpenGL code like wgl, glx or egl to the platform layer, I was confronted with failure.

Because in all motors' OpenGL code only corearb.h is used, it is incompatible with glx.h. glx.h includes gl.h which interferes with the corearb.h code. So the solution was to use the pimpl idiom and to only included those header files in the .cpp files. So it was possible to separate the includes and to be able to compile the code. The ticket #28 was dedicated to this issue.

The second problem #29 seemed to be that gcc changed its default behavior where global variables like the gl functions will cause the multiple definitions linker error. Here the first fix is to use the -fcommon compiler flag and secondly use the extern keyword on the gl functions.

A third problem was that during run-time loading of the gl functions, a segmentation fault was triggered. I believe this has to do with the functions defined in gl.h or whatever Linux or Mesa OpenGL is doing there. The solution to that was to put all the gl functions to be loaded in the engines' own namespace and load to those functions. This error only occurred with Linux OpenGL using Mesa OpenGL and GLX.

Clone this wiki locally