☰ Menu+  instagram  tuffy  ringing ear  rentals 

geekstuff | gameswf | Textweb | Chunked LOD | dumbuild

Cheat sheets: CVS | cygwin | Debian | Emacs | MythTV

Free geek stuff

This is a collection of software, scripts, methods, algorithms, and little programs and bits of code that may be useful to someone like me. Consider the source code to be in the public domain, unless otherwise noted. The non-code writings are copyright me.

See the links above for individual projects. The items below are more miscellaneous.

Microsoft's Free Windows Development Tools

23 April 2005

Here's something I didn't discover until today: Microsoft offers a free GUI debugger, WinDbg, that is actually pretty decent. Check out this screenshot. Combined with the free C++ Toolkit command-line compiler, plus emacs and cygwin for editing & building, I have everything I really want for Windows dev. Now that I'm not being paid to work with Visual Studio, I'm sure not going to spend my own money on it.

It was a pain in the neck to track down everything I needed to make the compiler & debugger happen, but they're all free downloads from MSDN. For example, the msvcrt.lib that corresponds to msvcr70.dll doesn't come with the compiler toolkit! Whereas the toolkit does include the non-DLL runtime link libraries. For real dev you kind of need the DLL runtime, so you have to go chase it down as part of ".NET Framework SDK". Then you need to discover that that SDK creates a "C:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/lib" directory, where it puts the .lib's. Thanks to this guy's page for pointing me in the right direction. Note that his alternative advice for making my own .lib's from the .dll's did NOT work for me.

I haven't used WinDbg very much yet, so maybe it will turn out to suck in some important way, but so far so good. It also required some tweaking before it became useful -- you have to manually (and separately) set up the paths to search for source and PDB files. And you can specify the debugee's arguments on the WinDbg command line, but I haven't yet found a way to change the debugee args from the GUI.

But hey, I just fixed my first couple of bugs with its help.

Yet More On Perspective Shadow Maps

Late breaking news: How to do them right ! See http://tulrich.com/geekstuff/psm_notes2.html

This is very brief and sketchy right now, but I'm pretty sure it's good.

More On Perspective Shadow Maps

Some collected notes, links to a 2D vizualization app for intuition, & diagrams: http://tulrich.com/geekstuff/psm_notes.html

Visual Studio .NET sanity

VS.NET is driving everyone at the office crazy, especially me. Thanks to the spiffy new automation features, I'm on a mission to automate everything from the friendly confines of emacs, and avoid learning yet-another-set-of-keybindings as much as possible. In furtherance of that mission, I created a little .exe which sends a command-line to a running instance of VS.NET. For example, you could set up a macro in your favorite editor to jump into VS.NET at your current edit location, to set a breakpoint or whatever. E.g.:

DevEnvCommand File.OpenFile c:/path/to/some/file.cpp
DevEnvCommand Edit.GoTo 37

Stick that on a function key, along with keys to trigger a build, a build & go, etc. To escape from VS.NET back into your fav editor, use the "Tools | External Tools..." stuff, and bind to a key. (For emacs, the options look something like: Command="c:\emacs-21.2\bin\gnuclientw.exe", Arguments="-n +$(CurLine) $(ItemPath)" and check "close on exit")

Here's the code: DevEnvCommand.cpp | DevEnvCommand.exe

Here's some elisp from my .emacs that puts it into action: devenv-tricks.el

Updated 26 Sep 2003 with a patch generously submitted by Brian Sharon. This change raises the VS.NET window after delivering the command. Previously I had been using a hack in my .emacs, to iconify emacs (i.e. put it at the bottom of the pile of windows) after delivering a command.

Updated 1 Sep 2008 I'm told by Christoph Conrad that DevEnvCommand is an ideal companion to VisEmacs: "VisEmacs is a Visual Studio Add-In that allows Emacs to be integrated as the default text editor. It will be used instead of (or in addition to) the Visual Studio built-in editor. " Sounds good to me, though I haven't tried it myself yet.

Perspective Shadow Maps

Here's some sample code:

shadowbuffer.cpp | shadowdraw.vsh | shadowgen.vsh | shadwbuf.psh

It's based on the Microsoft Xbox shadowbuffer sample program, modified to include the extra perspective transformation described in this nice paper by Marc Stamminger and George Drettakis at REVES - INRIA.

It's quickie demo code, it's D3D, and there are plenty of things about it that aren't great, but hopefully it should help answer some basic practical questions.

Screenshots: 1 | 2


When I got sick of writing HTML for my web site, I experimented with other stuff. I flirted with PHP (http://www.php.net) and even went as far as to install and use TWiki (http://twiki.org) for a while. Those are good tools in their domain, but none of the experiments was totally satisfying for me, so I finally built a Perl script to implement my idealized notion of web-site maintenance -- old skool plain-text markup. When you need super markup powerz, you just seamlessly drop into scuzzy old HTML .

Behold Textweb. Feel free to steal it (and send me bug fixes).

Chunked LOD

My Chunked LOD project is coming along pretty nicely, so I've split it out onto its own ChunkedLOD page. Synopsis: fast out-of-core terrain rendering, no pops, public-domain code.

Some Lua stuff

Lua is a very nice little embedded scripting language; in addition to being small and relatively fast (for a dynamically typed interpreted language), IMO it's almost a perfect minimal functional language. It's a lot like Scheme in many ways, but using ultra-intuitive hash tables and a friendly syntax instead of s-lists. Anyway, check it out for yourself at http://www.lua.org .

Where I come into this is with a couple of Lua hacks I did:

Here are my notes and Here's a link to source, Windows .exe and data. You can write your own little 2D games in Lua using this package, which I have to say is pretty fun. Here's a screenshot of my sample game: screenshot

update see LuaCheia for an updated, maintained version of all this, and much more.

Game Programming Gems

Hey, check it out... I've got a chapter in the new book, Game Programming Gems. My contribution is on a spatial partitioning technique called "loose octrees". If that sounds exciting to you, you may want to browse my geek stuff, and of course buy a couple copies of the book.

Terrain texturing info

Here're a bunch of miscellaneous emails on quadtree tiling / unique full-surface texturing.

Adaptive Quadtree LOD article and demo, w/ source

I wrote an article for GamaSutra about terrain representation and rendering using adaptive quadtrees.

In case you missed it on my home page, here's a link to my GamaSutra article Continuous LOD Terrain Meshing Using Adaptive Quadtrees. Also, here's a link to the demo source and exe -- it's easy to miss the link from the article.

Quickie millisecond timer code for both Win32 and Linux

Here's a little module that provides a millisecond timer. It can be compiled for either Win32 or Linux. Under Windows, it uses the timeGetTime() function, which is actually precise to ~2ms on my Win98 box (plenty good enough for game timing, in my experience). Under Linux (tested on RH 6.1, kernel 2.2.12-20), it appears to be pretty close to an ideal millisecond timer.

Important: if you're porting a game from Windows to Linux or vice-versa, do yourself a huge favor and try SDL, an open-source cross-platform library that gives you a consistent porting layer across a bunch of OS's (including Windows, Linux, Mac, BeOS). Not only that, but in my experience it's exactly 10 times easier to use than the typical native APIs like DirectDraw or X, so it's worthwhile even if you don't care about portability. Loki's Linux versions of commercial games (http://www.lokigames.com) like Quake III use it.

Note: this code sucks under NT and Win2K; it gives like 10ms accuracy -- use SDL instead. On second thought, just switch to Linux.

Mailing list for indie developers

Pretty dead, but maybe you want to revive it: ---

Note: 2005-06-26 I deleted this list; for the past couple of years it has had no legitimate traffic and occasional spam. RIP.

Spatial Partioning with "Loose" Octrees

Occassionally the topic of spatial partitioning w/r/t culling comes up on various programmer forums I participate in. Over the years I've written a few emails and postings about a method I've found pretty useful. Here are some excerpts from those posts for your reading enjoyment:

Loose octrees

I wrote up a clearer article with real diagrams for the book Game Programming Gems, edited by Mark DeLoura. It's a hefty tome with around 70 articles from 40 authors, and it would probably come in handy if you're into game programming.

A sample C++ style guide

I wrote a style guide a few years ago, with some input from coworkers, for our small programming team (~4 coders) when I worked for Tectrix. I recently unearthed it on my hard drive, and it's not too bad. If you find yourself needing to implement some style standards for a small team, maybe this is worth a look. I wouldn't change much if I were writing it again today; the main thing would be to add some comments on C++ namespaces, which are pretty worthwhile in my opinion.

Link to HTML version of the Style Guide

Multithreaded game-update loop

Here are some excerpts from the main update loop of Soul Ride. The interesting feature is that I start a separate thread for collecting input, so that the input is always sampled at at least 30 Hz, whereas the rendering can go as slowly as 2 fps (obviously not recommended :) without disturbing the game physics and logic. For reasons you might want to do this, consult DejaNews _(I guess that would be http://google.com now)_ for a thread in comp.games.development.programming.misc entitled "Game Syncronisation" [sic], that started in late 1998. There are also some prior, similar, threads on the same topic that are interesting.

Link to snippets of the C++ source code

The code all came out of my main loop module. It's excerpted, so it doesn't compile as is; you'll have to read it and adapt to your own use. All the comments that start "// [meta]" are explanations of what the following code is and where it came from. Everything else is just copied directly from working code.


PSD plug-in for 3DS Max

I wrote a plug-in for 3DS Max that enables Max to read and write Photoshop .PSD files. It's not too complicated, and it may be full of bugs, but it works for me. It can read compressed bitmaps, but it only writes uncompressed.

Link to the plug-in binary

Link to the source and makefile

(This stuff is ancient.)

C++ code to read .PSD bitmaps

(Photoshop 2.5 format, including the alpha channel)

The above Max plug-in is based on this code, but I'm including it here because it's probably easier to understand and adapt, since it doesn't have all the Max plug-in trappings.

Link to psdread.cpp

Yet Another Max Plug-In, a geometry exporter

The only interesting thing about this code, beyond the .DXF exporter it's based on, is that it deals with retrieving texture map information, including sub-textures if they exist, from Max meshes. It took me a few hours to figure out how to do that, so maybe this is useful. It only looks for diffuse maps (and also diffuse color), and is completely oblivious to lighting, so don't be alarmed if the results look a little bland :) (I'm not including a binary since the format is totally arbitrary to my project and hence useless to anyone else.)

Link to the source and makefile

Important: Don't use this code! Aside from being really old, there's much better free source available: go directly to http://www.codercorner.com/Flexporter.htm , the project page for Pierre Terdiman's very cool Flexporter. Lots of other good stuff on that site, too.

tu@tulrich.com |