Archive for May, 2008

Screen as a Serial Terminal

Wednesday, May 28th, 2008

While googling how to revert local changes in my git working tree I found a great blog entry titled Screen as Serial Terminal. Like the author I had no idea you could use screen as a serial terminal but it is actually pretty nifty since Minicom, even though a great application, usually is a little overkill for me.

Unsolved Mysteries

Friday, May 23rd, 2008

Here is a collection of some of the most well known unsolved mysteries (links to Wikipedia). They make for good reading on a rainy day.

Wow! Signal - Possibly extraterrestrial signal caught by SETI on August 15, 1977
Valentich Disappearance - Disappeared without a trace in a Cessna October 21, 1978 after reporting that he encountered a strange flying object
The Lost Colony - 16th century colony where all the inhabitants disappeared
Mary Celeste - Brigantine ghost ship discovered outside the strait of Gibraltar in December, 1872
Felix Moncla - USAF pilot that disappeared while pursuing an unidentified flying object in 1953
Ararat Anomaly - Unidentified object visible via satellite and aerial reconnaissance in a hard to reach location on mount Ararat
Oak Island - Location of a strange pit that many believe contain a hidden treasure

“The World’s Spookiest Weapons”

Friday, May 16th, 2008

Although only indirectly linked with deathtraps I found this article about The World’s Spookiest Weapons highly intriguing. I found it via Hack a Day.

They referenced the gay bomb in the last episode of 30 Rock but I assumed it was only a joke, stupid me.

Couple this with the old russian embassy in Bangkok and you have a pretty neat spy novel.

Python; impressively portable

Tuesday, May 13th, 2008

Last year I was faced with the daunting task of converting a large amount of Bash scripts to C-code. A terrible thing to do since we did a lot of stdio processing/redirecting which is simple to do in Bash but horrible in C. The reason for this atrocity was the fact that Bash did not work on our uClinux platform and none of the clones implemented enough feature to be compatible with our rather complicated scripts.

I went with a multicall binary in order to reduce the flash storage footprint and the end result is 100% compatible with the original scripts. On the downside the SLOC increased nearly four times and it was a PITA to implement.

Recently Kristian recommended that I should take a look at Python. At first I was skeptical for several reasons. If Bash wasn’t portable to uClinux then why would Python be considering it has so many more features. I’m also very careful about adding large complex software packages to an already sensitive platform.

A couple of weeks ago I had some time over and was terribly bored so I decided to give cross-compiling Python a go. As it turns out their build system isn’t cross-compile-aware at all but I did manage to build a working interpreter. Today Kristian found a guide on how to cross-compile the modules as well and so we were able to build a complete Python distribution. Surprisingly it seems to be working very well and so far memory consumption is within reasonable boundaries which is impressive. I’m not sure I want to port all the already converted Bash-scripts to Python right now but at least it is a perfectly viable option and would most likely increase code quality significantly in the long run.

Available socket bytes

Tuesday, May 13th, 2008

Ever wondered how to find out how many bytes can be read from a socket? I did and it is really simple although possibly not portable.

ssize_t socket_get_available(int socket_fd)
{
        int available = -1;
        assert(0 <= socket_fd);

        if (ioctl(socket_fd, FIONREAD, &available) < 0) {
                return -1;
        }

        return (ssize_t) available;
}

OpenGL 3.0, flip/flop

Monday, May 12th, 2008

Ever since I released the AdaTerrainEngine source code I’ve started to get an itch to go back into the OpenGL programming game again.

Something I’ve always been curious about is if Direct3D does have any big advantages over OpenGL but finding a good answer to that question has been hard, probably because there isn’t any. There is no doubt about OpenGL being much more portable and I’ve heard from good sources that it is much easier to get into OpenGL programming than Direct3D. For instance, you need approximately the same amount of lines of C/C++ code to set up an OpenGL window with SDL that you need to write a Hello World! application.

Recently someone told me that Microsoft’s latest DirectX release, version 10, is only available for Vista. I don’t find that weird considering the company’s history of forcing users to upgrade to something they don’t need however what I did enjoy was the fact that Crysis is (somewhat) playable with Wine. This indicates that you can recreate if not all at least the required parts of Direct3D 10 using OpenGL. Microsoft’s excuse for only delivering DirectX 10 to Vista is that it requires the new driver API they invented. I guess that means X11/OpenGL did it right the first time then, hooray.

Peter Kirn argues that OpenGL 2/2.1 offers the same functionality as DirectX 10 without the obvious vendor lock-in. Sometimes you hear people saying that since DirectX is updated more frequent than OpenGL it must be the case that it supports the latest GPU features whereas OpenGL does not. This is very simply not true due to the fact that the base OpenGL API only implements common and accepted functionality available across most GPUs. New features that have just been invented by someone are implemented as OpenGL extensions. These extensions can be implemented at any time and really only requires you to have the latest vendor-supplied driver which will support it. The effect of this is actually that OpenGL can support these new features quicker than DirectX since they do not have to release an entirely new version of their API! One such example is geometry shaders which are implemented by Direct3D 10 but available as GL_EXT_geometry_shader4 in OpenGL 2.1.

The fact is that OpenGL 3.0 is well on its way and it will offer an entirely rethought API which will much better meet todays needs. One of the biggies being that is more object-centric (whereas the current implementation is based on a finite state machine. The API will still be C compatible!

Another big advantage, according to “Some Thoughts on OpenGL 3.0“, is that you no longer need to tediously have to input every single vertex. Instead you can now “stream” a large amount of vertices into OpenGL making it much easier to load large, complicated, models. Another interesting feature is that everything in the API which can be created by shaders will be removed, leading to a cleaner more minimalistic API as opposed to DirectX which is constantly growing.

As desktop adoption of Linux and Mac OS X is constantly growing I believe that OpenGL will regain most of its fame soon. OpenGL 3 needs to be heavily marketed when it is released as I suspect many game developers have been listening to Microsoft for a long time now and they might need some encouragement to take the plunge. Writing portable games does not need to be something difficult as long as people are using the right tools for the job and the gaming industry need to wake up and smell platform diversity explosion that will soon be upon us. The only people I know that still argue against OS X on the desktop are the very same people that have never tried it. As for Linux, it tailors to the more computer literate and in my opinion it should stay that way. Still, the number of computer literate people should be enough to make it an interesting platform for entertainment providers.
nVidia gave a short OpenGL 3 presentation at SIGGRAPH 2007 which is available here.

The season’s afoot

Thursday, May 8th, 2008

Our media department was playing around in the parking lot outside the office and managed to take a couple of pictures of my car in the process. I have just taken it out of the garage for the summer and so far it seems to have survived the winter.

Camaro at work

During the off season I replaced all the (original) pintle-type fuel injectors with disc-type injectors from Ford. The car was difficult to start when cold before but with the new injectors in place it fires up instantly.

I also did a lot of work remove rust from the undercarriage and rear axle, when I get some decent pictures of the end result I will post them together with the before-pictures. Hopefully before I get too much dirt under there.

There is still a lot of work to do but I’m well on my way.