render offscreen to second Applet (urgent)
in
Contributed Library Questions
•
2 years ago
i have to finish something tommorow so plz help
How can i render the offscreen to the second applet?
library http://keystonep5.sourceforge.net/
library2 http://glgraphics.sourceforge.net/
How can i render the offscreen to the second applet?
library http://keystonep5.sourceforge.net/
library2 http://glgraphics.sourceforge.net/
- import processing.opengl.*;
import codeanticode.glgraphics.*;
import deadpixel.keystone.*;
// this object is key! you can use it to render fully accelerated
// OpenGL scenes directly to a texture
GLGraphicsOffScreen offscreen;
Keystone ks;
CornerPinSurface surface;
// second window
PFrame f;
SecondApplet s;
void setup() {
size(640, 480, GLConstants.GLGRAPHICS);
//second window
PFrame f = new PFrame();
offscreen = new GLGraphicsOffScreen(this, 1024, 768);
ks = new Keystone(this);
surface = ks.createCornerPinSurface(1024, 768, 20);
}
void draw() {
// convert
PVector mouse = surface.getTransformedMouse();
// first draw the sketch offscreen
offscreen.beginDraw();
offscreen.background(50);
offscreen.lights();
offscreen.fill(255);
offscreen.translate(mouse.x, mouse.y);
offscreen.rotateX(millis()/200.0);
offscreen.rotateY(millis()/400.0);
offscreen.box(100);
offscreen.endDraw();
// then render the sketch using the
// keystoned surface
background(0);
surface.render(offscreen.getTexture());
s.background(0, 0, 255);
s.fill(100);
s.rect(10,20,frameCount%120,10);
s.redraw();
}
// Controls for the Keystone object
void keyPressed() {
switch(key) {
case 'c':
// enter/leave calibration mode, where surfaces can be warped
// & moved
ks.toggleCalibration();
break;
case 'l':
// loads the saved layout
ks.load();
break;
case 's':
// saves the layout
ks.save();
break;
}
}
public class PFrame extends Frame {
public PFrame() {
setBounds(100,100,1024,768);
s = new SecondApplet();
add(s);
s.init();
show();
}
}
public class SecondApplet extends PApplet {
public void setup() {
size(1024, 768);
noLoop();
}
public void draw() {
}
}
1