I spent some time testing out the various "head tracking" demos written with OpenGL and none were complete. Many lacked wiimote support, and others simply didn't get the perspective transformation right. A few weekends ago I picked up a wiimote and wrote this program over the course of a few days. Many thanks to Johnny Lee for making the original version for Windows! His project was obviously my inspiration for this

.
Note that although the code works fine on my machine, you'll need to compile it once you set up your screen and IR bar settings. I suggest familiarizing yourself with the code before you compile and run it. Make sure you have the cwiid library and MesaGL/GLUT.
I admit that it's quite unpolished at the moment, but I see a LOT of questions about how to do this in OpenGL so I wanted to release the code so others don't have to bang their head on walls anymore trying to understand this. I will be improving the documentation over the next few weeks, as well as writing a tutorial on how the perspective transform works, including pretty diagrams for all of those who can't learn without

.
I posted my code here:
http://stsnyder.bol.ucla.edu/Click on "Wiimote Projects"
It's written in C and uses the cwiid library for wiimote access.
It does not currently support textures or any other goodies like that. The targets are draw as two quads each. I drew a grid with lines for reference. I will clean up the appearance in the next few versions.
In the next version I will have a better interface for setting it up for your screen and IR light bar. I have have a bunch of other projects going on right now, so I'm sorry I can't work on this at the rapid pace I did when I just wanted to get it working.
Yes, the perspective correction works PROPERLY. I've seen a lot of demos that just move the camera around, without doing the proper transformation.
Thanks,
Steven Snyder