OpenGL and Processing 2.0

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.*;
GL2 gl;
float t, s, c;
void setup() {
  size(400, 400, OPENGL);
  PGraphicsOpenGL pg = (PGraphicsOpenGL) g;
  PGL pgl = pg.beginPGL();
  gl =;
  t = 0.0f;
  s = 0.0f;
  c = 0.0f;
void draw() {
  t += 0.01;
  s = sin(t);
  c = cos(t);
  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);

One Reply to “OpenGL and Processing 2.0”

  1. Hi, I am new at OpenGL using with Processing. I could’nt find the opengl library for processing. Could You help me about this trouble.

Comments are closed.