PDA

View Full Version : Caching Tiles



Gadget
28-05-2003, 09:25 AM
Can anyone tell me if this is a good or bad way of approaching my tile based engine...

I decompress images from my own image library file, and store each image in a TBitmap array. The tiles are all 64 x 64 or 32 x 32 16 bit.

When I need to blit a tile, I simply get a pointer to the TBitmap and use that to blit to the DX surface.

I have tested the client so far on about 30 PCs and it runs well, but I have hit a problem on 2 PCs where it fails while loading the image library into TBitmaps. The image library is only about 1Mb in size so far, so that isn't too big.

Ideas / Comments please. I did wonder if a TBitmap used GDI memory?? Could that be the problem? Ideally I would prefer to store the raw pixel data and just blit that to the DX surface, but it needs s DeviceContext to blit, and I am not 100% sure how DCs work.

Zanthos
30-05-2003, 05:34 PM
I'm not sure what you're using DirectX headers(7,9a) or DelphiX, but the method you're currently using is good and not good :)

TBitmaps will use windows GDI system memory, which isn't well suited for DirectX.

The way I would do it in your case would be to decompress the images directly into DirectDraw surfaces in an array, the images being ideally stored in video memory.

You will see a significant speed increase from using direct draw surfaces in video memory blitting to the back buffer/primary surface.

Oh, the good bit about the method is that the images are compressed :wink:

Gadget
01-06-2003, 05:09 PM
I'm not sure what you're using DirectX headers(7,9a) or DelphiX, but the method you're currently using is good and not good :)

TBitmaps will use windows GDI system memory, which isn't well suited for DirectX.

The way I would do it in your case would be to decompress the images directly into DirectDraw surfaces in an array, the images being ideally stored in video memory.

You will see a significant speed increase from using direct draw surfaces in video memory blitting to the back buffer/primary surface.

Oh, the good bit about the method is that the images are compressed :wink:

Thanks :) I changed it today, and it seems to fix the crash that was occuring on some ATI cards. But I can't seem to get them to load into video memory?? I need to debug it to find out why, it can't be a memory size limitation as I am using 16Mb max in images so far.

Zanthos
01-06-2003, 07:29 PM
I'm presuming you're using this line for your surface caps:

dwCaps := DDSCAPS_OFFSCREENPLAIN or DDSCAPS_VIDEOMEMORY;

There may be forces at work which you can't control, which is the entire premise behind DirectX :)