Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (407)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Writing applet to launch in JNLPLauncher  (Read 677 times)
0 Members and 1 Guest are viewing this topic.
Offline sss061975

Junior Newbie





« Posted 2009-09-02 18:20:52 »

Hi,

I have an urgent need to launch an application which loads a 3d model in browser.

As practice, I tried the gears demo from https://jogl-demos.dev.java.net/applettest.html. I could successfully launch it with the jogl-demos.jar saved in my IIS server.

I am trying to write an applet for the JOGLTetrahedron demo in wikipedia http://en.wikipedia.org/wiki/Java_OpenGL. Also I am not sure about creating the jar file and signing it.
Can someone please guide me with the code for the applet and how to jar it.

thanks,
SSS

 
Offline Karmington

Senior Member


Medals: 1
Projects: 1


Co-op Freak


« Reply #1 - Posted 2009-09-03 19:04:43 »

not necessary to sign the applet, the jogl and joal libraries are trusted.
normal jar export should be ok
the main thing is to have the jnlp file setup right
and launch with <applet code="org.jdesktop.applet.util.JNLPAppletLauncher" settings figured out.

Offline sss061975

Junior Newbie





« Reply #2 - Posted 2009-09-04 15:43:05 »

thanks Karmington.

I am doing as you say. When I open the html, it starts the jnlpapplet launcher, says applet started but does not show the applet.

Can you please tell where I am going wrong.

Following is the modified JOGLTetrahedron.java which compiles and runs fine.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
package demos.tetra;
import javax.media.opengl.GL;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.glu.GLU;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.media.opengl.GLCanvas;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import com.sun.opengl.util.Animator;
 
public class JOGLTetrahedron implements GLEventListener, KeyListener {
public static void main(String[] args) {
    Frame frame = new Frame("Gear Demo");
    GLCanvas canvas = new GLCanvas();
   
    canvas.addGLEventListener(new JOGLTetrahedron());
    frame.add(canvas);
    frame.setSize(300, 300);
    final Animator animator = new Animator(canvas);
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
          // Run this on another thread than the AWT event queue to
         // make sure the call to Animator.stop() completes before
         // exiting
         new Thread(new Runnable() {
              public void run() {
                animator.stop();
                System.exit(0);
              }
            }).start();
        }
      });
    frame.show();
    animator.start();
  }

 float rotateT = 0.0f;
static GLU glu = new GLU();

public void init(GLAutoDrawable gLDrawable) {
   GL gl = gLDrawable.getGL();
   gl.glShadeModel(GL.GL_SMOOTH);
   gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   gl.glClearDepth(1.0f);
   gl.glEnable(GL.GL_DEPTH_TEST);
   gl.glDepthFunc(GL.GL_LEQUAL);
   gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT,
        GL.GL_NICEST);
   gLDrawable.addKeyListener(this);
    }

public void reshape(GLAutoDrawable gLDrawable, int x,
         int y, int width, int height) {
   GL gl = gLDrawable.getGL();
   if(height <= 0) {
       height = 1;
   }
   float h = (float)width / (float)height;
   gl.glMatrixMode(GL.GL_PROJECTION);
   gl.glLoadIdentity();
   glu.gluPerspective(50.0f, h, 1.0, 1000.0);
   gl.glMatrixMode(GL.GL_MODELVIEW);
   gl.glLoadIdentity();
    }

 public void display(GLAutoDrawable gLDrawable) {
   final GL gl = gLDrawable.getGL();
   gl.glClear(GL.GL_COLOR_BUFFER_BIT);
   gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
   gl.glLoadIdentity();
   gl.glTranslatef(0.0f, 0.0f, -5.0f);
 
   gl.glRotatef(rotateT, 1.0f, 0.0f, 0.0f);
   gl.glRotatef(rotateT, 0.0f, 1.0f, 0.0f);
   gl.glRotatef(rotateT, 0.0f, 0.0f, 1.0f);
   gl.glRotatef(rotateT, 0.0f, 1.0f, 0.0f);
 
   gl.glBegin(GL.GL_TRIANGLES);
 
   // Front
  gl.glColor3f(0.0f, 1.0f, 1.0f);
   gl.glVertex3f(0.0f, 1.0f, 0.0f);
   gl.glColor3f(0.0f, 0.0f, 1.0f);
   gl.glVertex3f(-1.0f, -1.0f, 1.0f);
   gl.glColor3f(0.0f, 0.0f, 0.0f);
   gl.glVertex3f(1.0f, -1.0f, 1.0f);
 
   // Right Side Facing Front
  gl.glColor3f(0.0f, 1.0f, 1.0f);
   gl.glVertex3f(0.0f, 1.0f, 0.0f);
   gl.glColor3f(0.0f, 0.0f, 1.0f);
   gl.glVertex3f(1.0f, -1.0f, 1.0f);
   gl.glColor3f(0.0f, 0.0f, 0.0f);
   gl.glVertex3f(0.0f, -1.0f, -1.0f);
 
   // Left Side Facing Front
  gl.glColor3f(0.0f, 1.0f, 1.0f);
   gl.glVertex3f(0.0f, 1.0f, 0.0f);
   gl.glColor3f(0.0f, 0.0f, 1.0f);
   gl.glVertex3f(0.0f, -1.0f, -1.0f);
   gl.glColor3f(0.0f, 0.0f, 0.0f);
   gl.glVertex3f(-1.0f, -1.0f, 1.0f);
 
   // Bottom
  gl.glColor3f(0.0f, 0.0f, 0.0f);
   gl.glVertex3f(-1.0f, -1.0f, 1.0f);
   gl.glColor3f(0.1f, 0.1f, 0.1f);
   gl.glVertex3f(1.0f, -1.0f, 1.0f);
   gl.glColor3f(0.2f, 0.2f, 0.2f);
   gl.glVertex3f(0.0f, -1.0f, -1.0f);
 
   gl.glEnd();
 
   rotateT += 0.2f;
    }

public void displayChanged(GLAutoDrawable gLDrawable,
                boolean modeChanged, boolean deviceChanged) {
    }

public void keyPressed(KeyEvent e) {
   if(e.getKeyCode() == KeyEvent.VK_ESCAPE) {
       System.exit(0);
   }
    }
 
    public void keyReleased(KeyEvent e) {
    }
 
    public void keyTyped(KeyEvent e) {
    }
 
}











Applet code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
package demos.applets;
import javax.media.opengl.*;
import com.sun.opengl.util.*;
import demos.tetra.JOGLTetrahedron;

/** Shows how to deploy an applet using JOGL. This demo must be
    referenced from a web page via an <applet> tag. */


public class TetraApplet extends Applet {
  private Animator animator;

  public void init() {
    setLayout(new BorderLayout());
    GLCanvas canvas = new GLCanvas();
    canvas.addGLEventListener(new JOGLTetrahedron());
    canvas.setSize(getSize());
    add(canvas, BorderLayout.CENTER);
    animator = new FPSAnimator(canvas, 60);
  }

  public void start() {
    animator.start();
  }

  public void stop() {
    // FIXME: do I need to do anything else here?
   animator.stop();
  }
}


My tetra.jar file has the class files for the above two and I have it in IIS
Following is the html,
<HTML>
    <HEAD>
        <TITLE>Applet example</TITLE>
    </HEAD>
    <BODY>
       <applet code="org.jdesktop.applet.util.JNLPAppletLauncher"
      width=600
      height=400
     archive="http://download.java.net/media/applet-launcher/applet-launcher.jar,
               http://download.java.net/media/jogl/jsr-231-2.x-webstart/nativewindow.all.jar,
               http://download.java.net/media/jogl/jsr-231-2.x-webstart/jogl.all.jar,
               http://download.java.net/media/gluegen/webstart-2.x/gluegen-rt.jar,
      http://localhost/tetra.jar">
   <param name="codebase_lookup" value="false">
   <param name="subapplet.classname" value="demos.applets.TetraApplet">
   <param name="subapplet.displayname" value="JOGL tetrahedron Applet">
   <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/jsr-231-2.x-webstart/jogl-core.jnlp">
</applet>


    </BODY>
</HTML>


I would greatly appreciate if you could help me out.

thanks.











Games published by our own members! Check 'em out!
Play the free demo of Revenge of the Titans!
Offline Karmington

Senior Member


Medals: 1
Projects: 1


Co-op Freak


« Reply #3 - Posted 2009-09-10 15:56:44 »

ok, comparing it to my version i see at least one difference:

missing this line as last param
<param name="jnlp_href" value="yourjarname.jnlp">

and the jnlp file has

<?xml version="1.0" encoding="utf-8"?>
<jnlp href="slicks.jnlp">
  <information>
  <title></title>
    <vendor></vendor>
    <homepage href="http://xxx.com/"/>
    <description>applet</description>
    <description kind="short">blahblah.</description>
    <offline-allowed/>
  </information>
 <resources>
   hrefs to the external jars
 </resources>
 <applet-desc
      name="xxx-applet"
      main-class="applet.xxx"
      width="1280"
      height="720">
  </applet-desc>
</jnlp>

P.S. how to make the code<div> here?

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (88 views)
2013-05-17 21:29:12

alaslipknot (96 views)
2013-05-16 21:24:48

gouessej (128 views)
2013-05-16 00:53:38

gouessej (123 views)
2013-05-16 00:17:58

theagentd (131 views)
2013-05-15 15:01:13

theagentd (119 views)
2013-05-15 15:00:54

StreetDoggy (161 views)
2013-05-14 15:56:26

kutucuk (184 views)
2013-05-12 17:10:36

kutucuk (185 views)
2013-05-12 15:36:09

UnluckyDevil (191 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.396 seconds with 21 queries.