From TheAlmightyGuru
Jump to: navigation, search

Mystique is a free screensaver I wrote to simulate the old "Dancing Lines" screensaver in IdleWild from 1990. To install it, download the screensaver, extract the zip, then right-click on Mystique.scr and click "Install" in the menu.


I wrote this program for a couple reasons. First, even though I don't employ them on my computer, I've always like watching screensavers, and this was always a favorite of mine. In Windows Vista, Microsoft replaced the "Mystify" screensaver with a different, and, in my opinion, less impressive, screensaver with the same name. And, since Windows doesn't allow you to install different screensavers with the same name, it effectively prevents all but the more technical users from switching back to the older one. The original, "Dancing Lines," won't even run on Windows 10, and, it required IdleWild anyway. So, by recreating it in a modern language and with a different name, you can once again use the old screensaver. The second reason I wrote it was because I thought it would be fun to re-implement it. Although, this ended up being quite a chore.

I wrote three different versions of Mystique. The first was written in FreeBASIC. It can be installed as screensaver, but, because FreeBASIC doesn't easily integrate with the UI of Windows, it doesn't support the preview or settings buttons. Instead, settings can be changed with the keyboard while the screensaver is running. Press '?' to see them.

Wanting to have access to the preview and settings buttons in the Windows screensaver dialog, I found a site on the web which included some source code for doing so. Then, I rewrote the screensaver in C# using GDI. This allowed me to add line thickness as a setting and easily support multiple monitors. This version runs in the preview window and has a settings form and saves the settings into an XML file. However, The more I played around with GDI, the less impressed I was with it. You just can't do smooth animation with GDI.

That's when I started making a third version that would work with hardware acceleration. I chose MonoGame as it was originally developed by Microsoft, but quickly ran into a problem when I discovered that MonoGame doesn't natively support any drawing primitives, not even a simple line! I found tutorials online how how to stretch a texture into a line, which I felt was asinine, and, having had difficulties getting MonoGame to do what I wanted in the past, I gave up. A year later, I decided to try again, and just bit the bullet and coded in the silly way necessary to work with MonoGame. After a lot of headache, I finally got it working. I added the ability to display polygons like the later version of Mystify, but I had to remove line thickness because the unusual way I had to draw lines in MonoGame doesn't handle corners very well. However, by accessing hardware, I was able to add anti-aliasing and alpha-blending, so the lines and trails can be made to look much nicer than the original if you want that. Using MonoGame also means the program bloats from 1 KB to 24 MB and now requires a couple dozen files.