
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!
And now…
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!

manolopm
I’ve compiled to x86_64 and works great! I’ve to download SOIL and bass and compile it for x86_64 but the demo compiles and run great.
Is quite impressive to view the demo at 1900×1200 fullscreen :)
Now I know what are you trying to do with pygtk ;) :P
Once again, great work
Regards from Canary Islands
sole
Great to see that you can compile too! I am still using 32 bit linux because of some applications which are provided in 32b flavour only (like renoise, flash). There are threads out there which say how to make them work in a 64 bit system but I don’t want to worry about that by now.
I mean, “here’s the code”, it should be easy to compile anyway :)
Glad you liked it! :D
Regards from British Islands
pplux
Great post!
I’d like to suggest two typical utilities for the settings, dialog (console based) and zenity (gtk based), it will be great to use a simple bash script with zenity and embed the demo at the end of the file (as Slack’s 4k demos), a all-in-one file :)
Also you get rid of python XDDDD, no, seriously using pyGtk is great (gtk is quite usable unless you want to use the native C interface).
sole
What’s wrong with python!?!?!! You’re always complaining about it – but I still haven’t found a nicer way of making a GUI which is as readable as this one.
The native GTK interface isn’t that bad, but since pygtk is installed by default in Ubuntu and making the GUI with pygtk would help me avoid extra compiling steps, I just went for that option. Besides, not having to allocate memory and things like that is nice :P
I didn’t know about zenity or dialog — but although I could find the zenity homepage easily, dialog is going to be a tad hard to locate. Couldn’t they just come up with a more original name? haha
By the way: wall-e? did you seriously name your computer wall-e? I’m not talking to you XD
pplux
What’s wrong with python!? What’s wrong with python? are you serious? WTF?
I’m kidding! I’m not always complaining about python, it’s a great language, it has its uses and certainly a minimal GUI interface is one of those uses. For me python is not THE language for everything, that’s all; That’s why I inexorably end showing people that there are beautiful little commands out there, that have been there since always, to do many of the things python can be forced to do. (but I do like python!!!)
my little grasshopper, a good tool doesn’t necessary need a webpage, if you need to know anything about dialog or zenity simply use “man” (is that old technology you can even use offline) XDD
And yes! my “MacBook” black and silvered is wall-e, and Diana’s macbook (white plastic) is eve. :)
sole
Amazing! Both ‘man dialog’ and ‘man zenity’ work!
Although to be honest, it’s the last thing I would do when looking for information. I used man like 10 years ago. Then came google…