Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Friday, 24 April 2009

GNU/Linux

Until only a few years ago, I had no real experience of UNIX-based systems save for some minor University-related work. However, over the last few years I have spent some time attempting to improve my knowledge of the POSIX world as part of my ongoing efforts to remain platform-independent.

At University, my UNIX experience consisted of using SuSe as part of a Networking/Computer Architecture course and using PS2-Linux for PlayStation 2 game development. Neither were very interesting - the networking coursework was largely unrelated to my degree and was made needlessly difficult by requiring us to use the foreign UNIX OS in place of the Windows environment that we were familiar with. As for the PlayStation 2 development, our coursework was to create a Pong clone using a horrible mess of UNIX and PS2 library code under a KDE that insisted on crashing at least once a day. This course module required me to sign a non-disclosure agreement, possibly in order to prevent me from informing others of how terrible the Game Console Development course was. All in all, these experiences did not do anything to improve my opinion of UNIX versus Windows NT.

Outside of University, the only UNIX-related experience I had consisted of about 10 minutes with an Ubuntu LiveCD and whatever time I could spare to experiment with my new Apple Mac Mini and it's PowerPC processor. However, during my industry placement year (2007-2008) away from the University, I decided to experiment with UNIX some more and installed Xubuntu on to a spare hard disk drive. Forcing myself to use it for a few weeks wasn't as arduous as it might have been, due to the availability of some of my favourite applications from Windows, such as OpenOffice.org, Firefox, Thunderbird, VLC and Code::Blocks.

However, I encountered more bugs and general inconveniences under UNIX than I have ever had to deal with under a standard, out-of-the-box Windows XP installation. The X Window system never seems to work correctly and installation of graphics drivers is an annoying and error-prone experience to say the least. Also, VLC refused to run after Code::Blocks was installed due to incompatibilities with the newer wxWidgets library. So-called "DLL hell" might have been an issue under the DOS-based Windows 9x design but this problem is not present under the new (and largely unrelated) NT architecture. It is disappointing to see that it is still an issue under the allegedly superior UNIX design.

During this time, I played around with a few other operating systems, including the OpenSolaris LiveCD. Those of you who have an interest in alternative UNIX systems aside from GNU/Linux and BSD may wish to download this LiveCD for yourselves.

Shortly before I completed my year working as a programmer and general IT technician, the replacement student, David, arrived. David seems to be an excellent fellow, with a much better knowledge of UNIX than myself. During our month working together, he suggested that we completely reinstall our dying Red Hat server with Debian GNU/Linux.

The end result was not one but three Debian-powered machines:
  • A "test run" server, which had previously been retired from service and put into storage.
  • The "real" server, which ended up being used in tandem with the "test run" server.
  • A desktop machine, built by myself from spare components.
The desktop machine became my primary workstation, as David was now using the machine that had previously belonged to me. It was on this that I constructed a GUI front-end for the AMANDA backup program using Code::Blocks and the GTK+ library. I still have this on a CD, licensed under the GPL v3 but as I lack access to any sort of tape backup hardware I cannot continue to work on it.

GTK+ was interesting to work with but has some major flaws:
  • It's much more limited than the Win32 API.
  • It was annoyingly difficult to configure projects so that they could link and build correctly.
  • GTK+ is much less efficient than pure Win32 code under Windows.
  • It seems to be riddled with bugs, although this might have been caused by Debian 4.0 using an older version of the GTK+ development libraries for it's repositories. I'm fairly certain that the code I wrote was correct and bug-free and yet my application seemed to either crash or output garbage far more often than it should have.
Moving on to the present day, my room currently has five computers in it:
  • My main tower, which is currently running Windows Server 2008.
  • My old laptop, running Windows XP Home SP3.
  • My Mac Mini running MacOSX 10.3.9 (currently being stored on a shelf).
  • A spare tower, currently in a state of disassembly (previously ran Windows Server 2008).
  • My UNIX tower, currently running gNewSense 2.2.
The gNewSense tower runs quite happily with a 450MHz Pentium III processor and 256MB of RAM using the integrated Intel graphics chip. I have unearthed the copy of Introduction to Unix that my University gave to me as part of the Network course, installed Code::Blocks and managed to rig up a simple OpenGL/SDL program that renders an animated .MD3 mesh at an acceptably smooth frame-rate. The same Code::Blocks project file recompiles on my main Windows tower with no alterations save for using a different build target.

I've not been without problems, however - Debian 5.0.1, which I attempted to use before trying gNewSense, didn't seem to like my graphics chip and X.org refused to run. The gNewSense GNOME GUI runs fine, but there seems to be a fault with the hardware OpenGL acceleration that causes corruption around the mouse cursor. This is not usually a problem for me, since SDL windows do not draw the standard X window system cursor and so corruption does not occur.

Yesterday, the X window system crashed when I attempted to create a simple OpenGL/SDL window. The CTRL-ALT-BACKSPACE combination that I have become so familiar with had no effect and attempting to CTRL-ALT-F# to a terminal display was equally useless. After forcing the machine to power off, I restarted it, logged in and ran the program again. It worked flawlessly. What, then, was the cause of the X server crash?

Lastly, my router loses it's connection to the Internet whenever the gNewSense tower is online. This might be a problem with the router, a problem with the network card or a problem with the driver or version of the network card driver or Linux kernel used by gNewSense but for now I have simply disconnected the gNewSense tower from the network.

Saturday, 28 June 2008

Mobile Phone Gaming with Java.

I've been hearing a lot about "Casual Games" recently and have been thinking about looking into making some myself. While developing for the PC or Apple Mac is probably the simplest way to do this, it's not very interesting since I do that all the time anyway. Developing games for mobile phones, however, is much more novel and also more challenging because of the comparatively limited power, so I decided to start investigating how to do this. After downloading and installing the J2SE and J2ME development kits from Sun, I began experimenting with the provided phone emulator and my actual PDA to see what could be done.

As John Carmack wrote, a major obstacle when designing games for phones is the method of input. For example, on my Phone/PDA all I have to work with is a D-pad with a "Fire" button in the middle. First of all, having the fire button in the center of the movement buttons is not a good design for any sort of game where input needs to be quick and precise, and, secondly, my phone detects only one button press at a time, so there can be no diagonal movement and no movement while pressing fire. These are serious limitations for any sort of dynamic game.

One solution that I have come up with is to use the touch-screen instead of the D-pad. This allows the player to control their movements with the stylus and use the fire button without the D-pad interfering. Unfortunately, not all phones have a touch screen, so designing a game that relies on a stylus for input would prevent it from being played on several devices. Also, the phone emulator provided with the J2ME development kit does not provide touch-screen emulation.

Turn-based gameplay seems to be the best idea here. Something like Advance Wars or a Final Fantasy 6-style RPG would work well with a bit of thought. For dynamic games, things such as Pong or Pac Man would work well because there is no need for a Fire button and only one directional button needs to be pressed at once.

Thursday, 13 September 2007

Introduction

For a while now, I've been meaning to create a website that I can use both as an on-line portfolio and as a “learning diary” for my experiences in the world of programming. I originally tried to do this with a variety of pure HTML sites but these were cumbersome to update and maintain - although I learned a lot about HTML by creating them, so I suppose that it was a worthwhile endeavour overall (it is worth noting that, due to a no-PHP restriction with my freely-provided University web-space, my site there is still written entirely in pure HTML).

My next thought was to create a PHP-based site, using an SQL database to store articles. I therefore installed Apache, PHP and MySQL and set about learning how to use them all. I think that I learned a great deal on this brief project but I eventually decided that a Blogger account would be a better idea. This was mainly because creating a Blogger account costs nothing, whereas a decent amount of web-space and bandwidth with PHP and MySQL support can be costly, especially if you want to buy a domain name as well. The Blogger system would also allow features such as user comments, which I had not originally thought about but which would undoubtedly be useful in getting feedback and advice from visitors with more experience than I in whatever field I decided to research next.

What can you expect to see on this site? The majority of my postings here will be programming related, relating either to basic coding topics such as successful encapsulation with object-orientated techniques and programming correctness or to higher-level, theoretical concepts such as flexible-yet-secure game engine design and AI techniques. For anyone who is not so very interested in the raw work that makes games and applications operate, I shall be posting images of rendering experiments and possibly even the occasional downloadable demonstration program every now and again.

For anyone wondering where the title of this Blog comes from (no, it is not my real name), you might like to know that I've always been interested in the work of id Software – including two of it's founding members, both of whom have now left.