Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How can I speed things up?

Author
Message
FieldDoc
23
Years of Service
User Offline
Joined: 30th May 2003
Location: London, UK
Posted: 18th Sep 2003 18:55
I am working on an Isometric map editor (IsoME). I have a confession to make, the FPS shown in the program if you try it aren't entirely accurate , the true figure is 10 less. That means I am only getting about 10 FPS which, needless to say is rubbish. I have found that if I completely get rid of all the LINE and BOX commands that make up the GUI, I still can only get around 25 FPS. Here is a snippet of the main draw routine:



Is this code destined to be painfully slow? Is there any way to improve the speed?

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Sep 2003 20:26
Ok, here are a few things to consider in order of priority ...

1) Tile visibility - if the tile isn't going to be seen, why draw it?
2) Tile size - The bigger the tile the more efficiently it will be drawn. Try using a tile size of 64x64 instead of 32x32.
3) Precalculate - all those numbers that you are generating in the middle of your loop could be easily precalculated outside the loop and held in an array.
Codger
23
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 18th Sep 2003 20:53
To get your GUI back at very low overhead try the following

If your GUI is fairly static i.e. only changes upon user input try the following approach

make a plane textured object locked in place on screen

using a timer routine or only when user does something that modifies GUI

Create a bitmap
draw GUI to bitmap
capture image
texture GUI object

Locked textured object use 0 CPU time and your graphics card will fly thru them.

System
PIII 650 MZ H.P. Pavillion
394 Mem GeForce 4 400MX
FieldDoc
23
Years of Service
User Offline
Joined: 30th May 2003
Location: London, UK
Posted: 19th Sep 2003 02:52
Thanks guys, i'll give those suggetsions a try tomorrow.

@IanM:
I will remove the math from the loop as you suggested. I am already using 64x64 tiles though so I probably can't make them any larger. I'm not sure how to go about only drawing what is on screen.

@Codger:
If I don't have any luck with IanM's suggestions i'll try yours. I have remmed out the GUI at the minute but I still only get 25 FPS, so I'm guessing it's the draw routine that's letting the team down.

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 19th Sep 2003 03:07 Edited at: 19th Sep 2003 03:08
Well, there are two ways ...

Calculate the position and if it doesn't hit the screen don't draw it ... that works out slightly faster than calling the PASTE IMAGE command.

Or a little harder but much better is this - If you can work out the first tile that gets drawn in each row, you know the rest of the row. If you know the first tile that gets drawn in the top left, you know the entire column, and therefore the rows for each tile in that column. Find the first one and you have the whole display.

It may take a little experimentation to get it right, but it should pay off quite well, because you remove all decisions from your loops and replace it with simple additions and divisions

Login to post a reply

Server time is: 2026-07-25 07:01:48
Your offset time is: 2026-07-25 07:01:48