 |
|

02-18-2004, 02:53 AM
|
|
|
FPS with bitblt
|
|
Any good way of getting the fps while using the bitblt
|
|

02-18-2004, 03:31 AM
|
|
Regular
|
|
Join Date: Sep 2003
Location: Manchester, England
|
|
How are you drawing frames? With a timer I presume?
in that case just have a variable say Frames and add to it every frame, and have another timer displaying it.
Code:
Dim Frames as Integer
Private Sub Gameloop_Timer 'set to whatever fps you want
'code
Frames = Frames + 1
End Sub
Private Sub Frame_Timer 'set to 1000ms
lblFramesPerSecond.Caption = Frames
Frames = 0
End Sub
If you wanted a more accurate timer you could use a high-resolution windows or CPU timer...but I doubt that's necessary in anything less than a proper dev environment when you're testing optimizations or something.
|
__________________
Currently working on:
Gdi32
|

02-18-2004, 04:17 AM
|
|
|
|
|
Ok i did the fps, but i was using a loop for drawing and moving objects, but i got only 10fps
my computer is a XP2500 512mb and a geforce fx 256mb
is this right?
|
|

02-18-2004, 04:18 AM
|
 |
Junior Contributor
|
|
Join Date: Oct 2003
Location: Washington, USA
|
|
It depends on how much you are drawing and how effecient your coding is. From what I know about your project, cant really say.
|
__________________
vbGORE :: Opensource Online RPG Engine
|

02-18-2004, 04:26 AM
|
|
|
is there a more effiecent way of refreshing the screeen, instead of just typing refresh?
|
|

02-18-2004, 04:42 AM
|
|
Regular
|
|
Join Date: Sep 2003
Location: Manchester, England
|
|
So you have a never ending loop that just refreshes the form?
that sounds like a bad idea, but even with inefficient code, 10 fps sounds a bit low, for that spec.
Do a game loop that's regulated by a timer, and manually blit to the screen, don't use something like Refresh.
Your code might work now but if you use a proper method (backbuffer, blit to screen) you should technically be able to get loads of frames per second, and it'll be much easier to implement new features.
could you post/attach some code?
|
__________________
Currently working on:
Gdi32
|

02-18-2004, 04:43 AM
|
|
|
|

02-18-2004, 04:53 AM
|
|
Regular
|
|
Join Date: Sep 2003
Location: Manchester, England
|
|
ok, had a look.
First of all, you need a proper game loop. Having your game loop in form_load with just a Refresh command isn't good. It'll work, but it wont really work if you want to do more things.
Secondly I think the poor FPS is due to bitblt'ing 87000 tiles, lol. Why do you need so many?
|
__________________
Currently working on:
Gdi32
|

02-18-2004, 05:06 AM
|
|
|
its a rts game, and it only paints the tiles that r on the screeen,(that can be seen), i am using lots of tiles because of u can scroll around the map, if u move ur mouse to the edges u can scroll.
|
|

02-18-2004, 05:39 AM
|
|
Regular
|
|
Join Date: Sep 2003
Location: Manchester, England
|
|
ok, well I don't have time to check the drawing code but 87000 checks per frame is still excessive. You could do it an easier way that doesn't need to check all of the tiles, by just drawing a tile(x) where x is inside the screen...if you get my drift.
|
__________________
Currently working on:
Gdi32
|

02-18-2004, 07:43 AM
|
|
|
i cant understand y its so slow its only painting wats on the screen, which is 768 tiles i think, when i did this b4 when i only have 768 tiles for the array i got 60 fps, then i declare 76800 (100 times bigger for a bigger map) it goes really slow but its still only painting 768 sqaures at most.
- updated project
|
|

02-18-2004, 08:33 AM
|
 |
Joseph Koss
* Guru *
|
|
Join Date: Aug 2003
Location: Unfashionable End
|
|
Quote: Originally Posted by mathewmunro i cant understand y its so slow its only painting wats on the screen, which is 768 tiles i think, when i did this b4 when i only have 768 tiles for the array i got 60 fps, then i declare 76800 (100 times bigger for a bigger map) it goes really slow but its still only painting 768 sqaures at most.
- updated project
I believe its because all your tiles wont fit into video memory at the same time - How much memory do these tiles take up?
NumTiles*XRes*YRes*4bytes per pixel is a close enough estimation
|
|

02-18-2004, 10:37 AM
|
 |
Regular
|
|
Join Date: Dec 2003
Location: Golden, Co
|
|
i looked at the code and i cant find out whats wrong, but i have a idea for you to try.
increase the size of the tiles 64-64 (i get the most fps when its about that big - dont go any bigger or you will start to lose fps) and cut the number of tiles you have (i think it was 76816 tiles) in half.
i really dont see why you need so many tiles- thats 1229056 pixels to the right and down!!!
here is a class i made when i was reading Visual Basic Programming with DIRECTX, theres two of them one for WIn API and the Other for DD7, you cant really use the class becuase it requries the classes that came with the book, but im sure you can convert the API one very easily so you can use it im just givin it to you becuase you may wont to look at the way i made the map scroll add the clip formula too. just to warn you the API Map Class is the first one i maded and its very missy coding to.
if you have Q's about it please just email me ill be glad to help
P.S>
also about the clsMApAPI i was doing a test for anim Tiles (like the ocean moving etc.)it doesnt work right.
|
|

02-18-2004, 10:45 AM
|
|
|
I've made games with out a single control. You don't need timers to make a game, but instead use gettickcount or other hi-res timers.
|
__________________
SpeedPear
Enter the pear
----------------------------------
Aeon Nexus Games
|

02-18-2004, 11:49 AM
|
|
|
ive actually sorted it out now i get 300 fps, with that really big no for the tiles,
instead of doing
for n = 1 to 76187
if statement see if its on the screeen the paint it if not dont cos u cant see it anyways
bitblt ..
end if
next n
(this searches every single tile) reason y its so slow
this way its a bit tricky with numbers but i got it in the end, i cant explain (cosreally difficult to) but it gets the 1st tile that can be seen (top left corner) and i get the index of this and call it x1, and then i add the total no of tiles across the screen(wat i can see) then i call this x2
then i get y1, (y1 = x1)
and y2 = y1 + 311, (311 is total across the whole map)
then with these u can do a for n loop to just for the squares that u can see, it will miss the others out becuase they are b4 x1 and after x2 and same with y1 and y2. this stops me from having to check all 76187 tiles
have alook for urself, i will post the project. (btw the fps is lower cos i added a for n = 1 to 1000000:next n to slow it down a bit)
oh and btw thx for ur help guys, now i need to add tanks , biuldings and a AI, lot of work! 
|
|

02-18-2004, 12:11 PM
|
 |
MetaCenturion
Retired Moderator * Guru *
|
|
Join Date: Aug 2001
Location: South Carolina, USA
|
|
Perhaps you want to look at timeGetTime for your game loop, because using a timer and game loop is not good... and using a For loop as a frame limiter is also not good.
Ex:
If timeGetTime >= LastTick + MsDelay Then
LastTick = timeGetTime
'move game loop code here
End If
so if MsDelay is 1000 and you declare Public LastTick As Long, then you can move the timer code into this loop to get the FPS.

|
|

02-18-2004, 12:18 PM
|
|
|
r msdelay and lasttick functions or just variables u used?
|
|

02-18-2004, 12:20 PM
|
 |
MetaCenturion
Retired Moderator * Guru *
|
|
Join Date: Aug 2001
Location: South Carolina, USA
|
|
r?
oh, nevermind.
timeGetTime API is the only function there...
LastTick is a variable (I said to declare it as Long)
and MsDelay-- you can just change that to 1000 directly.
|
|

02-18-2004, 12:26 PM
|
|
|
i did it but now i get 2 fps, somet wrong, i post code, see wat i did wrong
Do
If GameOn = False Then
Unload Me
Exit Sub
End If
If timeGetTime >= LastTick + 1000 Then
LastTick = timeGetTime
ViewArea
PaintTiles
PaintMenu
CheckMousePos
MenuOver MX, MY
FPS = FPS + 1
Me.CurrentX = 0
Me.CurrentY = 0
Me.Print FPS
FPS = 0
DoEvents
End If
Loop
|
|

02-18-2004, 02:10 PM
|
|
Regular
|
|
Join Date: Sep 2003
Location: Manchester, England
|
|
That's what I meant about only drawing tiles on the screen
btw, if timeGetTime produces a time in milliseconds, than waiting until 1000 have elapsed = 1 second delay between frames. Try it on something lower.
|
__________________
Currently working on:
Gdi32
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|