GLSL Sandbox on the Raspberry Pi

Posted on May 13, 2012


I hope many of you have seen the excellent and fun WebGL GLSL sandbox at This live editing of shaders is an excellent learning tool, as it allows you to watch the consequences of any changes you make.

I am constructing some simple OpenGL ES scripts as a learning resource for anyone new to it, in part as a way to help me learn it too. As part of this, I’ve written a little script that gives a similar kind of experience, but on the commandline, with a Raspberry Pi. It overlays the render display over the top of the framebuffer window, and reloads the shader any time you save the script.

You can run this from the terminal (as I do in the video later on) or from within LXDE (X11). (You may wish to replace ‘nano’ with ‘leafpad’ in if you are running it in LXDE)


* Install pyinotify

$ sudo apt-get install python-pyinotify

* Get the repository:

$ wget -O
$ unzip
  Inflating benosteen-pyopen....

cd into the repository and you are ready to go!

Usage of ‘’:


The repository has a few demo shaders that are known to work included for you to try – they are copied from the WebGL sandbox site (

‘basic.glsl’ – From

‘leds.glsl’ – From

‘raymarch.glsl’ – From

Pass the script any new filename, and it will create a new shader from the template and save it to that location.

This uses the “nano” text editor by default, as that is installed on the reference debian image, but if you look in the script, it is not hard to change to your preference 🙂

(NB Ctrl-O, followed by enter to save the file, and Ctrl-X to quit nano.)

Here is a video of it in action, as it is quite hard to describe in words.

Posted in: creativity, linux, python