Halftone Program – First Year Project

When I started this, I barely knew what a pointer was. After a day’s solid watching videos to teach myself C++ and a week reading a stodgy book on OpenGL, I felt ready to start… making the interface. I assumed the halftone implementation would be trivial so left it to 18 hours before the hand-in date. In retrospect, this was a bad idea.

It’s surprisingly hard to make a UI in OpenGL. I have a file 1000+ lines long filled with functions for drawing most of the useful ASCII characters. Yep, just to show text. I made this by writing out all these characters with 3ds Max’s text in a readable font and writing a Maxscript to take each one and export the triangle lists for it. To get anti-aliasing on the text (using OpenGL 1.2 I think), I drew the triangles making up the letter, then the outline of the letter with a smoothed line. I programmed it to understand spaces and carriage returns, and used it with buttons and messages. To display the available image files I taught myself to use the STL vector, so I could have enough buttons for unlimited image files in the folder. The time developing and debugging this would definitely have been better spent actually working on the algorithm! I assumed loading images would be trivial… It’s not. I hacked up a BU lecturer’s C module for loading PNG images into OpenGL, and unfortunately only got it working with square images!

Most of the GUI is just for loading files. Showing halftone variations is done using keyboard shortcuts, set up with the GLUT windowing system. I had to port the final application to work with Linux (GLUT only works in Windows I think) so taught myself the necessary parts of QT in about an hour. Of course, had I gone with QT to start with, I wouldn’t have had to make my own UI code, and it would have looked a lot more professional and performed a lot better, on all platforms! Ah well, you live and learn.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s