Why is my blit going so slow?

Started by
9 comments, last by UberXenon 23 years, 10 months ago
OK, here's the deal. I'm writing a tetris clone as my first attempt at a Win32/DirectDraw game. So far, it's going pretty good. At this point, I have a single block on the screen that I can move around the screen with the arrow keys. I have a loop that locks the game at 30 FPS and a function that displays the current FPS in the upper left corner of the screen. When I only blit my single 24x24 pix block around the screen (clearing the screen between frames), it runs just fine at 30 fps. However, I also have a large 640x480 bitmap that I am using for the background of the game. This bitmap contains the layout of the game board, the "next" box, etc. When I blit this bitmap at the beginning of my game loop, the framerate slows to 3-5 fps! I have no idea what's going on. Should a full screen 640x480x8bpp blit be this expensive?!? I have a K62-400 and 32Mb TNT2 Ultra. Am I doing something really stupid here? This is really bothering me. You can get the source here. I compile under Visual C++ 6 service pack 3. The specific section of code I'm referring to is located in BlockBlasterEngine.cpp in function CBlockBlasterEngine::Main() Also, you have to use the standart Windows [alt]+F4 to exit the game, as I haven't added a "quite the game" feature yet Any help from you more experienced folks would be greatly appreciated. UberXenon Edited by - UberXenon on 7/10/00 4:50:49 PM
------------------------------------------------------------Four young warriors arrive, each holding an ORB...byrdjb@email.uah.edu
Advertisement
I only took a quick look at your code. i couldn''t find a main reason for that big lag that happens, but try these things:
1- don''t put all of the bitmaps in your resources. try loading them dynamically. that would redice the size of the .exe file (this dones''t help to improve the speed, it will just make your program smaller)
2- try using bltfast instead of blt. but again, blt shouldn''t be this slow...

----------------
- Pouya / FOO!!!
***CENSORED***
Hi, I have no idea why your game is so slow and I have no time to look at your code either; but I can tell you that I made a small game that uses several big bitmaps (the biggest was 800x600).

I have an PII-233 TNT2 ultra and I got 120fps ( it was flattend by my drivers though).
A friend of my has a PII-300 Voodoo Banshee and got more than 500fps.

So I gues you should be able to get frames like this (for what you are making) or something is very wrong with your code or your drivers.

The Rock
- BAD software -

http://members.spree.com/entertainment/bad_software
The Rock
on a pentium II 350 i have blitted around 2000 64x64 images + a big background of 800x600 (all 16bit color) at the rate of 60frames a sec (that was the monitor refresh rate, so it couldn''t go higher than that)


----------------
- Pouya / FOO!!!
***CENSORED***
ive seen this in this forum so many times , ppl locking the frame rate to a certain value. don''t do it.
heres code to tetris i wrote last week it should run at 200 fps on your machine the reason being it uses opengl instead of directdraw for the 2d stuff. only joking mate directdraw is quicker than opengl for 2d stuff.
http://members.xoom.com/myBollux/home.html
Thanks for all of the input so far. However, I still haven''t solved the problem. As far as what zedzeek said, I have let the main loop "run free"; I removed my StartClock and EndClock. When blitting only the single block, it runs at HUGE fps, but when blitting the background it still runs at only about 4 fps.

I looked in the DXSDK help, and it said that BltFast was only about 10% faster than regular Blt, and that was only for the software implementation. If Blt is accellerated in the HAL (which it almost certainly is), then the speed is the same. So, BltFast isn''t the solution to my problem either.

Any other ideas?
------------------------------------------------------------Four young warriors arrive, each holding an ORB...byrdjb@email.uah.edu
Set your Rect up like this before yout Blt:


Static RECT rectDest;
rectDest.top = 0;
rectDest.left = 0;
rectDest.bottom = 480;
rectDest.right = 640;


The bottom and right numbers are non-inclusive meaning they always have to be +1 from what you really want. Also code for the Esc key to quit. I had to reboot my machine to get out.

I ran the exe on my AMD550 w/nVidia Vanta. Got 29.99 FPS. There must be something up with your setup.
I once had a similar problem because my image was not the same bpp as the graphics mode I was using. You might check to make sure your graphic and the bpp of your surface are the same.

Ben
I ran your program and got 4-5 fps.

I took out the &rect on the blt and passed in NULL to blit the entire screen and I got the 29FPS.

Not sure if this helps, but gives you an idea where to look for your problem.

Anyone know of any limitation in DX to specify a rect to blt to on the destination surface, when your dest is the back buffer?

Just curious.

This topic is closed to new replies.

Advertisement