The existing OpenGL codes for Processing do not work in the 2.0 alpha. Here is an example code segment I modify to use the new PGL class.
import processing.opengl.*; import javax.media.opengl.*; GL2 gl; float t, s, c; void setup() { size(400, 400, OPENGL); background(0); PGraphicsOpenGL pg = (PGraphicsOpenGL) g; PGL pgl = pg.beginPGL(); gl = pgl.gl.getGL().getGL2(); pg.endPGL(); t = 0.0f; s = 0.0f; c = 0.0f; } void draw() { t += 0.01; s = sin(t); c = cos(t); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glBegin(GL.GL_TRIANGLES); gl.glColor3f(1, 0, 0); gl.glVertex3f(-c, -c, s); gl.glColor3f(0, 1, 0); gl.glVertex3f(0, c, 0); gl.glColor3f(0, 0, 1); gl.glVertex3f(s, -s, c); gl.glEnd(); } |