realbasic-games
[Top] [All Lists]

Re: Draw algorithm slow

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Draw algorithm slow
From: Joseph Nastasi <joe at pyramiddesign dot us>
Date: Tue, 29 Jun 2004 07:25:41 -0400
Delivered-to: realbasic-games at lists dot realsoftware dot com
List-help: <mailto:realbasic-games-request@lists.realsoftware.com?subject=help>
List-id: REALbasic Games <realbasic-games.lists.realsoftware.com>
List-post: <mailto:realbasic-games@lists.realsoftware.com>

On Monday, June 28, 2004, at 10:21  PM, Joseph J. Strout wrote:

At 10:01 PM -0400 6/28/04, Joseph Nastasi wrote:

Works like a champ but it is as slow as hell and I don't understand why. First, I am double-buffering (even on OS X - because I need to use the mask and I can't use Picture as a control) and this is a technique I used in A-OK! without an real issue.

Have you tried profiling it with Shark? If not, I would recommend this as a first step. Even if you don't have the developer tools, and think Shark is a large carnivorous fish, it will take substantially less time to download, install, learn to use, and get results from Shark than it will to find where all your CPU time is going any other way.

Yeah, I was going to do that.

Well, you're calling self.graphics and self.mask.graphics a LOT here. It may not be clear that these are methods that create objects -- objects that may well get destroyed when there are no further references to them. So, start by declaring g As Graphics (and perhaps mg, for the mask graphics) at the top of your routine, assign to them once, and use them for the rest of the function.

Didn't know that. I have to change that as well.


Also, it will help greatly if, right after you get these, you do g.useOldRenderer = true. Otherwise you're drawing with CoreGraphics, which is wasteful (and slow) for things like this.

I guess I have to hope Apple keeps that in the OS long enough for the level of machine speed to go up to compensate. :-)
Of course this does nothing for Windows.


The only other difference is that I am now using small graphics of needles (with masks) instead of drawing a line. This technique is used in many flight simulators, so there's nothing inherently wrong with the idea, but perhaps my execution.

I don't think most flight simulators are actually rotating a picture to draw the needle, as you're doing. Instead, they have pre-rendered needle images at all the orientations they care to draw (yes, there may well be quite a few of those). This is much faster, and often looks better too, since you can have them properly shaded and shadowed for each angle, which you can't do when simply rotating a picture.

I don't know. For example, both X-Plane and MS Flight Simulator only require that you create one needle graphic (and corresponding mask) for a gauge. Is it possible that they pre-rotate copies on startup?
--
Joseph Nastasi
Pyramid Design - a software development firm
http://www.pyramiddesign.us
Voice 609 601-0814      Fax 609 601-0815

Creators of FTP Suite for REALbasic
Creators of A-OK! The Wings of Mercury
http://www.youarego.com
Columnist for REALbasic Developer
http://www.rbdeveloper.com



_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>