We released this demo approximately 6 years ago. Then I was using windows and I didn't worry about other platforms actually. Nowadays I'm using linux and get horrified with the mere thought of having to use windows again, but my demos didn't work too well with wine. Since I still hadn't lost the code, what about doing a portable version which works in my computer? So that's what I have done with Scene Of The Girls.
Things that I have learnt
I expect most of you to feel skeptical about the idea of taking sources 6 years old and trying to make them work in a completely different system. But it has been an interesting experience and I have learnt a lot meanwhile.
BASS is way better than fmod
This is kind of ironic. At the beginning, I used BASS. Then when I began coding for Mac I had to use fmod, because it was the only available multiplatform library. I wasn't too happy with the sound quality (specially for modules) but that was all that we had. I then found out that BASS was available for MacOS, so I switched back to BASS. But then I wanted to code for linux and BASS wasn't available, so I switched again to fmod. I tried with fmod3.75 and then I noticed that I couldn't capture the demo with it, so I moved to the newer fmodex, which did allow me to capture the demo, with audio.
And there was a big "but": the latency. There was a considerable amount of time between the "BOOM" in the music and the images reacting. Funnily it wasn't that the images were happening with delay; it was that the music happened to sound too late for what was being shown in the screen. You saw torus shaking, and a quarter of a second later, there was a bassdrum kick. Something was decidedly wrong. I copied the code to a usb pen stick, and compiled everything on my powerbook with MacOSX, just to dismiss any possible ALSA+Pulseaudio+whatever latency issue. After all, supposedly MacOSX sound drivers have a very good latency. But the problem was still there. I tried on mrdoob's laptop (a Macbook running Linux) and the latency was still there. Luckily before I began to code my own sound/module playing library I thought of having a look at the BASS site again, just in case they happened to have released a linux version and oh joy! there it was!
I then proceeded to change once again my Music.h/cpp wrapper. I congratulate myself each time I have to change the wrapper, because thanks to having the wrapper I don't have to change every other call in the code. Then I ran the demo again, in linux, and the latency had gone away! YEAH! Even more, the song sounds WAY BETTER, because BASS interprets properly the resonant filters the song uses. That was a supercool moment!
So unfortunately for the fmod guys, sorry, but there's something wrong in your library. Although to be honest, the fmod API is nicer and doesn't make you think of bytes when what you want to know is how many seconds have elapsed, but is the price you have to pay for no delays.
GLC: a .kkapture alternative for linux
Normally one would capture a demo with .kkapture... if he happened to be using windows. Us linux-ers are left out without any alternative... or not! Because I found glc. It can capture opengl windows along with its associated audio and it works very well actually. I used it for capturing the demo and publishing it in youtube, after encoding it to mp4 with this script.
getopt_long is confusing, but very rewarding
To date I had only used a very basic style of argument parsing. I decided I would have something better, and I used getopt_long for it. This allowed me to add a lot of configuration options which before had been hardcoded in the demo and forced me to recompile each time I wanted to test a different parameter. You can see how I used it in the parse_arguments function in main.cpp.
PyGTK is very cool
This also set the path clear for the next thing I wanted: a nice launcher for people who do not want to type in a series of config options to launch the demo. I made the launcher with pygtk, and verified it works on any vanilla ubuntu (as I suspected, pygtk comes by default with the system because several basic applications depend on it).
So I just open that GTK window with some checkboxes and pulldown lists and let the user choose what he wants, and it builds up the config settings for the executable, and calls it. And when developing, one just had to press the up arrow to get the last typed in command and relaunch the demo using those very same parameters, instead of having to select them manually in the launcher dialogue. Simple linux style, I like it!
VBlank is off by default, whatever they say
I had lots of tearing in my app, even in window mode. I checked the SDL docs and they mentioned an GL attribute (SDL_GL_SWAP_CONTROL) that could be activated but was deprecated, and activated by default. I tried it anyway, explicitly setting it to true and surprise! the tearing and flickering went away!
I guess I'll continue releasing the remaining sources, once I get them to work here and wipe up extremely confusing stuff. The main goal is to let someone else learn from the code just as I did when looking at the code of other demos and specially sites like NeHe. There aren't superclever tricks in this demo, it is all fairly basic and if you want to code an opengl demo, it should be a good basis, at least for experimenting and changing things here and there. So come on, play with the code, experiment with it and make something better. And let me know afterwards!