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 › OpenGL + Eclipse BUT as Applet possible
Page Index Toggle Pages: 1
OpenGL + Eclipse BUT as Applet possible? (Read 3652 times)
OpenGL + Eclipse BUT as Applet possible?
Aug 28th, 2007, 1:20pm
 
I'm trying in vain to run my OpenGL Sketch from Eclipse as an Applet? Is this even possible, I read somewhere that it's only possible when used as signed applet, but within eclipse?


This is my test code:
Code:
de.myPackage;

import processing.core.*;
import processing.opengl.*;
import javax.media.opengl.GL;

public class Virulova extends PApplet{
//
private static final long serialVersionUID = 1L;

float x, y;
// static public void main(String args[]) {
// PApplet.main(new String[] { "de.myPackage.Virulova" });
// }

// ToDo
public void setup(){

int dim = 400;

size(dim,dim, OPENGL);
}

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);
}
}


These are my errors:
Code:

Error while running applet.
java.lang.RuntimeException: Before using OpenGL, first select Import Library > opengl from the Sketch menu.

at processing.core.PApplet.createGraphics(PApplet.java:1120)

at processing.core.PApplet.size(PApplet.java:897)

at processing.core.PApplet.size(PApplet.java:838)

at de.smolka.Virulova.setup(Virulova.java:17)

at processing.core.PApplet.handleDisplay(PApplet.java:1285)

at processing.core.PGraphics.requestDisplay(PGraphics.java:680)

at processing.core.PApplet.run(PApplet.java:1454)

at java.lang.Thread.run(Unknown Source)
java.lang.RuntimeException: Before using OpenGL, first select Import Library > opengl from the Sketch menu.

at processing.core.PApplet.createGraphics(PApplet.java:1120)

at processing.core.PApplet.size(PApplet.java:897)

at processing.core.PApplet.size(PApplet.java:838)

at de.smolka.Virulova.setup(Virulova.java:17)

at processing.core.PApplet.handleDisplay(PApplet.java:1285)

at processing.core.PGraphics.requestDisplay(PGraphics.java:680)

at processing.core.PApplet.run(PApplet.java:1454)

at java.lang.Thread.run(Unknown Source)

Re: OpenGL + Eclipse BUT as Applet possible?
Reply #1 - Aug 28th, 2007, 7:24pm
 
How did you setup your Java Buildpath classpath in eclipse, and your java.library.path (or PATH environment variable) you need to make sure that the native libraries (*.dll, or *.so) for the JOGL OpenGL library is on your java.library.path.

In Eclipse in the Project >> Properties screen select Java Build Path. In the Libraries tab expand the entry for your jogl.jar library. Select "Native Library Location" and then hit the "Edit" button on the right.

Now you want to put it to the directory that contains the JOGL native libraries for example:
C:\processing-0125-expert\libraries\opengl\library

This will let you run it as an Applet in eclipse, now you can also just simply run it as a regular java application embedded in a JFrame.
Code:

public static void main(String[] args) {

JFrame f = new JFrame("Embedded PApplet");


f.setLayout(new BorderLayout());

PApplet embed = new Virulova();

f.add(embed, BorderLayout.CENTER);

f.setSize(DIM, DIM);

f.setVisible(true);

// important to call this whenever embedding a PApplet.

// It ensures that the animation thread is started and

// that other internal variables are properly set.

embed.init();

}

-------

The other thing that you might want to test out is using the JOGLAppletLauncher class which is how processing applets that use OpenGL in the browser (because the JOGL jar is already signed and so you don't have to sign your own jar).

To do that you'd setup a launch configuration in eclipse that would launch the com.sun.opengl.util.JOGLAppletLauncher class with the following parameters:

subapplet.classname = Virulova

Re: OpenGL + Eclipse BUT as Applet possible?
Reply #2 - Aug 29th, 2007, 12:06am
 
Thank you so very much, adding the directory containing JOGL helped. Gee, my head starts to smoke...

With your help I could start googling around for how to actually implement an opengl applet into a browser, and this is what I found, in case other newbies want something to read Wink
http://download.java.net/media/jogl/builds/nightly/javadoc_public/com/sun/opengl/util/JOGLAppletLauncher.html
https://jogl-demos.dev.java.net/applettest.html
https://applet-launcher.dev.java.net/

I then quickly made some edits to an exported processing opengl applet which didn't work first.

Original part:
Code:

<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase="http://java.sun.com/update/1.4.2/jinstall-1_4_2_12-windows-i586.cab"
width="200" height="200"
standby="Loading Processing software..." >
<param name="code" value="com.sun.opengl.util.JOGLAppletLauncher" />
<param name="archive" value="RGBCube.jar,opengl.jar,jogl.jar,core.jar" />
<param name="mayscript" value="true" />
<param name="scriptable" value="true" />
<param name="image" value="loading.gif" />
<param name="boxmessage" value="Loading Processing software..." />
<param name="boxbgcolor" value="#FFFFFF" />
<param name="progressbar" value="true" />
<param name="subapplet.classname" value="RGBCube" />
<param name="subapplet.displayname" value="RGBCube" />
<param name="test_string" value="inner" />
</object>


changed part:
Code:

<applet code="org.jdesktop.applet.util.JNLPAppletLauncher"
width=200
height=200
archive="http://download.java.net/media/applet-launcher/applet-launcher.jar,
http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jar,
http://download.java.net/media/gluegen/webstart/gluegen-rt.jar,
RGBCube.jar,opengl.jar,core.jar">
<param name="codebase_lookup" value="false">
<param name="subapplet.classname" value="RGBCube">
<param name="subapplet.displayname" value="RGBCube">
<param name="noddraw.check" value="true">
<param name="progressbar" value="true">
<param name="jnlpNumExtensions" value="1">
<param name="jnlpExtension1"
value="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp">
</applet>

Edit: Deleted the local jogl.jar entry!

I must admit that I don't understand everything yet, but at least I'm on the road Wink

Thanks again dougnukem! btw impressive sites you have there, very very impressive.
Re: OpenGL + Eclipse BUT as Applet possible?
Reply #3 - Aug 29th, 2007, 6:39pm
 
the gluegen jars, possibly more, are also missing when you 'save as application' under linux. i think they've been added to jogl in the last couple of revisions.

(you have jogl.jar specified twice btw)
Re: OpenGL + Eclipse BUT as Applet possible?
Reply #4 - Aug 29th, 2007, 11:10pm
 
true, deleted the local jogl.jar and it's still working. Don' know which jogl version is downloaded though. The newest version 1.1.0 didn't work in eclipse.
Page Index Toggle Pages: 1