OpenGL Programming on Linux
The days went by, and we started incorporating more and more code into the project. My team-members had more course work than I did, so I found myself leading the team—writing most of the code in the first part of the project and all of it in the second and third parts. Of course, I was writing it all on Linux—but always verifying later that it ran on the RS/6000 workstations (Murphy, you know?).
Of course, that did not go unnoticed, and some of the students in the class started exploring ways to build and develop their own projects at home on their PCs using NT or that OS-with-an-expiration-date-in-its-name (Windows 95). Others followed my advice that it would probably be better to use a Unix because of portability problems (I thought...er envisioned...er imagined that the Win32 API could be quite different from that of most Unices) and got Mesa running. After all, if you have the choice and if you can do the same things you do at your university at home, would you rather spend nights in a freezing-cold computer lab with armless wooden chairs or work on your home computer?
Problems started to appear just a few weeks after that when we were required to implement and use a timer within the game. That was the first blow for the NT/95 people because, unless you're familiar with the Windows API or have some sample source code, changing Unix's gettimeofday() to a Windows API call is not trivial. After all, if your virtual tank is going at 10 m/s, it should do so no matter what hardware you have, be it a 16 CPU SGI workstation or a poor 80486. Some people got tired of putting #ifdefs and #ifndefs in their code and decided to spend nights in the lab instead.
Then came the network daemon. The idea (mostly at my suggestion) was that the game client running on a particular workstation would fork() a daemon at initialization. The daemon would share one or more memory segments with the client and would have the task of listening on certain ports for broadcast messages sent by other possible network players. Needless to say, these Unix intrinsics marked the end of the Windows port; even if you could run a part of the 3D engine on Win32, you'd still have to do all the network and final debugging on the RS/6000 workstations at school.
But during all this time there was at least one happy Linux user who did not change a single line of code when sending it from his home Linux box to the Risc workstations. And the only time he actually had to put an #ifdef was when the endianness difference between the Pentium and the RS/6000 processor started to show in the byte ordering of the TARGA files he was loading and using for textures. Rumour even has it that he debugged his network code without actually entering the computer lab: in the darkest hours of the night he used two workstations to run his program on and exported the display to his Linux box (which was slow, but functional enough to track down some bugs).
Speaking about performance in OpenGL is, for those of us who don't use a middle to high-end SGI workstation at home or at work, about as important as speaking about OpenGL itself. In our case, around the middle of the semester, it became obvious to both professors and students alike that the RS/6000 workstations we were using were not fast enough for what we were doing with them.
Eventually we switched to another lab of RS/6000 workstations which belonged to the Mechanical Engineering Department. People there ran CATIA—like AutoCad but with ten times the features and the memory requirements. Those workstations were still not inherently faster than a good Linux Pentium PC with enough RAM; most tests, gcc, xv, etc, showed my P133 was about 50-60% faster doing generic operations. But their hardware-accelerated OpenGL graphics allowed my game to run on them at 25 frames per second with 512x384 pixels. By comparison, I was getting a maximum of only 9-10 frames per second with 320x240 pixels on my Linux box, where OpenGL rendering was done by software alone on the main CPU and FPU.
The program still ran, and it was fast enough to allow me to work out most of the bugs and implement new features, but I would personally have enjoyed it a lot more if the Linux OpenGL port I was using had been able to take advantage of the 3D features on my video card to make my programs run even faster. On my end, I tried removing as much un-optimized stuff as possible from the game's main loop to make it run as fast as possible on all platforms.
Here are some stats about the project:
Lines of code: about 7600 (game and daemon) + 900 (explosions renderer)
Number of textures and ray-traced rendered explosions: 34
Number of different object lists used: 38
Number of possible network players or automated opponents: 20
Features only available on Linux: basic sound!
Time spent pulling our hair out on that game: around 200-250 man-hours
- Machine Learning Everywhere
- Bash Shell Script: Building a Better March Madness Bracket
- Own Your DNS Data
- Understanding OpenStack's Success
- Simple Server Hardening
- Understanding Firewalld in Multi-Zone Configurations
- From vs. to + for Microsoft and Linux
- Natalie Rusk's Scratch Coding Cards (No Starch Press)
- Ensono M.O.
- The Weather Outside Is Frightful (Or Is It?)