WebGL is really a fascinating topic to me. Being able to utilize the power of a local machine’s GPU via the web browser is a very novel concept.

If one was to ask back in 1996 would you be able to render Open GL code in a web browser via  GPU, even the most tech savvy may have replied, “Open GL? GPU? what are those things, you speak about?”

WebGL Hello World

In the posting below I will show the equivalent of writing a Hello World example that is used to teach many other programming languages.  The code is written in JavaScript and should run on newer browsers.

The code will draw 1 triangle and fill the triangle with gradients.  The JavaScript may not be the worlds most exciting but neither are the Hello World examples.  However it will lay the foundation for showing what is possible and future postings will show some more details.

Link to a working example.  gradient triangle

There is  a lot more lines of code than a typical Hello World program; but no one ever said drawing a gradient triangle would be easy.

Code for Gradient Triangle