|
-
Apr 5th, 2002, 06:12 PM
#1
Thread Starter
Fanatic Member
[Resolved] Too slow (BitBlt)
Is there any way I can speed this up?
VB Code:
Private Sub GameLoop()
Do Until boolPlay = False
DoEvents
intX1 = intX1 + 5 * intLevel
intY1 = intY1 + 5 * intLevel
'put the background on the form
RetVal = BitBlt(Me.hDC, 0, 0, picBack.ScaleWidth, picBack.ScaleHeight, picBack.hDC, 0, 0, SRCCOPY)
'picBuffer.Cls
'put the sprite on the form
RetVal = BitBlt(Me.hDC, intX1, intY1, 67, 79, picSprite.hDC, 67, 0, SRCAND)
RetVal = BitBlt(Me.hDC, intX1, intY1, 67, 79, picSprite.hDC, 0, 0, SRCPAINT)
'copy the buffer to the form
'RetVal = BitBlt(Me.hDC, 0, 0, picBuffer.ScaleWidth, picBuffer.ScaleHeight, picBuffer.hDC, 0, 0, SRCCOPY)
frmMeteor.Refresh
Loop
End Sub
I used to use a buffer but that only slowed it down even more...
Last edited by McCain; Feb 17th, 2003 at 07:12 PM.
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
-
Apr 6th, 2002, 06:14 AM
#2
PowerPoster
Looks like it should be going pretty fast there.
Are you recording how fast it is?
(To do this use the gettickcount API call to time how fast the loop executes).
You could get rid of the "RetVal = " if you're not using the variable for anything.
Gentile or Jew,
O you who turn the wheel and look to windward,
Consider Phlebas, who was once handsome and tall as you...
-
Apr 6th, 2002, 09:02 AM
#3
Addicted Member
Theres a few things you can do.
Your Blting everything everytime. you should try to blt only things that have changed (much harder to code, much, much faster to run).
nearly all professional game titles use this "dirty rectangle" method. and you should use a buffer to avoid flicking.
Rewriting in DirectX 7 will speed things up aswell.
Some Days, i just get this feeling that i'm helping to write dozens of Viruses...
-
Apr 7th, 2002, 03:40 AM
#4
Thread Starter
Fanatic Member
Thanks for the help.
I'll do what you've told me and we'll see if I can notice any better performace.
It's probably the background that slows it down the most it think. It's 1024x768 - guess it's pretty hard work for the computer to blit that every time...
Would it be faster to just blit parts of the back to where things used to be? (Like if I have a sprite that's 32x32 pixels at the coordinates 100, 100 then move the sprite 10 pixles to the right. Would it be faster to just blit the 10x32 piece of the background that was covered before of would the calculations take more time then we save on the smaller blit?)
Hope I made sence...
How would I use the GetTickCount to get the speed of the loop?
Last edited by McCain; Feb 17th, 2003 at 07:11 PM.
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
-
Apr 7th, 2002, 04:46 AM
#5
Hyperactive Member
I made a map editor That uses Bitblt
NEARLY full screen( Maximize the editor) and I get 65 FPS.
using 16x16 tiles at 1024x768 with GeForce 2 GO
I've optimized the file size, AND code...
Something that I found that helps a LOT
somewhere make a variable at the top of the forum
Private FormHDC as long
in form resize
FormHDC = Me.HDC
Then in your code, replace Me.HDC with FormHDC
THIS WILL INCREASE SPEED, probably a BUNCH
NOTE: You put the FormHDC = Me.HDC under formResize because it *HAS* to be called everytime the source HDC changes (the form, in this case)
plus, on Form_LOAD, it calls the form_resize sub, also so no need to put it in form_load
killing two birds with one stone on that one.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|