The Electric Giraffe Project
21st September, 2012 by

There are a couple of things that have been bothering me about the software.  First is the lack of multi-threading: the UI and the pattern generation are done in the same thread, meaning that if the pattern generation runs slowly (for example because of heavy processing doing beat detection or video processing), the UI might become sluggish.  The second is the rendering of the UI being done in Windows GDI.  I really pushed the GDI beyond what it was designed to do.

Even though neither of these things are a problem (the CPU is plenty powerful enough, and the UI functions perfectly) I still wanted to make the changes because, well, I'm a bit of a perfectionist.

I decided that it was finally time to bite the bullet.  I have split the frame generation off into its own thread so it can now be run on a separate core to the UI, keeping the UI nice and responsive.  The difficulty here was ensuring everything is synchronised and thread-safe, but a sprinkling of critical sections here and there have got it covered.

Replacing the rendering engine is a much harder prospect.  At the moment everything is written using Windows controls (they're owner drawn so that they have their own visual style, but they're still standard components.)  I'm going to use OpenGL for the rendering, and scrap all the Windows controls.  This means that I have to write from scratch all my own UI widgets like buttons, checkboxes, edit boxes, list views… the works.  It's a huge task.  I also have to do all my own message handling, creating the whole windowing framework, processing mouse and keyboard messages – everything.

I've been working on it for a few months now and it's starting to take shape.  I have implemented the basic OpenGL rendering engine, texture loading and drawing.  I've implemented a small number of the basic UI widgets: buttons, drop-down lists and scroll bars.  There is still a long long way to go, but I'm getting there.