tags:

views:

224

answers:

1

I grabbed firefox 3.7a (note go to about:config and enable webgl) and ran the examples on this site http://www.iquilezles.org/apps/shadertoy/

The examples were cool then it hit me. How is it running? Code is being ran is it not? Is this an implementation of LLVM? is something else going on? Would i be able to run my own examples and do something like a command line text based game?

+3  A: 

The shader examples on that site are written in a C-like language called GLSL, which is the (Open/Web)GL Shader Language. When they're executed, the JavaScript WebGL code sends the shader source off to your graphics driver's OpenGL functions, which compile it down to a machine code that runs directly on your GPU.

BTW, the shader-only style of coding, while very popular and a great way of writing cool demos, is not an entirely typical use of WebGL. Normally the shaders are used to do a lot of the heavy-duty number crunching, but the design and animation of the various objects that make up your scene is done in JavaScript. (In OpenGL, you would see a similar split between GLSL and some other language, such as C or C++.)

If you want to learn more about coding WebGL, you could do worse than visit the tutorials on my site, learningwebgl.com. I frequently link to other people's demos and tutorials too, so if you don't like my examples you should easily be able to find something better :-)

Giles Thomas