We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm using the following code snippet (from https://amnonp5.wordpress.com/2012/01/28/25-life-saving-tips-for-processing/ - number 16) to export a scaled-up high resolution file. Everything works perfectly as long as size() and createGraphics() use the 2D renderer:
void setup() {
size(500, 500); // IMPLICIT USE OF 2D RENDERER
}
void draw() {
background(255);
smooth();
strokeWeight(10);
fill(255, 0, 0);
ellipse(width/2, height/2, 200, 200);
}
void keyPressed() {
if (key == 's') {
save("normal.png");
saveHiRes(5);
exit();
}
}
void saveHiRes(int scaleFactor) {
PGraphics hires = createGraphics(width*scaleFactor, height*scaleFactor, JAVA2D); // CREATION OF 2D PGRAPHICS OBJECT
beginRecord(hires);
hires.scale(scaleFactor);
draw();
endRecord();
hires.save("hires.png");
}
However, once the two bold lines use P3D instead (code at the end of this post), the program results in two problems: 1. The following error message appears: "OpenGL error 1282 at top endDraw(): invalid operation" (on Win7 with updated drivers) 2. Scaling doesn't actually happen - instead, unscaled image sits in the left bottom of the hi-res PGraphics object - like this:
The correct result should look like this:
After researching this, I couldn't find any high-resolution output for people working with a 3D renderer. I don't care so much about how to create hi-res output, and tried several approaches - without luck yet.
Any help would be greatly appreciated!
Here's the 3D version of the initial code snippet: void setup() { size(500, 500, P3D); // 3D RENDERER }
void draw() {
background(255);
smooth();
strokeWeight(10);
fill(255, 0, 0);
ellipse(width/2, height/2, 200, 200);
}
void keyPressed() {
if (key == 's') {
save("normal.png");
saveHiRes(5);
exit();
}
}
void saveHiRes(int scaleFactor) {
PGraphics hires = createGraphics(width*scaleFactor, height*scaleFactor, P3D); // CREATION OF 3D PGRAPHICS OBJECT
beginRecord(hires);
hires.scale(scaleFactor);
draw();
endRecord();
hires.save("hires.png");
}