Hi
I've created some complex geometry using a class which I'd like to render to an off screen buffer using PGraphics in order to capture the image and use it as a texture that I then map to lower complexity geometry in the main draw function. I've been having problems getting the class to display within the PGraphics object.
I've boiled it down to the simplified code below. As you can see I'm trying to display two ellipses. One that is drawn simply using the ellipse() function from within the PGraphics context displays just fine. But my object that attempts to render its output using exactly the same code doesn't display. I've tried prefixing the object instantiation and render() call with 'offscreen.' but these throw an error.
Any ideas on how I can use a class to output to a PGraphics display area? I'm using 2.0b7 by the way.
Many thanks for any assistance
Matt
- PGraphics offScreenBuffer;
- Circle myCircle;
- int bufferDimensions;
- void setup() {
- size(1000, 600, P3D);
- noStroke();
- smooth(5);
- bufferDimensions = 200;
- offScreenBuffer = createGraphics(bufferDimensions, bufferDimensions, P3D);
- offScreenBuffer.beginDraw();
- offScreenBuffer.noStroke();
- offScreenBuffer.smooth(5);
- myCircle = new Circle();
- offScreenBuffer.background(255, 128);
- offScreenBuffer.translate(bufferDimensions/2, bufferDimensions/2, 0);
- offScreenBuffer.fill(255, 0, 0);
- offScreenBuffer.ellipse(-50, 0, 40, 40);
- myCircle.render();
- offScreenBuffer.endDraw();
- }
- void draw() {
- background(100, 100, 100);
- translate(width/2, height/2, 0);
- rotateY(mouseX/200.0);
- image(offScreenBuffer, -bufferDimensions/2, -bufferDimensions/2);
- }
- class Circle {
- Circle() {
- }
- void render() {
- fill(0, 0, 255);
- ellipse(50, 0, 40, 40);
- }
- }
1