I have a simple sketch that clears the background, shifts the location of a vertical line horizontally and draws that line:
Code:
int x;
void setup()
{
size(400,400)
frameRate(30);
}
void draw() {
background(0);
stroke(255);
strokeWeight(4);
x += 20;
line(x, 0, x, 400);
if (x > 400) {
x = 0;
}
}
When I shift the line one pixel each frame, the animation looks smooth at 30fps. However, when I shift the line 20 pixels each frame, two blinking lines are rendered.
I've read on these boards that enabling vsync has fixed these issues for some. I tried this, but got the same result.
Code:
import processing.opengl.*;
import javax.media.opengl.GL;
PGraphicsOpenGL pgl;
GL gl;
int x;
void setup()
{
size(400,400, OPENGL);
pgl = (PGraphicsOpenGL) g; //processing graphics object
gl = pgl.beginGL(); //begin opengl
gl.setSwapInterval(1); //set vertical sync on
// pgl.endGL(); //end opengl
frameRate(30);
smooth();
}
void draw() {
background(0);
stroke(255);
strokeWeight(4);
x += 20;
line(x, 0, x, 400);
if (x > 400) {
x = 0;
}
}
System details:
MacBook Pro C2D 2.8ghz, 4gm ram
Nvidia GeForce 9600 GT
OS 10.6.2, Processing 1.0.9
I also tested this on a Windows XP machine running 1.0.9 and got the same result. I did notice here that I got tearing without vsync.
Thanks in advance!