19 Jul

OpenGL, Static Arrays and glMaterialfv

I stumbled upon weird behavior of OpenGL (OGL 1.4, Catalyst 8.612, GCC if that matters): I was setting material properties with glMaterialfv and for some reason this did not change the parameters if done multiple times in succession. I.e. when I drew two versions of the same object on the screen side by side with different material parameters, they both looked the same.

The reason seems to be I was using a static array to store the parameters like this:

void set_params(const Color& diffuse)
{
  static float d[4] = {diffuse.r, diffuse.g, diffuse.b, diffuse.a};
  glMaterialfv(GL_FRONT, GL_DIFFUSE, d);
}

The only explanation I can think of is OpenGL doesn’t copy or use the values before glMaterialfv returns but instead reads them later, at which time there could be different values in the array (because it’s declared static) set for some other object being drawn. But that doesn’t explain why it can read the array (which AFAIK will be located on stack) later because the address to the then-valid location on the stack most likely won’t point to the parameters. Maybe the driver assumes anything that’s not on the stack can be used later and stuff located on stack will be copied. Who knows?

In any case, not declaring the array as static fixed the problem.

19 Jul

Wordle and Classics

More Wordle madness. Try to guess if you recognize the works summarized below (no cheating allowed!)

pulp-fiction

slaughterhouse-five

The first is easy but the second probably is something you uneducated mooks should read.

01 Jul

Wordle and 30 Years of Games

Here’s a superficial analysis on game titles. I have used Wordle to generate a word cloud from lists of recurring phrases in game titles. What I generally wanted to know is how a generic title from 1985 would differ from a generic title from 2009. The size of a word or phrase is relative to how many different titles contain the text and also how complex the phrase is (so one word long “phrases” won’t dominate the more interesting, relatively rare phrases).

What the word clouds show are very generic words like “space” or “super”, the number two (a game series is more likely to be two than three games long) and multiple word phrases which usually are popular game series, clichés (Foobar of Doom) or games with many versions or expansion packs. It is interesting that the generic words tend to be the same across 30 years — all generations of gamers seem to love dragons. Another point of interest is that a phrase from a 1980s game title is much less likely an established brand as it most likely is in the 1990s. Also, in the 1990s is became common that a game title has the release year attached to it, since EA et al started to churn out minor updates to their sports games as brand new releases.

30 years of games. Find your favorites!

1980-2009

1980-2009

1980-1989

1980-1989

1990-1999

1990-1999

2000-2009

2000-2009