Monday, May 26, 2008

Video mode switching

I've created a nice new video menu, and am working towards mode switching. Right now I have the 2D stuff dynamically changing in the menu, and can change the size of windowed modes on the fly (shockingly easy). Because I'm in Windows city, I'm going to use the registry for storing the default startup mode.

Update: all done. Fullscreen mode switching is also included, and the registry storage is done. There's some bugs to track down:

  • At 1280 x 1024 (and presumably other resolutions with the same aspect) the FOV used causes R_CullBox to break badly. This is a priority bug.
  • Switching from windowed to fullscreen at the same resolution doesn't really work.
Otherwise it's rather nice.

Sunday, May 25, 2008

Nothing much done today...

...but I did finally and conclusively clean up the whole vid.width/vid.conwidth/glwidth mess. I'm sure that lots of beginning Q1 coders have been bitten by this at one point or another, and it's always rankled with me that I never really straightened it out. It's done now: glwidth and glheight are utterly gone forever, vid.width and vid.height are used for all of the 3D stuff (as they are initially set to in gl_vidnt.c), and vid.conwidth and vid.conheight are used for all of the 2D stuff. Far more logical and sensible.

It's worth commenting that as part of this, I've set the 2D resolution to default to the same aspect ratio as the 3D resolution, but never less than 640 x 480. What this means is that on widescreen monitors, the 2D text and icons will be correctly proportioned. The console background, of course, remains stretched to fill the window. I've also removed the -conwidth and -conheight command-line options. I'll probably put them back in as cvars for those who prefer to scrunch their 2D stuff down, as there's no reason whatsoever for these to be only available as startup options.

At the same time, I've also removed glx and gly from the video system forever. These were just hacks to allow sizing down the screen for 1996-class cards, and they have no place in 2008. I'd actually partially done this ages ago (and in virtually every engine I've ever done), but this time I've completed the job, and just wanted to mention it.

Thursday, May 22, 2008

Today I have been mostly...

...Reworking the video startup code. The ID code is truly truly horrible. I mean, really ghastly. It's quite therapeutic to haul out that rubbish and replace it with clean, readable, functional and maintainable code.

Wednesday, May 21, 2008

On Development Environments

I'm currently developing MHQuake using Visual Studio 2003. I'm sure it's not the best IDE in the world, but I've used it for 5 years, I'm comfortable with it, I'm familiar with many of it's little quirks, and it's lightning fast on a modern PC, while still being functional enough.

I've downloaded and tried out a lot of free (as in speech) alternatives, but they just don't do it for me. Even at a basic level, like being able to auto-hide and auto-show away all the additional panels in VS, they fail. At the very worst, they do things in their own wildly idiosyncratic way; seemingly different just for the sake of being different.

Up until March I was developing on Visual C++ 2008 Express. I like the idea of using a free (as in beer) alternative, as it can make the source code more accessible to others, but intellisense turned out to be badly broken, despite promises of it being better in this release (in some cases it would take up to 5 minutes to recognise a new struct member, then promptly forget about it again) which was a total deal-breaker. If MS fix this, I might switch back. (The fact that SP1 is already in beta suggests that they're aware that something is wrong with it...)

The other alternative, Visual C++ 2005 Express, unfortunately doesn't ship with Windows headers and libs, which kinda defeats the purpose of making the code accessible. Also, neither 2005 nor 2008 can link with the single-threaded C runtime, which does cause issues for Q1 (thread locking issues and other fun galore). I might see if I can link with GNU libc instead.

Ultimately I'd like to switch to 2005 or 2008. They're nicer to use (provided intellisense gets fixed), cost nothing, and seem to produce faster code. I am however open to suggestions, so if anyone can suggest a free (either beer or speech will do) alternative that maximizes screen space, has good fast intellisense, runs quickly, is compatible with VCPP, and has features like outlining, unused code detection, code formatting, resource editing, full project management (source control not necessary), and lots of other good productivity features, but has nothing whatsoever to do with Java, I'd be interested to know.

Another update

Been doing some serious work on cleaning out my surface refresh. Basic stuff like removing surface subdivision, some troubleshooting and bugfixing on the refresh itself, tightening up code, and so on. I do need to start hitting at lightmap allocation though; one major optimization can come from allocating lightmaps in BSP tree order, which will mean that nearby surfs will share the same lightmap. What this means in practical terms is that lightmap uploads can be speeded up quite a bit, as modified surface lightmaps will tend to cluster together. I've an idea for modifying them entirely on the GPU too, but that will need some serious work (as well as re-engineering the whole subsystem).

I've just discovered that interpolated lightstyles are a colossal framerate hit, so I'm chewing over whether to drop them entirely or whether to just update lightmaps at a slower (but constant) rate, like at 25 FPS. This can free up GPU headroom for actual rendering, as the way things are, any speed increase is almost instantly swallowed up by lightmap uploads.

Also tightening up the framebuffer water warp code. The texture matrix warp is efficient but ugly, so I think I'm going to revert to a software warp.

Monday, May 19, 2008

More Progress

Just been spending some time working on the input code. More of a general tidy up than anything dramatic, although I have made a few changes.

  • Removed joystick support. This might get some people's backs up, but it's a practical necessity: I just plain-old-fashioned do not have a joystick to test other changes on, so better to have no support than broken/unpredictable support.
  • Added cvar controlled mouse looking (m_look, on by default). This is in addition to, rather than instead of, the old Quake 1 look controls, which still work exactly the same way as before with mouse looking switched off. You can even still have +mlook in your autoexec. While I was doing this, I removed the mouse slide forwards = move forwards a little funtionality (thinks: might restore this but make it controllable too).
  • Switched Direct Input and m_filter on by default (m_filter is now an archive variable). It's just smoother and more responsive on XP, which I guess is the version of Windows most people have these days. I may yet decide to re-initialize Direct Input at a map load/change as it doesn't seem to properly flush it's state between maps.
  • Added mouse wheel support to Direct Input. No thanks at all to the non-existent documentation, but a bit of digging around in header files and experimenting with stuff got me there.
If you're interested in implementing that last item, here's the code. It should be obvious where to put this.
case DIMOFS_Z:
// detect the mouse wheel movement
if ((int) od.dwData < 0)
{
Key_Event (K_MWHEELDOWN, true);
Key_Event (K_MWHEELDOWN, false);
}
else
{
Key_Event (K_MWHEELUP, true);
Key_Event (K_MWHEELUP, false);
}

break;

In other news, I finally threw out my old wimpy 350 watt PSU and got a nice beefy 650 PSU in. That wasn't quite the source of some of my recent problems (I'm fairly convinced that was an NVIDIA driver bug), but it's good to have the extra juice on tap, and it opens up GPU upgrade possibilities. Plus it's so quiet by comparison. Happy to report that changing it was a breeze, and I didn't end up all blackened and charred with smoke rising from the remains of my hair.

Thursday, May 15, 2008

Fun with my PC

What an evening of joy that's been! It started when my beloved GeForce 6600 GT complained about using too much power (which it never did before), but I fixed that by swapping things around a bit. Then I upgraded to AVG 8, which was a whole barrel of laughs. Hello ultra-slow start-up times, excessive memory use, and a fairly graphics-heavy user interface that takes positively ages to load. So after years of being loyal to AVG I'm ditching it; the new version is just not worth it - all I want is a lightweight AV program that's effective at stopping nasties, not some ghastly bloatware Norton 360 clone. To top it all, my idea for caustics in MHQuake didn't work out quite as well as I'd hoped (fortunately I have another).

On the plus side, Windows XP Service Pack 3 is so far rather nice. It actually gives a fairly hefty speed-up!

Wednesday, May 14, 2008

2 TMU Path

I've finally written most of the 2 TMU path for world rendering. Tackling this was fairly off-putting, but I'm there. The remaining item is handling of caustics, but that was always something that I had intended to move away from textures and on to vertex colours, so I'm going to switch them over to that.

I think I'm going to drop torch coronas too. I'm not a massive fan of the code I've used for them, and I came very near dropping the ball on this engine after the effort it took to even get that far. Better off without them than to have code in there I don't like and would risk freaking myself out over again.

Wednesday, May 7, 2008

Slightly Happy Today...

I've finally figured out the whole mess of how Hipnotic draws the Grenade Launcher icon in the status bar/HUD. This was a big jump forward, as having the same mod support as regular GLQuake is important.

I've also decided to drop the 3D HUD. It looks pretty, but the game assets are just not there to support it properly, and it requires far more hard-coding than I'm happy with. I've gone back and reworked the original SBar code to support a 2D HUD, so this will give the best mixture of compatibility and moving-forward.

Finally, I'm going to be reworking the video startup architecture a bit, as I want to support in-game resolution changing. Plus I think that the original is a bit of a nasty hack anyway.

Thursday, May 1, 2008

Not Gone Away

Just took an extended break. I'm in the cleaning up and filling in of loose ends part of the work right now, so don't worry - this will still be released!