Processing Forum
- import processing.core.*;
- public class Driver extends PApplet
- {
- public void setup() {
- size(200,200);
- background(0);
- }
- public void draw() {
- stroke(255);
- if (mousePressed)
- line(mouseX, mouseY, pmouseX, pmouseY);
- }
- }
* Create a new folder named "lib" in project root.
* Right click lib folder, import. general, filesystem. Browse to your processing folder ".../processing-0199/lib"
* Select core.jar and finish
* Right click core.jar, build path->add to build path.
At this point the project will run fine.
Next, OpenGL functionality is added.
* Right click lib folder, import. general, filesystem. ".../processing-0199/modes/java/libraries/opengl/library"
* Select all the .jar files: gluegen-rt.jar, jogl.all.jar, nativewindow.all.jar, and opengl.jar.
* Right click each of the .jar files and select build path->add to build path.
* Create a new folder named "natives" in lib folder.
* Right click "natives", import. general, filesystem. ".../processing-0199/modes/java/libraries/opengl/library/windows32"
* Select all the .dll files and import them.
gluegen-rt.dll
jogl_desktop.dll
jogl_es1.dll
jogl_es2.dll
nativewindow_awt.dll
nativewindow_win32.dll
newt.dll
* Go to the Project menu->Properties. Java Build Path. Libraries tab. For each of gluegen-rt.jar, jogl.all.jar, nativewindow.all.jar, and opengl.jar:
click Native library location and Edit...
select Workspace...
select lib/natives
* In Driver.java,
add "import processing.opengl.*;" below "import processing.core.*;"
change size(200, 200); to size(200, 200, OPENGL);
If you don't clear and redraw the entire screen each frame you may get flickering.
Here is the example above with OpenGL enabled and redrawing everything each frame:
- import processing.core.*;
- import processing.opengl.*;
- import java.util.Vector;
- public class Driver extends PApplet
- {
- public class Line
- {
- public float a,b,c,d;
- public Line(float inita, float initb, float initc, float initd) {
- a = inita;
- b = initb;
- c = initc;
- d = initd;
- }
- }
- Vector<Line> lineList = new Vector<Line>();
- public void setup() {
- size(200,200,OPENGL);
- }
- public void draw() {
- background(0xFF000000);
- stroke(255);
- if (mousePressed)
- lineList.add(new Line(mouseX, mouseY, pmouseX, pmouseY));
- for(Line l : lineList)
- line(l.a, l.b, l.c, l.d);
- }
- }