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 › Using both OPENGL and P2D, in the same applet
Page Index Toggle Pages: 1
Using both OPENGL and P2D, in the same applet (Read 369 times)
Using both OPENGL and P2D, in the same applet
May 27th, 2009, 6:53am
 
Hello everybody,

First of all, I'm french, so my English may be hardly understandable. Don't hesitate to correct me:)

I'm working on a small processing applet, and I would like to divide the applet between two (or even more) areas:
One zone (the top half part of the applet) using an OPENGL renderer dor 3D animations, and the other zone (bottom half) using a P2D applet.

Is this possible? It seems to be possible with use of PGraphic, but I don't understand how to do this.

The classical way to use 2 renderes is like this example:


Code:


import processing.core.*;

public class Test extends PApplet {

private PGraphics g1, g2;

public void setup() {
size(400,400);
g1=createGraphics(400, 200, P2D);
g2=createGraphics(400, 200, P3D);
}


public void draw() {
g1.beginDraw(); {
g1.rect(10, 20, 100, 80);
} g1.endDraw();
image(g1, 0, 0);
g2.beginDraw(); {
g2.background(0);
g2.fill(255);
g2.stroke(255);
g2.translate(100, 80);
g2.sphere(20);
} g2.endDraw();
image(g2, 0, 200);
}
}

This work well, the top middle of the screen show a 2D box, and the bottom one show a sphere on a black background

But when I try to remplace P3D with OPENGL, This doesn't work anymore! The OPENGL graphic recover the whole applet...

Does anybody has any idea about this? I've spent some hours trying to fix it, and I haven't found any example or tutorial about this?

Some help would be great Smiley

Thanks

Amaury
Page Index Toggle Pages: 1