Update: This hack is obsolete as of Processing 0133. Read more here.

I’ve previously mentioned the problem of anti-aliasing not working properly in OpenGL, which is particularly bothersome for MacOS users who can’t use a graphics card control panel to override application settings to force AA. Mike Creighton posted source for a hack on the Processing forums that modifies PGraphicsOpenGL to force AA. I’ve created a simple version of this hack and made a replacement for the opengl.jar that comes with Processing.

This hack should work for Processing 0124 on Mac and PC. Simply download the opengl.jar below and drop it into the “libraries\opengl\library” subfolder of your Processing application directory. Make sure to make a backup of the original opengl.jar first in case this doesn’t work for you. Once replaced, the new PGraphicsOpenGL class should always initialize with 4x supersampling. Please leave comments on this post to let me know if it works for you.

Downloads

There are 8 comments to "Hack: Force OpenGL anti-aliasing in Processing". You may leave your own comment.
1. lenny, April 30th, 2007 at 17:07

i love it.
thanks a lot.

2. andreas, April 30th, 2007 at 20:53

Hi, Marius. It has same error like my attempt (the last but one post in the thread). In my sketch I draw a opacity rectangle polygon, with the size of the screen, at the begin of the drawing loop, then I clear the depth buffer and then the rest will be drawn. Normally this would give me trails but in your and mine solution it fails.

3. marius watz, May 1st, 2007 at 00:07

Andreas, I haven’t done trails with OpenGL so I have no experience with that. Do you have some code to demonstrate how it would work properly before the hack is applied? The problem has been confirmed by someone else, but I’m not sure what causes it or how it could be fixed.

4. Simon, May 1st, 2007 at 14:37

Hello Marius!
Thank’s for this, like usual it is really great.
But, because there is always a but, unfortunatly it isn’t functionning for me.
When I draw something the draw function will erase it in the next frame so except if I draw each object, each frame I can’t do anything.
Here is a small exemple of code where it’s not functionning:
import processing.opengl.*;

void setup(){
size(400,400,OPENGL);
background(255);
}
void draw(){
}
float x,y;
void mousePressed(){
x = mouseX;
y = mouseY;
}
void mouseReleased(){
leaf(x,y,mouseX,mouseY);
}
void leaf(float x1,float y1,float x2, float y2){
float dx = x1-x2;
float dy = y1-y2;
float d = sqrt(dx*dx+dy*dy);
float a = atan2(dy,dx);
float ar1 = random(-2.7,-3);
float ar2 = random(-.2,-.9);
float l1 = random(.4,.7);
float l2 = l1+random(-.2,.2);
float cx1 = x1+cos(a+ar1)*d*l1;
float cy1 = y1+sin(a+ar1)*d*l1;
float cx2 = x2+cos(a+ar2)*d*.3;
float cy2 = y2+sin(a+ar2)*d*.3;
noStroke();
fill(random(255));
bezier(x1,y1,cx1,cy1,cx2,cy2,x2,y2);
cx1 = x1+cos(a-ar1)*d*l2;
cy1 = y1+sin(a-ar1)*d*l2;
cx2 = x2+cos(a-ar2)*d*.3;
cy2 = y2+sin(a-ar2)*d*.3;
bezier(x1,y1,cx1,cy1,cx2,cy2,x2,y2);
}

Hope it help you. (I’m on an old PC with winXP sp2, an ATIRadean 9600xt, the last java and the last processing).

Best Regards!!!

Simon.

5. steve cooley, May 2nd, 2007 at 03:24

Ahh, thank you! This is amazing!

6. patrik francescato, May 23rd, 2007 at 16:09

thanx 1000000000 MARIUS !!!!

creating hacked PGraphicsOpenGL 4
17.746 [50]
40.08 [50]
42.735 [50]
43.011 [50]
42.735 [50]
43.908 [50]
43.243 [50]
43.716 [50]
43.011 [50]
43.86 [50]
43.431 [50]
44.593 [50]
43.716 [50]
38.059 [200]
21.61 [400]
11.884 [1600]
6.96 [3200]

now it work properly…..finally!
u always over the edge….eheh
see ya bro

Patrik

7. david wicks, June 26th, 2007 at 02:45

Thanks for this hack. Works beautifully on my macbook pro. It even eliminates the weird seams that used to crop up between the triangles in a TRIANGLE_STRIP.

8. Andreas Wetterberg, July 26th, 2007 at 21:41

thanks for that bit of info, David - I was totally wondering about those!?!? That’s some buggy stuff. Can’t wait to try out this bug fix.

andreas

Comment on this entry

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>