Hi,
I have been mostly using P3D.
Today I decided to run one of my P3D sketch in OPENGL mode.
When I did that, the code flickers a lot and junk showed on my screen.
So I downloaded a OPENGL sketch from Processing website and it worked perfectly fine.
So I modified my sketch to use beginShape() and endShape() instead of line() and point()
Still the code flickers and shown junk.
Any idea what I am doing wrong?
Here's my code:
Quote:import processing.opengl.*;
//
float len = random(220);
float radius1 = random(20, 130);
float radius2 = random(10, 100);
float position = random(101);
float num = random(5, 10);
float prevX = 0.0;
float prevY = 0.0;
float x = 0.0;
float y = 0.0;
//
PVector point1, point2;
//
float step = 1 * PI / 180.0;
float theta = 0;
int i=0;
float count = 0;
//
void setup(){
size(500, 500, OPENGL);
background(255);
stroke(0, 20);
}
void draw(){
count+=1;
translate(width/2, height/2);
prevX = x;
prevY = y;
x = len * cos(theta) - position * cos(len * theta / radius2);
y = len * sin(theta) - position * sin(len * theta / radius2);
//
point1 = new PVector(prevX, prevY);
point2 = new PVector(x, y);
//
theta += step;
i++;
if(prevX!=0){
stroke(0);
strokeWeight(1);
PVector perp = new PVector(point2.y - point1.y, point1.x - point2.x);
// Length 1
perp.normalize();
// Length to n pixels
perp.mult(60); // Put 10 for 10 pixels
// Move to point1
perp.add(point1);
// Draw it
stroke(#AA2244);
strokeWeight(1);
beginShape(LINES);
vertex(point1.x, point1.y);
vertex(perp.x+random(-5, +5), perp.y+random(-5, +5));
endShape();
}
}
void mousePressed(){
background(255);
initL();
}
void initL(){
len = random(220);
radius1 = random(20, 130);
radius2 = random(10, 100);
position = random(101);
num = random(5, 10);
prevX = 0;
prevY = 0;
x = 0;
y = 0;
}