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 › Question about PGraphics \ createGraphics
Page Index Toggle Pages: 1
Question about PGraphics \ createGraphics (Read 290 times)
Question about PGraphics \ createGraphics
Oct 12th, 2008, 1:06am
 
Searched the forms, couldn't find the answer to this:

I have a custom object that draws little circles, pretty simple.  I want to draw it to the screen, then to an off-screen buffer for some post-processing.  Then apply the buffer back to the main screen with some filters.

It SEEMS like PGraphics \ createGraphics would be the way to go.  However, it looks like the PGraphics object doesn't have any hooks into my custom class?

<example code snippets>
PGraphics buffer;
buffer = createGraphics(512,512,P3D);
buffer.beginDraw();
buffer.myObject.run();
buffer.endDraw();
</example>

It's not so happy with buffer.myObject.run(), since buffer seems to have no knowledge of my object.  And if I just execute 'myObject.run()' in the middle of the buffer calls, buffer doesn't get updated.

What to do?  How can I get createGraphics to execute my custom object?  Or is there a better method to get this to render to an off-screen buffer?

Many thanks!
Re: Question about PGraphics \ createGraphics
Reply #1 - Oct 12th, 2008, 1:13am
 
Heh, a few minutes after I sent this I came up with a solution.  But I'd be interested to hear if there are better\different ways:

I went into my object, and made a 'runBuffer()' method, that simply made all of its calls directly to the buffer object.  And that works.  Does mean a lot of code duplication though.  Anything better out there?
Re: Question about PGraphics \ createGraphics
Reply #2 - Oct 12th, 2008, 10:19pm
 
Does this thread help?

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Suggestions;action=display;num=1214781848
Page Index Toggle Pages: 1