Parameters and book stores

· by Steve · Read in about 3 min · (546 Words)

I’ve been going nuts on C++ for the last week so I took a break tonight to do a couple of things I’ve been meaning to do for ages. Firstly, to make our Pro Ogre 3D Programming book link in the sidebar of country-sensistive, so that instead of only getting the link & price from, it behaves differently depending on your country. Secondly, since people are always asking about books I recommend on 3D / C++, I’ve embedded a country-sensitive Amazon store in the Ogre site via a new Books link, containing the books I personally recommend most at the moment. Currently it displays if you’re in the UK (like me) or for elsewhere. Sorry to any non-UK, non-US people - Amazon makes you sign up individually for each region so I’ve only bothered to set up for the US and UK so far; if there’s great demand I might expand that but for the moment that’s good enough. I really quite like Amazon’s affiliate set up except for that administrative bit, it’s very customisable especially around what content you want to display - I wanted to only directly display the specific books I own and recommend (although you do of course get ‘Similar Items’ links, which you can turn off but actually are very relevant), and it lets me do that. There’s plenty of other options too if you want a more general advertising set up.

As for OGRE work, I got on well over the weekend with rewriting and extending some patches, but a few things bothered me during my sojourn through some of the code. It’s been a few years since I wrote the first version of GpuProgramParameters, the class that holds all the parameters that you send to shaders, and I originally wrote it for assembler shaders, with Cg, HLSL and finally GLSL added later. It all works, but there are some things that I felt could have been done better on working through it again, and there was quite a lot of code that had been tacked on for tool support (serialising params back to a script) as well as the ultra-high level stance that GLSL takes. For example, all our parameters were built around the notion that underneath it all, everything is packed into 4-element structures e.g. float4 / int4 (so a 2×3 matrix will actually take 2 float4’s), and that applies to all but GLSL, which packs things tightly, at least from an API perspective anyway (I suspect underneath it all it’s no different). Anyway, I saw a ton of ways I could make it better, and had another patch which I wanted to rewrite anyway which I saw could be folded into that work. It’s taken quite a while (2 days so far, but I’m almost done) but the code is smaller, more memory and CPU efficient, and just generally more satisfying. Had I known it would take this long I might not have started, but I feel good about where it’s going.

Been getting a bit of RSI the last couple of days again, which I haven’t suffered for a while because of both my new keyboard and not working quite so many hours. Better play a few more games or something instead 😀