ADOdb function: GetUpdateSQL

I have been getting myself familiar with ADOdb by using it in a personal web-development project. I ran across this (rather poorly documented) member function in the database connection class: GetUpdateSQL. In principle, it looks like a very useful function. Given a recordset (which you’ve previously retrieved in a query) and some desired changes, it will generate a nice compatible UPDATE query string for you. However, I have found it to be a little disappointing for my needs.

Read the rest of this entry »


Making slugs with JavaScript and regular expressions

You will sometimes want to generate a suitable URL ’slug’ based on something the user has entered, such as the name of a blog post, or perhaps the name of a file which is being uploaded.

In order to ensure that your URLs are consistent, valid, and unambiguous, it is common to place the following restrictions on your slugs: allow only lowercase letters, numbers, and dashes (-). For example, a blog post called “Hello World!” might have a resulting slug of “hello-world”. Additionally, it is common to remove leading and trailing dashes from the final slug.

In this post, I’ll introduce a way of doing this in JavaScript.

Read the rest of this entry »


Another SL presentation tool: Slide Wheel

My supervisor (Daniel) and I were giving a SLOODLE presentation at a conference in Second Life today. When we were discussing it earlier this week, Daniel suggested a really novel way of presenting the slides… and since I’m never one to back down from a programming challenge, I built it!

The result is the Slide Wheel. All the slides in your presentation are displayed in a big wheel in mid-air. When you want to show a particular slide, the whole wheel rotates, and the current slide jumps to the foreground. I’ll upload a video of it soon, but for now, here’s a screenshot:

Screenshot of the new Slide Wheel presentation tool in Second Life

Slide Wheel screenshot

You can get this item free on XStreetSL, as I am releasing it open source. I am sorry it is not perfect yet, but the requests for me to make it available tell me it’s in high demand! Please give it a try, and contact me if you have any questions or if you find any bugs.

Happy presenting!


OpenGL gotcha: my particles are too small

As far as graphical effects go, a particle system is one of the most versatile. It can be used to simulate things like electrical sparks, dust clouds, smoke, fire, and water. However, there is one problem which I have been annoyed with several times in the past, but until now I hadn’t really bothered to fix it.

I would spend ages programming a particle effect, tweaking all the parameters to get it just right, and it would look fine at first. But then, on another computer, or on a different screen resolution, or even just with a different size of window, the effect suddenly wouldn’t look right. All the particles would be too small or too big.

You can see this problem in the image above. It shows a particle effect for a rocket thruster — the one on the left is how it should look, while the one on the right shows what happened when I roughly tripled the size of the game window.

Read the rest of this entry »


OpenGL gotcha: remember GL_LIGHT0

In my experimenting with some simple scene geometry and lighting today, I stumbled into the same pitfall I’ve strumbled into several times before (you’d think I would have learned by now!). While moving around the scene, I found that the lighting on surfaces appeared to change depending on my camera angle — if I looked at a polygon square-on, it seemed much brighter than if I was looking slightly away from it.

There are two common reasons for this problem…
Read the rest of this entry »


PHP4/5: Object orientation and compatibility

Some compatibility problems were reported following the release of SLOODLE 1.0, and they largely appear to centre around the object-oriented plugin system I developed for the Presenter module.

The idea is fairly simple. The SLOODLE core or 3rd party developers can create plugin classes to extend the functionality. These will all belong to a structured inheritance hiearchy, and will be automatically detected and loaded by the SLOODLE framework. However, it has been a big challenge maintaining compatibility for both PHP4 and PHP5, given that the object orientation of the language has changed so much in that time.

After considerable efforts, I think I’ve finally found the solution, and it’s infuriatingly inelegant.

Read the rest of this entry »


OpenGL gotcha: scale your normals!

My OpenGL blunder this evening involved forgetting to make sure my normals were scaled correctly.

I had a scene with a single point light source and several small rotating cubes. Everything looked fine. I had also written a function to draw a 1×1 plane in the scene, and that looked fine too. I then applied a scaling transformation in my plane-drawing function (using glScalef) to make it 10×10, but for some reason the plane was then totally dark.

I tried moving and rotating the plane to see if it would catch the light at some other angle, but it wouldn’t. Eventually, I spotted the flaw…

Read the rest of this entry »


PHP quirk: shell commands breaking on Windows

I’ve been wrestling with many compatibility quirks in my work on SLOODLE lately, and this one certainly takes the prize. It seems that some perfectly valid shell commands will simply not work when executed from within PHP on Windows.
Read the rest of this entry »


OpenGL gotcha: depth buffer distortion

While I’m on the topic of OpenGL gotchas, I thought I’d mention another which caught me out a couple of years ago. I was working on some prototypes with some friends, and you can see a screenshot on the right (click it for a full view).

Notice areas where polygons overlap — you can see a striped or checked pattern of the occluded polygon showing through. In this case, it was 2d graphics and a 3d camera (so that we could make some interesting visual effects). However, the problem manifests just as badly in full 3d.

It took quite a while to figure out the problem, and it’s one I’ll never forget.

Read the rest of this entry »


OpenGL gotcha: mipmaps only please!

Here’s an OpenGL gotcha which caught me out for quite a while. I was writing code to load textures, but it only worked if I was using the GLU function to build mipmaps. After lots of hair-pulling, I realised that it was entirely my mistake.

Read the rest of this entry »


« Previous Entries