Loading...
Logo
Processing Forum
I am currently working with Processing 2.0a4 and I wonder if anybody else has the same problem:

When running the sketch below in standard mode everything is okay. But when i render it in javascript mode it doesn't smooth/antialias the lines. Am I doing something wrong or is there any other way to smooth/antialias in processingjs?

Copy code
  1. void setup() {
  2.   size(400, 400, OPENGL);
  3.   hint(DISABLE_OPENGL_2X_SMOOTH);
  4.   hint(ENABLE_OPENGL_4X_SMOOTH);
  5.   smooth();
  6.   stroke(0);
  7.   noFill();
  8.   strokeWeight(2);
  9. }

  10. void draw() {
  11.   background(255);
  12.   rotateX(mouseX/200.0);
  13.   rotateY(mouseY/200.0);
  14.   translate(width/2, height/2);
  15.   box(200);
  16. }
Thanks in advance,
mrzl

Replies(4)

Unless Processing.js uses WebGL, I don't think it has a real OpenGL mode, so these hints are probably without effect.
Oh yeah, thats true. Since in processing 2.0 the P3D renderer has been replaced by OPENGL its not possible to smooth at all?
Processing.js uses WebGL, but we have a line in processing.js that turns off aliassing, because it broke on Firefox a while ago. You can edit processing.js and make it work by finding the Drawing3D.prototype.size function and removing the context options argument (the {...} bit) there:

gl = canvas.getContext(ctxNames[i], {antialias: false});

should become

gl = canvas.getContext(ctxNames[i]);

We'll be removing this in a future release now that firefox no longer dies on code it shouldn't have died on in the first place =)
Great, that worked. Thanks a lot!