We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › using opengl from eclipse
Pages: 1 2 3 
using opengl from eclipse (Read 33985 times)
using opengl from eclipse
Apr 25th, 2005, 5:41am
 
in my project I'm including:

lib/core.jar
libraries/jogl.jar
libraries/opengl.jar

I made a copy of:
jog.dll
jogl_cg.dll

inside:

[path to j2sdk]/bin

now, to have opengl working properly I' had to do the following ugly as hell hack:


Code:



import processing.core.*;
import processing.opengl.*;

public class OpenGLPApplet extends PApplet {

float x, y;

public void setup() {
int dim = 400;

// <this is horrible!>
//

setSize(dim,dim);
g = new PGraphicsGL(dim,dim, this);
size(dim,dim);

//
// </this>

println("rendering with: "+ g.getClass().toString());
x = y = 0;
}

public void draw() {
background(255);
directionalLight(125, 125, 125, 0, 0, -1);
ambientLight(50, 50, 50);
translate(width / 2, height / 2, 100);
x += ((mouseX / 100.00) - x) * .05;
y += ((mouseY / 100.00) - y) * .05;
rotateY(x);
rotateZ(y);
noStroke();
box(100);
}
}




... alhtough it works, I get the following:

Code:


rendering with: class processing.opengl.PGraphicsGL
top endFrame(): 0502 GL_INVALID_OPERATION
bot endFrame(): 0502 GL_INVALID_OPERATION



what would be the proper way to use OPENGL then when compiling from eclipse?

Re: using opengl from eclipse
Reply #1 - Apr 26th, 2005, 5:11am
 
Damn, what a hell of a coincidence. I too was struggling to get processing and opengl working with eclipse (on osx). I was comitting the mistake of using size(x,x,OPENGL) which wasn't really working. Your way of creating the renderer works, but I don't seem to have jogl on my path. I'll fix that and report back.

I don't believe many people are using eclipse with this new build, but there are updates to be made to the old toxi integration tutorial. And I know the way we're creating the opengl canvas has to be unclean.

Any thoughts from someone else?
Re: using opengl from eclipse
Reply #2 - Apr 26th, 2005, 5:27am
 
After copying the necessary files to /Library/java/extensions/ I don't get the jogl missing error, but I do get a NoClassDefFoundError error for PGraphics3, which isn't definitely normal.

Code:
java.lang.NoClassDefFoundError: processing/core/PGraphics3
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
(...)


This has to be something stupid that I'm not really looking at, but considering its 4.30AM, I have better odds in finding a gold pot under my desk than to find a solution for this right now.
Re: using opengl from eclipse
Reply #3 - May 10th, 2005, 3:34pm
 
I'm working JBuilder on Windows XP and can't get PGraphicsGL running either. Using marumushi's code I get the same error message from Processing, but in addition I get the following:

Code:
java.lang.UnsatisfiedLinkError: CreateDummyWindow
at net.java.games.jogl.impl.windows.WGL.CreateDummyWindow(Native Method)
at net.java.games.jogl.impl.windows. WindowsGLContextFactory$NativeWindowThread.run(WindowsGLContextFactory.java:318)


I uncommented the debug message lines in PGraphicsGL.java, and it looks like it's successfully initalizing (it spits out all the messages, including "done creating gl" at the end).

I also tried Ben's method of using PApplet.main() to invoke the applet as an application, which bizarrely works when invoked in present mode but not when that parameter is removed. I would very much prefer to run it windowed, so I for one would like to figure this one out.

It looks like it is theoretically possible to cut PGraphicsGL loose from PApplet if one writes a new constructor that doesn't require a PApplet parent reference. That way you would have to take care of initializing the GLCanvas yourself, but would have more freedom to not use the PApplet application structure.

Of course the reason I'm so keen on this is that I have a project deadline this weekend, and have grown quite convinced of the advantages of OpenGL with the P5 library API instead of the usual brutal glVertex3() calls...
Re: using opengl from eclipse
Reply #4 - May 11th, 2005, 2:03am
 
Ok, no luck using PGraphicsGL from JBuilder, and since supersized windows (I need 4x PAL frames, 3072x576 px) don't work with PGraphicsGL even from inside Processing I will stay oldskool and stick with the old 0068 lib.

Off-screen OpenGL rendering (i.e. initializing PGraphicsGL objects without showing them on-screen) would be great, but I guess that goes against the whole principle of OpenGL.
Re: using opengl from eclipse
Reply #5 - May 11th, 2005, 11:45am
 
It's possible to do offscreen rendering with opengl, but this needs a special initialization when creating the opengl rendering context (tell opengl if we are going to draw on a window or on a block of pixels). I guess this must be in the depths of PGraphicsGL Smiley
Re: using opengl from eclipse
Reply #6 - Jun 16th, 2005, 12:18am
 
fyi, not knowing exactly where to place the .dlls, i eventually found what seems to be the best solution --

Project>Properties>Java Build Path>Source>Add Folder...

then right-click on the new folder in the Package Explorer, and Import the .dlls.
Re: using opengl from eclipse
Reply #7 - Jun 16th, 2005, 11:10pm
 
another good thing to add to marumushi's code, immediately after the size() call, is:

Code:

width = g.width;
height = g.height;


cause for some reason this hack doesn't properly set PApplet.width/.height, they remain at zero.
Re: using opengl from eclipse
Reply #8 - Sep 20th, 2005, 11:22pm
 
has anybody had any success running opengl in eclipse? The ported processing application compiles fine but just crashes with only one hint: Bus error.

I am running OS X 10.3
with eclipse 3.1
java 1.4.2
jogl libraries supplied with the opengl package
processing 92
Re: using opengl from eclipse
Reply #9 - Oct 9th, 2005, 11:27pm
 
Hey maybites,

I'm also running OS X, but I've no idea how to install JOGL. It seems that anywhere that I put the JAR files I get the "no jogle installed" message when I try to compile in Eclipse. So yes, I'm at step 0 here. Any help would be appreciated. Oh yeah, I should add that I'm a OS X neophyte, for I surely be able to do this in Windows... surely... yeah... Smiley

c.
Re: using opengl from eclipse
Reply #10 - Dec 23rd, 2005, 12:55am
 
Trip -
I've gotten Eclipse to work with JOGL on OS X by unzipping the  jogl-natives-macosx.jar and putting libjogl_cg.jnilib and libjogl.jnilib along with jogl.jar in ~/Library/Java/Extensions.

You shouldn't have to.  You should be able to add the libraries via eclipse or use the argument -Djava.library.path but neither of those seemed to work (although I didn't spend too much time on the problem).
Re: using opengl from eclipse
Reply #11 - Dec 28th, 2005, 2:28pm
 
marumushi

I put aside processing  for a while and learned Jogl on Eclipse and came back to processing 98.
When I tried following procedure it seems works fine.
I am using Windows XP professional.

I put < jogl.dll> and <jogl_cg.dll>
in the directory  Java\jre1.5.0_06\bin

and  I put
<jogl.jar>, <core.jar>, and <opengl.jar>
in the directory Java\jre1.5.0_06\lib\ext.

Now in eclipse,
following code works without any error message.

//**********

import processing.core.*;

public class OpenGLPApplet extends PApplet {
private static final long serialVersionUID = 1L;
float x, y;
public void setup() {
 int dim = 400;
  size(dim,dim, OPENGL);
//  size(dim,dim, P3D);
 println("Rendering with: "+ g.getClass().toString());
 x = y = 0;
}
public void draw() {
 background(255);
 directionalLight(125, 125, 125, 0, 0, -1);
 ambientLight(50, 50, 50);
 translate(width / 2, height / 2, 100);
 x += ((mouseX / 100.00) - x) * .05;
 y += ((mouseY / 100.00) - y) * .05;
 rotateY(x);
 rotateZ(y);
 noStroke();
 box(100, 50, 150);
}
}
//********************

In console window
you see

Rendering with: class processing.opengl.PGraphicsGL

if you use
size(dim,dim, P3D);
you get

Rendering with: class processing.core.PGraphics3

When I remove either <jogl.jar>  or <opengl.jar>
I can get error message saying  jogl missing or opengl missing.
This means even if I omit "import" statement,  as far as  <jogl.jar>  and <opengl.jar> are installed in the ..\lib\ext directroy,  the processing statement
  size(dim,dim, OPENGL);
obviously creates instance g of processing.opengl.PGraphicsGL!


Re: using opengl from eclipse
Reply #12 - Dec 28th, 2005, 9:38pm
 
Thanks, this also works for me!

So actually the only bit that is confusing is that you manually have to copy the JOGL dlls to the JRE bin directory, as you wrote:

dcknsk wrote on Dec 28th, 2005, 2:28pm:
I put < jogl.dll> and <jogl_cg.dll>
in the directory  Java\jre1.5.0_06\bin

and  I put
<jogl.jar>, <core.jar>, and <opengl.jar>
in the directory Java\jre1.5.0_06\lib\ext.


The jars don't need to be copied to the jre\lib\ext folder. It's sufficient to add them to the build path of the eclipse project. Just go to [ Project -> Properties -> Java Build Path -> Libraries -> Add External JARs... ] and add them there. That way you can easier stay on top of processing and jre versions.
Re: using opengl from eclipse
Reply #13 - Jan 1st, 2006, 10:55pm
 
..and for the .dlls: They just need to be in some directory that is mentioned in the Windows PATH variable, which you can modify at [ Start -> System Properties -> System -> Advanced -> Environment Variables ] (freely translated).
Re: using opengl from eclipse
Reply #14 - Feb 8th, 2006, 5:39am
 
I realize I'm late to this thread, but I came up with a different way to use jogl in eclipse on windows:

Import the .jar files as you would any other library in the project properties.

Add the .dll's by configuring the run options. In the VM Arguments textbox in the Arguments tab, add this:

-Djava.library.path="${env_var:PATH};C:\processing\processing-0103-expert\librar
ies\opengl\library"

substituting your local processing install location.

This way you don't have to modify your system path, or pollute your jre install with the dll's.

Hope that helps...
Pages: 1 2 3