29. Raise Your Hand If You Think C++ Was A Good Idea
I spent long days hacking on an SGI workstation that we had installed in my apartment. Even had email via a modem connection through a contact at McGill University.
Using home-brew object-oriented conventions for defining classes and dispatching methods, I implemented a preprocessor which generated C structures and switch statements. I was (and remain) a big fan of object oriented design, having used Flavors on Symbolics and read up on Smalltalk, Objective-C, and C++.
But I was definitely not a fan of the way C++ implemented OO ideas. And 30 years on as I watch the hairball it has evolved into, I’m still not sure what positive contribution it has made to software development, or how anyone thinks it’s a good thing. My impression is C++ started with two incorrect assumptions: (1) That OO can be statically bolted onto C — whereas Objective-C implemented a dynamic runtime , and (2) everything — productivity, maintenance, safety — must be sacrificed at the altar of code execution speed.
Enough ranting for now. Back to the Metropolis Graphics system.
I started by implementing vector and matrix libraries, scene data structures, and polygonal geometry. Everything was written in C and SGI GL. I think the OpenGL standard was just being formulated around that time.
The UI was also entirely written in GL: windows, buttons, menus, and so on. I even wrote routines for drawing bevels on the buttons, which was the trendy thing to do back then.
Meanwhile Mike was working on his new renderer. One thing I have noticed about developers like Mike, who specialize in rendering, is that they are always keen on starting a new rewrite. They always have new and improved ideas on how to increase the flexibility and optimization of their next renderer by re-architecting the code, based on better understanding of the domain.
After a while, for the first time, my wrists began to hurt from the long hacking sessions. I was worried about carpal tunnel, but it turned out not to be the case. Working on my posture and developing better ergonomic habits improved things over time. I was not getting younger.
Design & Code
As can be seen in the image above, I have implemented a multi-view window so I can see variations of the procedural modeling I have been playing with recently. It generates a grid of viewports whose viewing parameters are synced up.
Carrying on with the procedural geometry implementation from my previous post, I added a superquadric
class to the system. Always been a fan of procedural geometry. Maybe because it feels like I’m telling the computer what to do and it's doing the work for me. As it should be.
Superquadrics also come with a tinge of nostalgia for me. One of the first 3D CG images I saw (not counting “Tron”) was a robot arm made of superquadrics. It was a Polaroid photo from Raster Technologies of a ray-traced rendering by Alan Barr of Caltech.
The listing above is the entire code for my superquadrics implementation. I adapted it from some code I had written in 1992 in Macintosh Common Lisp. I am pleased at how brief and — if I may say — elegant it turned out.