PDA

Click to See Complete Forum and Search --> : Please advice on my DirectX programming


007shahid
Dec 16th, 2001, 10:37 PM
I have made a small project using DirectX. It uses Direct Draw to blt frames from a bitmap based on the input keys. I just want you guys to check my source code and tell me if it is programmed in an optimized form or I can still make improvements.
One major improvement would be memory management. Every time I run the program my memory page size increases by about 42mb. How do I remove the memory allocated for my program

The compressed size of the bitmap even in GIF format was 163 kb, so I had to split the file in 2 attachments due to the limitations of this site.

007shahid
Dec 16th, 2001, 10:42 PM
Here is the second half of the sprite bitmap. Open actionpic0.bmp from the previous zip file. Increase the height attribute to 980pxl.
Paste the bitmap in actionpic1.zip to the new area and Save as 'actionpic.bmp' in project directory. Sorry for the inconvenience.

actionpic0.bmp + actionpic1.bmp = actionpic.bmp (In App.Path)

Jotaf98
Dec 18th, 2001, 06:29 AM
Yeah, that's right: I spent 15 minutes debugging someone else's code :D

Anyway, your code is fine, except that you're setting the width and height of the image, which is not needed if you don't use the width/height caps. The problem is that your image is too big for the graphics card - I tried a smaller image and it worked fine :)
So remove those empty spaces in the image if you really wanna use it :p

Jotaf98
Dec 18th, 2001, 06:30 AM
Btw, you also forgot to set the color key for the sprites ;)

007shahid
Dec 18th, 2001, 10:41 AM
Thanks.
Anyway what about the memory page size problem. Can I remove the virtual memory allocated for it.
And about the setting the Color Key, I found a link in vbexplorer.com about make sprite have transparent background. But It linked me to an article on setting 16-Bit Colors.
Can you please give me the Syntax for setting the color key for transparent background.

007shahid
Dec 18th, 2001, 10:55 AM
OK no problem on Setting Color Key to make a color transparent. I found the answer from some of your other posts in this matter.

Jotaf98
Dec 18th, 2001, 01:01 PM
To make the surface smaller you just have to remove the spaces around the frames, Paintbrush is enough to do that, you don't need PSP or something :p

Sastraxi
Dec 18th, 2001, 02:57 PM
If the image is too large to fit in Video Memory (as yours was) it's stored in the slow system memory (the swap file). Using a smaller image helped, as Jotaf said. It let your computer store the image in actual video memory instead of virtual memory.