TurtleBrains now with Linux Support

turtlebrains_on_linux

Upon starting TurtleBrains it was planned to support many major platforms. Not so recently Linux support was added, actually TurtleBrains had been compiling on Linux, and even running with #define tb_legacy_gl_forced in tbi_renderer.h (or compilation settings). This of course is not very user friendly, and it seemed to have a few issues with text so a game was never actually released, nor support claimed.

The issue for several months (probably close to 9 of them) was an inability to create the the OpenGL 3.2 Core context. After combing through the code for two days, and comparing against several tutorials and having help from the #LudumDare irc channel, the issue finally emerged.

int contextAttributes[] = {
	GLX_CONTEXT_PROFILE_MASK_ARB, contextProfileBit,
	GLX_CONTEXT_MAJOR_VERSION_ARB, glVersion.mMajor,
	GLX_CONTEXT_MINOR_VERSION_ARB, glVersion.mMinor,
	GLX_NONE //Incorrect. This should be: None, or 0
};

Not being super familiar with the platform/GLX I had unknowingly used GLX_NONE to represent the end of the contextAttributes array that would be passed to create the 3.2 Core context. The value of GLX_NONE is NOT zero.

I repeat; NOT ZERO

This actually caused a really weird crash that, with CodeLite IDE debugger, (aka GDB), appeared to be an issue calling the glXCreateContextAttribsARB function, and I got hung up thinking the function pointer was invalid. The actual error was attempting to access memory out of bounds since GLX_NONE was not signifying the end of the attributes array.

After fixing this issue I was able to make an experimental Linux build of my LD36 game, Ancient Robots.

Comments are closed.