Tutorial: Processing-0199 + Eclipse + OpenGL on Windows
in
Share your Work
•
2 years ago
Here's how to get Processing working in Eclipse with OpenGL on Windows.
All the tutorials I could find were written for previous versions of Processing and Eclipse. I'm using 32-bit Java 6 on Windows 7 and Eclipse build id 20110615-0604. Processing version is 0199.
First get Processing working in Eclipse.
* Download Processing-0199 here: http://code.google.com/p/processing/downloads/list
* Open Eclipse, set workspace directory to a new folder.
* Create a new Java project.
* File -> New Class, name it "Driver", so Driver.java is created. (this name is arbitrary)
* Replace contents of "Driver.java" with the following: (as from here: http://processing.org/learning/eclipse/)
* Open Eclipse, set workspace directory to a new folder.
* Create a new Java project.
* File -> New Class, name it "Driver", so Driver.java is created. (this name is arbitrary)
* Replace contents of "Driver.java" with the following: (as from here: http://processing.org/learning/eclipse/)
- 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);
- }
- }
4