Setting the clip, double buffering
Setting the clip, double buffering
- Subject: Setting the clip, double buffering
- From: Candide Kemmler <email@hidden>
- Date: Thu, 5 Jul 2001 11:50:42 +0200
Hi !
I don't find any clip-setting function for graphics, i.e. functions that
set a viewing rectangle outside of which all drawings are discarded.
As of double-buffering, until now, I just didn't care, but then now I
get this very annoying bug where I see a path drawn a fraction of a
second on the screen, then it disappears forever...
Are there any means to draw to an offscreen buffer before copying it to
the screen ? I'd like something like the following java snippet:
Image offImage;
Graphics offPort;
Dimension d:
public void update ( Graphics g ) { paint ( g ); }
public void paint ( Graphics g ) {
if ( offImage == null || d.width != getSize ().width || d.height !=
getSize ().height ) {
d = getSize ();
offImage = createImage ( d.width, d.height );
offPort = offImage.getGraphics ();
}
// drawing is done to the off-screen graphics:
offPort.setColor ( ... );
GeneralPath gpath = new GeneralPath ();
...
// now, we copy the image to the on-screen graphics:
g.drawImage ( offImage, 0, 0, this );
}
BTW, until now, there's no noticeable performance difference between the
Java drawing routine and the Objective-C/C drawing routine under Cocoa...
Regards,
Candide