For Processing 2.0xx there have been many changes, so I don't know. Even the example on the wiki seems to work no longer. So only andres knows.
For Processing 1.5.1 that would be:
For Processing 1.5.1 that would be:
- import javax.media.opengl.*;
- import processing.opengl.*;
- void setup() {
- size(800, 600, OPENGL);
- }
- void draw() {
- background(0);
- PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;
- GL gl = pgl.beginGL();
- gl.glBegin(GL.GL_POLYGON);
- gl.glColor4f(1, 0, 0, 1);
- gl.glVertex2d(100, 100);
- gl.glColor4f(0, 1, 0, 1);
- gl.glVertex2d(100, 200);
- gl.glColor4f(0, 0, 1, 1);
- gl.glVertex2d(200, 200);
- gl.glEnd();
- gl.glFlush();
- pgl.endGL();
- }
For full clarity. Of course the same shape could be drawn through the Processing API (but I assume you want to use low-level OpenGL calls for a reason):
- import processing.opengl.*;
- void setup() {
- size(800, 600, OPENGL);
- }
- void draw() {
- background(0);
- beginShape();
- fill(255, 0, 0);
- vertex(100, 100);
- fill(0, 255, 0);
- vertex(100, 200);
- fill(0, 0, 255);
- vertex(200, 200);
- endShape();
- }