Re: Faster drawing sprite and background
Re: Faster drawing sprite and background
- Subject: Re: Faster drawing sprite and background
- From: jean-michel daix <email@hidden>
- Date: Mon, 08 Oct 2001 18:34:59 +0200
Thank you all for you help.
This 3 lines made my day :
- (BOOL)isOpaque {
return YES;
}
My fps jumped from 28 to 78. It was exactly what I was looking for.
For those who are interested by this topic, take a look at the CircleView
example in Developer Example folder. (I forgot it in my search).
>
On Monday, October 8, 2001, at 01:19 PM, jean-michel daix wrote:
>
>
> I'm using a NSView based Cocoa application basicely drawing a
>
> background and
>
> a sprite. My problem is "drawRect". My background is a 640x480 image
>
> and so
>
> it can only be drawed about 12 time by second on my G4 400 (12 fps). I
>
> don't
>
> want to redraw all my background all the time for sure, I just want to
>
> redraw the sprite and a part of the background. But, tell me if I'm
>
> wrong,
>
> "drawRect" is made to redraw all the content of the NSView.
>
********************************************
>
Sometimes you get better repeated drawing performance with bitmap images
>
if you call [image lockFocus]; [image unlockFocus]; once to force the
>
image to create a cache (at least if you use composite... operations).
>
Otherwise the image may be doing format conversions etc every time it is
>
composited.
>
>
Regards.
>
John Hornkvist
>
********************************************
>
I think its parameter though is the dirty bounds that needs to be redrawn,
>
so that would be at least one for of optimization. If your drawRect
>
method also draws all of the view's contents, then override the isOpaque
>
method and return YES.
>
>
Although, if you need high fps rates, I strongly suggest looking into
>
OpenGL...it's not just for 3D.
>
>
HTH,
>
>
Rick Sharp
>
Instant Interactive(tm)
>
********************************************
>
That depends on the particular implementation of -drawRect:. As it
>
happens, a lot of developers don't bother to use the given rect to limit
>
the amount of drawing they have to do.
>
You might want to look into using the NSCell class.
>
-jcr