Electoral College Screensaver 1.0

Written by on October 10, 2008, 12:00 am

This ScreenSaver accesses the Internet to download a compilation of polling data for Democratic and Republican candidates in US Presidential Elections. Polling percentages for each candidate are used to determine a winning candidate and the states are coloured accordingly. A indicator bar at the bottom of the screen shows the Electoral College totals for each candidate. Electoral Votes "won" with more than a 4% up or down margin of error are displayed in a darker colour than those within the margin of error.

This screensaver is developed in C++ and uses the Ogre SDK to perform the onscreen rendering.

There were a handful of technical hurdles that required more interesting solutions:

  • The Electoral Vote data is not accessed directly by the screensaver (and be subject to changing data formats). Instead I use a python script to scrape the data daily and update to an XML file hosted on my domain.
  • I was not able to find detailed geographic data for the United States online, so I wrote a python drawing utility to cut textures out of a larger bitmap. I used a Google maps image to slice out each state texture.
  • I wanted to avoid the UI blocking on startup, so I implemented the WinHTTP requests in a seperate thread.
  • The OGRE SDK is a rich C++ interface and designed with the assumption that client code will use implicit linking. The is fine for most applications where the OgreMain DLL is in the run directory for the application. Because the screensaver has to run in the system32 directory, I had the onerous choice of writing a complicated thunking layer for the rich set of classes in OgreMain or add my install directory to the path. With a few weeks to go till the election, I chose the latter.

Permalink - Tags: Electoral College,Development