OpenGL Software Rendering Mode

Have you ever found yourself in a situation where you had to run some OpenGL 2.x code but your hardware was OpenGL 1.5 or smaller? This was a situation I faced recently. But with a quick Google search, the problem was solved... almost...

I am always on the move, so I mostly program on my laptop running Ubuntu. The problem I faced was that my laptop has an OpenGL 1.4 chipset but I need to run some OpenGL 2.x code. You can force an application to execute is OpenGL software rendering mode.

To do this you either set an environment variable that will apply to your entire system, or the better solution, apply the environment variable to a specific terminal session. With a terminal session open simply type in:

export LIBGL_ALWAYS_SOFTWARE=1

Any application started from that terminal will execute in software rendering mode. Currently the MESA drivers that ship with Ubuntu will render most of the OpenGL 2.1 spec.

The only caveat is that you can't easily create a bash script to set this environment variable and add it to your path. You can create the bash script, but you will quickly notice that it won't work. The reason for this is that when you invoke your custom bash script to set the environment variable for your terminal session, the bash script starts a new process and executes there. It then closes and returns. So the environment variable was set in that temporary process and closed after execution.

As of yet, I still haven't figured out a way to execute a bash script in the current terminal session.