I am new to processing and 3D and I have been trying to test renderer differences. I am wondering why the following code works with the default and JAVA2D renderers, but not with the P3D or OPENGL renderers. This particular code does not manipulate the shape in the Z-axis but I am trying to figure out why i can't use the P3D and OPENGL renders with this code, before adding more variables. Any help would be appreciated. Thank you.
Quote:
import processing.opengl.*;
int shapes = 100;
float[]speedX = new float[shapes];
float[]speedY = new float[shapes];
float[]x = new float[shapes];
float[]y = new float[shapes];
float[]w = new float[shapes];
float[]h = new float[shapes];
color[]c1 = new color[shapes];
void setup(){
size(500,500, OPENGL);
frameRate(30);
for (int i=0; i<shapes; i++){
x[i]=width/2;
y[i]=height/2;
w[i]=random(.1, .2);
h[i]=w[i];
c1[i]=color(random(255), random(255), random(255));
speedX[i] = random(-5, 5);
speedY[i] = random(-2, 2);
}
}
void draw(){
fill(255, 90);
rect(0,0, width, height);
for (int i=0; i<shapes; i++){
fill(c1[i]);
fontA(x[i], y[i], w[i], h[i], c1[i]);
x[i]+=speedX[i];
y[i]+=speedY[i];
if (x[i] > width-(64.01*w[i])){
x[i] = width-(64.01*w[i]);
speedX[i]*=-1;
}
else if (x[i] < 0){
x[i] = 0;
speedX[i]*=-1;
}
else if (y[i] > height-(71.73*w[i])){
y[i] = height-(71.73*w[i]);
speedY[i]*=-1;
}
else if (y[i] < 0){
y[i] = 0;
speedY[i] *=-1;
}
}
}
void fontA(float x, float y, float w, float h, color c1){
resetMatrix();
translate(x,y);
scale(w, h);
fill(c1);
partA();
fill(255);
partB();
}
void partA(){
beginShape();
vertex(27.01, 0);
vertex(37.98, 0);
vertex(64.01, 71.73);
vertex(53.37, 71.73);
vertex(45.88, 50.24);
vertex(17.74, 50.24);
vertex(9.96, 71.73);
vertex(0, 71.73);
vertex(27.01, 0);
endShape(CLOSE);
}
void partB(){
beginShape();
vertex(32.08, 10.64);
vertex(43.12, 42.33);
vertex(20.6, 42.33);
endShape(CLOSE);
}