OpenGL Pitfalls, or how I wasted most of an evening…
I’ve worked on computer graphics for over twenty years now. Through some quirk of fate, I have spent nearly all of my time programming batch rendering algorithms that take minutes or even hours (days?) to render pictures. The last time I really did interactive work was before OpenGL even had the “Open” prefix, back when I was working in the Princeton Applied Math department back in 1990. So, I’m not exactly the most experienced OpenGL programmer. I haven’t written anything more complicated than simple 2D plotting in years.
So, I was working on my program that reads the accelerometers from the Wii Remote tonight, and tried to set it up to draw an airplane that I could tip and tilt using the Wii remote. Unfortunately, I couldn’t get the lighting to look right. I tried all sorts of different things, but finally decided to do a bit of research and found this page:
What bit me? Why, the very first thing:
glEnable(GL_NORMALIZE);. It never dawned on me that OpenGL might fail to compensate for scaling before computing lighting. Oh well. Live and learn.
I’ll have some example code and video of this little hack this weekend. I want to clean it up a bit more, and I still need to shoot some video of it.
interesting aside bit of personal trivia: the model that I am using is a model of the NASA’s X29 experimental aircraft. It’s the same polygonal model that I first rendered with my old raytracer over twenty years ago. I feel like I’ve come full circle.
Addendum2: Here’s a screen dump of the same shaded in OpenGL: