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.

2D All the way! / Dot command causes program to run slow. Any ideas?

Author
Message
Urist McCoder
18
Years of Service
User Offline
Joined: 27th Sep 2005
Location: At the computer.
Posted: 19th Feb 2011 20:21
I was bored yesterday, so I started writing a little 2d game which I had an idea for. Unfortunately, the game runs really slow. Maybe I shouldn't call it a game because it doesn't actually do anything yet, but I was wondering if anyone had ideas to speed it up. It draws the screen using the dot command over and over to show what materials are where, but this causes a ridiculous drop in FPS. Can anyone think of a way to make it work better?
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 19th Feb 2011 22:21 Edited at: 19th Feb 2011 22:23
are you locking the buffer before and unlocking it again after drawing the batch of dots ? - If not, then that's a likely suspect.

Urist McCoder
18
Years of Service
User Offline
Joined: 27th Sep 2005
Location: At the computer.
Posted: 20th Feb 2011 23:17
Um. What do you mean by locking and unlocking the buffer? I'm pretty un-knowledgeable about programming, so that was mostly gibberish to me...
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 21st Feb 2011 00:46
The 2D commands like dot for example, have to lock the buffer prior to drawing any pixels and then unlock it once they're done. The lock/unlock process can be fairly slow, much slower than the drawing the pixel in this case.

You can control this behavior yourself however, by using the lock pixels & unlock pixels commands to manually lock/unlock the bitmap you're drawing to..

So if you're drawing a lot of dots in a loop, then you manually the lock the buffer prior to entering the loop and unlock once you're done..

Some like this for example,



Bandito_Walrus
13
Years of Service
User Offline
Joined: 19th Nov 2010
Location:
Posted: 8th Mar 2011 18:39
Hey... does this same thing apply to the Sprite commands? Because, if so, this might solve a slowness problem that I have been having in my own project.

Randomly viewing forum posts that solve my problems FTW!! =|:}D

A Graceful Harmony of Video Games and Insanity:
BanditoWalrus.com
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 11th Mar 2011 05:54
Quote: "Hey... does this same thing apply to the Sprite commands?"


Haven't tested that, but it'd be unlikely to give any performance benefit for Sprites.

Login to post a reply

Server time is: 2024-04-20 12:29:37
Your offset time is: 2024-04-20 12:29:37