We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Getting default PGraphics as variable
Page Index Toggle Pages: 1
Getting default PGraphics as variable? (Read 651 times)
Getting default PGraphics as variable?
Oct 30th, 2009, 11:31am
 
So I know I can make an offscreen buffer ala
buf = createGraphics(width,height,P3D);
buf.beginDraw();

etc-- but if I'd like a function that will either draw to an offscreen buffer OR the main buffer (understanding that the offscreen needs the explicit beginDraw/endDraw), is there a variable or function to access the "default" PGraphics?
Re: Getting default PGraphics as variable?
Reply #1 - Oct 30th, 2009, 12:09pm
 
Assuming that you have I understand you correctly then the following might help. (I have not tested the code but I don't think it is far off a solution)

Code:

PGraphics3D p3dg;

void setup(300,300,P3D){
  p3dg = (PGraphics3D) g; // Get the graphics object
  buf = createGraphics(width,height,P3D);

 draw(p3dg); // draw to main buffer
 draw(buf); // draw to off screen buffer
}

void draw(PGraphics3D g3){
  g3,beginDraw();
  // ... draw with g3
  g3.endDraw();
}
Re: Getting default PGraphics as variable?
Reply #2 - Oct 30th, 2009, 1:27pm
 
It has been discussed in this post :
http://processing.org/discourse/yabb2/num_1214781848.html

Code:
PGraphics defaultPGraphics = g; 

Page Index Toggle Pages: 1