GLSL Hacker on Raspberry Pi: First Tests

GLSL Hacker on Raspberry Pi


GLSL Hacker for Raspberry Pi is available HERE.


I spent these few last days playing with my Raspberry Pi board and porting GLSL Hacker to this tiny computer. That was my first contact with OpenGL ES and the way to get a hardware accelerated window under Raspbian, the Debian-based operating system optimized for the Pi.

The nice thing is that Raspbian has all the tools I need to build GLSL Hacker: text editor, gcc/g++, OpenGL ES headers and libs and code samples. I installed absolutely nothing. I directly updated GLSL Hacker source code and compiled it on the Raspberry Pi, it was a bit slow but usable (I will try with a faster SD card to see if that will reduce compilation times). I must say that I’m too lazy to tackle the configuration of a cross-compiler system, that’s why I compiled directly on the Raspberry Pi.

I tested few GLSL Hacker demos and updated the GLSL shaders to make them compliant with OpenGL ES 2.0. Here is an example of a simple OpenGL ES 2.0 vertex shader used in the demos I tested:

attribute vec4 gxl3d_Position;
attribute vec4 gxl3d_TexCoord0;
invariant gl_Position;
uniform mat4 gxl3d_ModelViewProjectionMatrix;
varying vec4 Vertex_UV;
void main()
{
  gl_Position = gxl3d_ModelViewProjectionMatrix * gxl3d_Position;		
  Vertex_UV = gxl3d_TexCoord0;
}

An OpenGL ES 2.0 vertex shader is based on the OpenGL 2.0 specification (attribute and varying keywords) but has no fixed function pipeline (no gl_Vertex for example).

Here are the demos (from the code sample pack) I updated and tested on the Raspberry Pi (these updated demos will be available with the release of GLSL Hacker for Pi):

– GLSL_ShaderToy/julia.xml (source)

GLSL Hacker on Raspberry Pi - Shadertoy Julia demo

– GLSL Sandbox/demo_3155_0_gl2.xml (from source)

GLSL Hacker on Raspberry Pi - GLSL Sandbox 3155.2 demo

– GLSL_Sandbox/demo_3331_5_gl2.xml (from source)

GLSL Hacker on Raspberry Pi - GLSL Sandbox 3331.5 demo

– GLSL_Textured_Quad_OpenGL_21_32/demo_gl2.xml

GLSL Hacker on Raspberry Pi - Simple textured quad demo




In many Shadertoy demos, there is a for() loop. For example, in the inversion machine demo, we find this loop in the pixel shader:

for (int i=0; i<60; i++) {
  p=from+totdist*dir;
  d=de(p);
  if (d3.) break;
  totdist+=d; 
  st+=max(0.,.04-d);
}

For the Raspberry Pi, 60 is a too high value, I had to decrease the max value to… 4 to get something on the screen. So many demos based on raymarching won’t work on the Raspberry Pi because of this limitation.

That being said, it’s cool to see some GLSL Hacker demos running on the Raspberry Pi. I will release a DEV version of GLSL Hacker for Raspberry Pi as soon as possible.

For information, here are some OpenGL ES data about the Raspberry Pi I logged during my tests:

EGL_VENDOR: Broadcom
EGL_VERSION: 1.4
EGL_CLIENT_APIS: OpenGL_ES OpenVG
GL_VENDOR: Broadcom
GL_RENDERER: VideoCore IV HW
GL_VERSION: OpenGL ES 2.0