Posted by
p0pes on
Sep 24, 2010; 2:17pm
URL: https://forum.jogamp.org/Basic-Jogl-Applet-Trouble-tp1574201.html
So I'm trying to make a simple jogl applet and I've been able to get my project to run in Eclipse but I can not get it to work online. I've been here
http://jogamp.org/jogl-demos/www/applettest-jnlp.html and tried to do this but I just get a blank region where my applet should be.
This is what I'm using for my class. I exported the class to a jar using the standard eclipse export.
import java.applet.Applet;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.FPSAnimator;
public class AppletLauncherJogl extends Applet implements GLEventListener {
/**
*
*/
private static final long serialVersionUID = -5349107458641586294L;
public void init() {
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
GLCanvas canvas = new GLCanvas(caps);
canvas.setSize(400, 400);
canvas.setVisible(true);
add(canvas);
canvas.addGLEventListener(new AppletLauncherJogl());
this.start();
Animator animator = new FPSAnimator(canvas, 60);
animator.add(canvas);
animator.start();
}
@Override
public void display(GLAutoDrawable drawable) {
update();
render(drawable);
}
@Override
public void dispose(GLAutoDrawable drawable) {
}
@Override
public void init(GLAutoDrawable drawable) {
}
@Override
public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
}
private void update() {
}
private void render(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glBegin(GL.GL_TRIANGLES);
gl.glColor3f(1, 0, 0);
gl.glVertex3d(0, 0, 0);
gl.glVertex3d(0, 0.5, 0);
gl.glVertex3d(0.5, 0, 0);
gl.glEnd();
}
}
This is my html
<applet code="org.jdesktop.applet.util.JNLPAppletLauncher"
width=600
height=400
archive="
http://jogamp.org/deployment/util/applet-launcher.jar,
http://jogamp.org/deployment/webstart/nativewindow.all.jar,
http://jogamp.org/deployment/webstart/jogl.all.jar,
http://jogamp.org/deployment/webstart/gluegen-rt.jar,
MyURL/AppletLauncherJogl.jar">
</applet>
and this is my jnlp file
<?xml version="1.0" encoding="utf-8"?>
<jnlp href="MyURL/AppletLauncherJogl">
<information>
<title>AppletLauncherJogl</title>
<vendor>AppletLauncherJogl</vendor>
<homepage href="MyURL/"/>
<description>AppletLauncherJogl</description>
<description kind="short">AppletLauncherJogl</description>
<offline-allowed/>
</information>
<resources>
<j2se href="
http://java.sun.com/products/autodl/j2se" version="1.4+"/>
<property name="sun.java2d.noddraw" value="true"/>
<jar href="MyURL/AppletLauncherJogl.jar" main="true"/>
<extension name="jogl-all-awt" href="
http://jogamp.org/deployment/webstart/jogl-all-awt.jnlp" />
</resources>
<applet-desc
name="AppletLauncherJogl"
main-class="AppletLauncherJogl"
width="640"
height="480">
</applet-desc>
</jnlp>
I'm not sure really where the problem is but any help would be really appreciated. I've been stuck for quite and while. Thanks.