# 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 by several times in the past, but just lived-with because I didn’t think it important enough to fix.

I would spend ages programming a particle effect, tweaking all the parameters to get it just right. 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 increased the size of the game window. Read more OpenGL gotcha: my particles are too small

# OpenGL gotcha: remember light 0

I was experimenting with some simple scene geometry and lighting in OpenGL today, and I stumbled into the same pitfall I’ve stumbled 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 more OpenGL gotcha: remember light 0

# 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. Next, I 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 my mistake. Read more OpenGL gotcha: scale your normals!

# 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 larger view).

Notice areas where polygons overlap: you can see a striped or checked pattern of the occluded polygon showing through. In this case, we were rendering 2d graphics with a perspective (3d) view so that we could make some interesting visual effects. However, the problem can manifest just as badly in full 3d.. Read more OpenGL gotcha: depth buffer distortion

# 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. Loading standard textures kept failing. After lots of frustration, I eventually found my mistake. Read more OpenGL gotcha: mipmaps only please!