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 › drawing OPENGL off-screen
Page Index Toggle Pages: 1
drawing OPENGL off-screen (Read 562 times)
drawing OPENGL off-screen
Apr 30th, 2006, 5:41pm
 
Although the following code works for PGraphics3 it doesn't with PGraphicsGL:
Code:

import processing.opengl.*;
PGraphicsGL graphic;
void setup(){
size(400, 400, OPENGL);
graphic = new PGraphicsGL(width, height, this);
graphic.defaults();
graphic.background(255);
}
void draw(){
graphic.line(0,0,width,height);
image(graphic,0,0);
}

I want to be able to use smooth(), hence the need for a PGraphicsGL but I'm getting the following error:
Code:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at processing.opengl.PGraphicsGL$ImageCache.rebind(PGraphicsGL.java:882)

I'm guessing that because I can't find an implementation of PGraphicsGL on the forum there must be some voodoo involved to get it to work.

I basically just want to be able to draw something flat (no translation or matrix stuff) on to an off screen image but using smooth().
Re: drawing OPENGL off-screen
Reply #1 - May 1st, 2006, 1:33pm
 
it's not possible to use the opengl library offscreen, sorry.
Re: drawing OPENGL off-screen
Reply #2 - May 11th, 2006, 12:11am
 
A thought:
What if you draw to the main GLCanvas as usual and then use glReadPixels to get the data back out (storing it in a PGraphics, for example). A lot of pixel-moving i know, but if fps isn't particularly important it might work.
Re: drawing OPENGL off-screen
Reply #3 - May 11th, 2006, 12:41am
 
I tried using copy() for a while but that was really heavy work.

I've changed tack now and I've decided my 'background' is going to remain an interactive part of the project.

Thanks anyway though.
Page Index Toggle Pages: 1