To clarify, using the "OPENGL" mode in Processing is faster than the default 2D, or P3D, but it's not as fast as straight OpenGL. To use that, you need to initialze an openGL object, align the GLUperspective to match Processing, etc.
Here is an example of this:
http://benhem.com/games/GLP5alignAnd this is what the following code looks like, in action:
http://benhem.com/games/GLfadeHere is the code you need, for reference in case I move those demos:
Quote:import processing.opengl.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
GL gl;
GLU glu;
float aspect, camZ, xx, yy;
void setup(){
size(400,400,OPENGL);
aspect=(float)width/(float)height;
camZ=((height/2.0) / tan(PI*60.0/360.0));
glu = new GLU();
gl = ((PGraphicsOpenGL)g).gl;
}
void draw(){
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(180/3.0, aspect, camZ/10.0, camZ*10.0);
glu.gluLookAt(0, 0, camZ, 0, 0, 0, 0, 1, 0);
gl.glColor4f(0,0,0,.02);
gl.glBegin(GL.GL_TRIANGLE_STRIP);
gl.glVertex3f(-width/2,-height/2,0);
gl.glVertex3f(width/2,-height/2,0);
gl.glVertex3f(-width/2,height/2,0);
gl.glVertex3f(width/2,height/2,0);
gl.glEnd();
xx=mouseX-width/2;
yy=mouseY-width/2;
gl.glColor3f(1,1,1);
gl.glBegin(GL.GL_TRIANGLE_STRIP);
gl.glVertex3f(xx-20,yy-20,0);
gl.glVertex3f(xx+20,yy-20,0);
gl.glVertex3f(xx-20,yy+20,0);
gl.glVertex3f(xx+20,yy+20,0);
gl.glEnd();
}
// enjoy -- Ben