[SDL] [PATCH] Function to get desktop resolution

Jon Colverson sdl at vcxz.co.uk
Mon Jan 24 08:51:35 PST 2005


On Tuesday 04 January 2005 16:22, Bob Pendleton wrote:
> There are a lot of things that were done in DOOM that are not worth
> doing now. For example, DOOM used fixed point arithmetic, but modern
> processors (486DX and above) do floating point math very well, so there
> is no need to deal with fixed point arithmetic.

There are still some niches where fixed point is valuable. Whenever you need 
to store some vector that is supposed to have equally distributed precision 
across its entire range, and you're not doing seriously heavy math with 
this vector, you might want to consider fixed point.

In one 3D environment, I was reaching the range limits of the 32 bit float. 
Well, not exactly the range limit, but once you're too far from 0 (i.e. the 
world origin), the precision got so bad that round-off errors in simulation 
were unacceptable. There were two choices: Use double, which takes twice 
the memory, or store the actual coordinates as 32 bit fixed point. I chose 
the latter, and it works perfectly fine. Note that I still use float during 
the actual simulation, but that works out fine because during the 
simulation, only small (difference) vectors will be used.

To give a more well-known real-life example, Half-Life sends player 
coordinates as fixed point across the network. This is obviously done in 
order to save space while guarantueeing that the precision at which player 
coordinates are transferred is everywhere the same.

cu,
Nicolai
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050108/4092f884/attachment-0008.pgp>


More information about the SDL mailing list