Updating only parts of the screen
In my current project (which uses Cocoa) I am trying to make it only update the part of the screen that needs updating. So what I do is use NSUnionRect to get the rect of where the sprite was and where the sprites is. I use NSRectFill to clear that area and then use [backgroundImage compositeToPoint:spritePoint fromRect:unionOfSprite operation:NSCompositeSourceOver]. This greatly speeds it up (adds about 50 frames) but there is a white box around the sprite, as if the background didn't copy to all of the rect. Did I make sense? Anyone know what I am doing wrong? Where can I find examples of only updating parts of the screen?
First off, I'd suggest not using cocoa quartz.*|
If I understand correctly, you're doing the following:
NSRectFill() to erase the sprite and it's new location.
[NSImage compositetopoint] to fill the erased rect with background.
then finally, [NSImage compositetopoint] to draw your sprite.
if this is the case, then your last sprite composite is probably not copying with alpha transparency. So what you need to do is make sure the NSImage you're drawing has a valid alpha and that you're using the right compositeop. Using disolve to point draws alpha transparency by default, I think; you might want to try that.
If you eventually find (as I did) that Cocoa and Quartz are too slow, might I suggest my SDK? <shamlessplug> http://www.variableaspect.com/experiments/CocoaBlitz </shamelessplug>
If I understand correctly, you're doing the following:
NSRectFill() to erase the sprite and it's new location.
[NSImage compositetopoint] to fill the erased rect with background.
then finally, [NSImage compositetopoint] to draw your sprite.
if this is the case, then your last sprite composite is probably not copying with alpha transparency. So what you need to do is make sure the NSImage you're drawing has a valid alpha and that you're using the right compositeop. Using disolve to point draws alpha transparency by default, I think; you might want to try that.
If you eventually find (as I did) that Cocoa and Quartz are too slow, might I suggest my SDK? <shamlessplug> http://www.variableaspect.com/experiments/CocoaBlitz </shamelessplug>
---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| updating to ios5 recorder doesn't work anymore | sefiroths | 3 | 3,242 |
Nov 21, 2011 03:56 AM Last Post: sefiroths |
|
| About object creation, updating, interactions, Unity | Najdorf | 26 | 7,757 |
Jan 12, 2010 04:40 PM Last Post: AnotherJake |
|
| Updating Map Annotations - coordinates | PHANTOMIAS | 0 | 2,192 |
Dec 8, 2009 08:39 AM Last Post: PHANTOMIAS |
|
| Browser Based.. Updating turn times? | guest_05 | 1 | 2,615 |
May 24, 2007 04:03 PM Last Post: Tobs_ |
|
| Parts of C++ not linking properly? | Jones | 15 | 4,767 |
Jun 22, 2006 11:12 AM Last Post: Jones |
|

