We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Background doesn't clear with vsync enabled.
Page Index Toggle Pages: 1
Background doesn't clear with vsync enabled. (Read 944 times)
Background doesn't clear with vsync enabled.
Jan 11th, 2010, 2:04pm
 
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!
Page Index Toggle Pages: 1