Modern OpenGL with Perl

For a long time, I've wanted to actually make use of the modern hardware I have at home. The graphics card is capable of OpenGL and OpenGL now has a fancy little language to actually bring images to life. For example [https://www.shadertoy.com] has great so-called "shaders" that show off what can be done with them.

Because I also want to toy around with programming some shaders, I want to get a live environment running. So during the weekend, I took the Glew library, wrote a small Perl script to convert the header files to XS, and then fought with OpenGL until I had a driver that could run shaders from Shadertoy.com:

shadertoy-01-seascape-still.png

The app runs on Prima, but until I've worked out how to best integrate everything into mainline Prima::OpenGL on Windows, you will need to fetch a patched version of Prima::OpenGL from my Github repository.

The gif below doesn't really do it justice, but on my machine, Perl obviously is able to run the shader at 60fps. As Perl only has to do 14 OpenGL calls per frame, there certainly is room for more interesting things soon.

shadertoy-01-seascape-still.png

This wouldn't have been possible without the work of Mithaldu and Chris Marshall, who provided encouragement and hopefully will pick up my work and integrate it into OpenGL mainline proper.

Also, the original author of the "Seascape" shadertoy, Alexander Alekseev aka TDM, needs to be mentioned, because what good is a nice engine if you don't have assets to display in it.

The source code including my OpenGL::Glew temporary experimental XS module lives on Github, and it is "Works on My Machine" certified. I haven't tried the changes with an Intel integrated graphics card and certainly not on other operating systems.

1 Comment

Ooooh, it's interactive!

Can you have it draw the received mouse position to see what the input latency is like?

Leave a comment

About Max Maischein

user-pic I'm the Treasurer for the Frankfurt Perlmongers e.V. . I have organized Perl events including 9 German Perl Workshops and one YAPC::Europe.