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 Discussion / Print command is slow >.<

Author
Message
Ashingda 27
17
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 16th Dec 2008 19:14 Edited at: 16th Jan 2012 10:30
I wrote a simple code that prints 216 strings on the screen an it's giving me a pretty bad FPS rate of 42. Can someone else run it and tell what you're getting? Without using the Bitmap 1 my FPS will drop down to 32.



Is there a faster way to output strings onto the screen?

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 16th Dec 2008 20:38
Use the TEXT command.

Realize that with copying bitmaps back and forth, if you are updating the bitmap (bitmap 1 in this case) every iteration, you are still running processes and loops to make the updates possible. Your subroutine PrintList only outputs unique values once so it doesn't make sense to run that subroutine every iteration. In your code, you are not only updating bitmap 1 with information that doesn't change (except for the FPS) by calling gosub printlist every loop, but you are copying it to bitmap 0 every loop so you have a lot of extra stuff going on. This first example is just your version eliminating the bitmap swap and using the text command instead of print. I get about 95 to 100 fps this way and about 35 the way it was:



This code runs the printlist once on bitmap 1 then copies it into bitmap 0 each loop. Using text and this method I get 340+ fps:



Swapping bitmaps is great when you have a lot of static graphics or backgrounds that aren't changing. For example, say you made a paint program or something. At the top is a menu bar, on the right side are a bunch of buttons for functions, and on the bottom is a status bar. The rest of the screen is devoted to the drawing area. To keep processing down, the entire window (without any drawing) can be saved in a bitmap offscreen. Another bitmap can be saved offscreen that is the drawing area. When you start the app, you paste the main background bitmap ONCE with all of the buttons and what not in the non selected state. You then swap in and out the drawing area as you draw. The only time you swap in or out or update the main background is if you select a tool or use the menu or change something on it. Otherwise, you paste it once and only as necessary and the main modifications occur on the drawing area (be sure not to clear screen 0! Or else you'd have to paste the background every iteration).

Enjoy your day.
Ashingda 27
17
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 16th Dec 2008 22:27 Edited at: 16th Jan 2012 10:30
Wow text is so much faster than set cursor + print bahh, silly me. Thanks Latch.

Attachments

Login to view attachments
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 17th Dec 2008 22:32
@Ashingda
Don't take this the wrong way but I think you should go through TDK's basic tutorials. You seem to have a very sporadic knowledge; you are brilliant at some quite advanced stuff and yet come unstuck because of things you've skipped over. I was exactly the same, for example: I spend 4 days coming up with a very complicated function to position the camera behind a rotating spaceship (that only half worked) only to discover that SET CAMERA TO FOLLOW would do all of that for me!

A small program that works is better than a large one that doesn't.

DBC Challenge Rank: Rookie
Ashingda 27
17
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 18th Dec 2008 02:33 Edited at: 17th Mar 2013 21:12
Hmm it's true, I've been skiping on alot of stuffs. I'll take a look NOW

Attachments

Login to view attachments

Login to post a reply

Server time is: 2025-06-08 00:28:33
Your offset time is: 2025-06-08 00:28:33