Staying on top of bitmaps
While putting off working on my Perl Advent Calendar submission, I was instead active in resolving bugs in App::ShaderToy and adding some interesting features. The three major features I added this week are, in order of implementation, loading of bitmap images, hot reloading of code and the feature to make the window stay always on top.
It is incredible how much joy quicker iterations bring me while toying around with shaders, tweaking the parameters to see if I can find new visuals.
Adding the new features was a mixed bag. Prima proved very great again, as it already implements the "always on top" feature. Hot reloading of saved shader files was also quite easy thanks to Filesys::Notify::Simple, which is a cross-platform watcher for changed files. As that module is synchronous and I didn't want to fight with the integration into the Prima event loop, I used threads (and Threads::Queue) to communicate changes from the watcher to the main program.
The hardest part programming wise was getting bitmaps loaded into the graphics card. Here, I found that OpenGL 4.5 has really improved the API. I first got images loading correctly using the newest OpenGL 4.5 API calls, which mimic malloc
and memcpy
quite closely. After getting that to work and reading the list of Common Mistakes in OpenGL, I understood what I had been doing wrong all the time and also the API calls from OpenGL 2 to work. Sometimes, I need hard won experience to understand and appreciate a FAQ.
Talking about compatibility, while my goal with App::Shadertoy is to gain experience with GLSL and to exercise my GPU a bit, I also want to support OpenGL versions earlier than 4.5. My current aim is for OpenGL 3 support. Thanks to the intrepid testers and bug reporters Dmitry Karasik, Chris Marshall and Mithaldu, the application now works better and more stable. I still haven't figured out why some shaders don't compile on OpenGL 3 cards, but the program is not done by any means either.
Looking forward, I want to implement geometry generation next and some kind of support for configuration files so that the bitmap textures can be associated with each shader separately.
Leave a comment