Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
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 973 times)
0 Members and 1 Guest are viewing this topic.
Offline sss061975

Junior Newbie





« Posted 2009-09-02 16: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 Devvie


Medals: 1
Projects: 1


Co-op Freak


« Reply #1 - Posted 2009-09-03 17: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 13: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!
Legends of Yore - The Casual Retro Roguelike
Offline Karmington

Senior Devvie


Medals: 1
Projects: 1


Co-op Freak


« Reply #3 - Posted 2009-09-10 13: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.

 

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

The first screenshot will be displayed as a thumbnail.

rwatson462 (37 views)
2014-12-15 09:26:44

Mr.CodeIt (31 views)
2014-12-14 19:50:38

BurntPizza (62 views)
2014-12-09 22:41:13

BurntPizza (99 views)
2014-12-08 04:46:31

JscottyBieshaar (60 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (77 views)
2014-11-29 21:32:03

toopeicgaming1999 (138 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36

toopeicgaming1999 (38 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!