OpenGL Pitfalls, or how I wasted most of an evening…

February 22, 2007 | General | By: Mark VandeWettering

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:

Avoiding 16 Common OpenGL Pitfalls

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.

One of my first raytraced pictures

An 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.

Technorati Tags: , ,

Addendum: Here’s a brief blurb about the X29 from NASA.

Addendum2: Here’s a screen dump of the same shaded in OpenGL:

X29 in OpenGL

Share Button
Be Sociable, Share!

Comments

Comment from AG
Time 2/28/2007 at 11:07 pm

Recently read an article in Linux Journal, written by Nicholas Petreley, states that M$ owns the rights to the openGL software patent. If this is true, does your company(Dreamworks) have an undisclosed balance sheet liability? If you’re interested, I can refer you to the article.

Comment from Mark
Time 3/1/2007 at 1:09 pm

Wow. How odd.

In no particular order:

  • I don’t work for Dreamworks.
  • There is not an “OpenGL software patent”. Microsoft may own IP which they think is protected by patents, but you’d have to refer me to precisely which patents those are for me to offer an opinion as to whether OpenGL infringes (although admittedly, I don’t know much about the innards of OpenGL, so I am hardly an expert, and am not empowered to answer those questions on behalf of any company or entitity).
  • I am unqualified and uninterested in commenting on the financial liability of any companies interest.
  • Petreley has written about the entire Novell/SUSE/Microsoft stuff before. I frankly don’t care very much about this at all. It seems to be a huge amount of FUD, resulting mainly in a tempest in a teacup. Novell doesn’t think that Linux infringes on MS patents. Under their agreement, Microsoft has agreed not to sue their customers. Whoopdy do.

Did this answer your question?

Comment from AG
Time 3/4/2007 at 8:55 am

Mark:

Yes, this answers my question.

Sorry, I didn’t mean to come across as a FUD replicator or troll. I used to be a fairly regular listener of your now wayward podcast. Just wanted a bit of education regarding this talk about OpenGL being patent encumbered. It would be a shame if M$ greed could somehow cripple Beryl and Compiz projects.

BTW: I often confuse Dreamworks and Disney, don’t ask why ;)

Comment from arbab nazar
Time 12/11/2007 at 3:35 am

hello can it possible that you give me the code how to draw a aircraft in opengl because i want to make a project on which i want to use it but i shall mension your name in it.
thank you

Comment from Shreekanth G
Time 3/30/2009 at 9:03 am

Sir,
Can u please mail me the OpenGL program for Stars program with turbo and crazy mode.
I am in need of its synopsis with one page of description.
If u can send me I will be grateful to u .

Comment from Suadi
Time 4/20/2009 at 8:06 am

Can anybody please help me write a synopsis for the bounicing ball program?

Comment from Suadi
Time 4/20/2009 at 8:07 am

Can anybody please help me write a synopsis for the bouncing ball program?

Comment from mona
Time 12/5/2012 at 11:57 am

is it possible give me the code how to draw an aircraft in opengl for my project,it is necesery
thanks alot

Write a comment