www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Fencer on September 25, 2006, 08:00:15 pm

Title: The car demo as an applet
Post by: Fencer on September 25, 2006, 08:00:15 pm
I would like to use the Car Demo (http://www.jpct.net/demos.html) as a classic applet (because I've seen it in this thread (http://www.jpct.net/forum/viewtopic.php?t=258)) but when I try to convert the existing example to the applet, it doesn't work. Actually, the Java console says all resources have been loaded correctly but the applet window shows nothing, only a black screen.

Since the full code is too long to post it here, would it be possible to download the car demo applet source code? I just want to learn how to use jPCT features in an applet context and working examples are always the best way.

Thank you.
Filip
Title: The car demo as an applet
Post by: EgonOlsen on September 25, 2006, 08:16:14 pm
It's already there due to popular demand (but well hidden... :wink: ):http://www.jpct.net/download/beta/AppletCarTest.java
Title: The car demo as an applet
Post by: Fencer on September 25, 2006, 08:26:25 pm
Quote from: "EgonOlsen"
It's already there due to popular demand (but well hidden... :wink: ):http://www.jpct.net/download/beta/AppletCarTest.java


Thank you very much, you saved me.  :D

Filip
Title: The car demo as an applet
Post by: Fencer on September 26, 2006, 11:05:15 am
Quote from: "EgonOlsen"
It's already there due to popular demand (but well hidden... :wink: ):http://www.jpct.net/download/beta/AppletCarTest.java


I guess it requires a signed applet due to accessing local resources, right?
I would like to try it without signing but I hope it won't be a big modification.

Filip
Title: The car demo as an applet
Post by: EgonOlsen on September 26, 2006, 05:12:50 pm
The signing is required because the applet uses native libs. You can't work around this unless you are not using them. The example is not meant to be a general applet example but as a starting point for OpenGL implementations in an applet. A more generic example (using the software renderer) can be found in this (german) thread: http://www.jpct.net/forum/viewtopic.php?t=474
Title: The car demo as an applet
Post by: Fencer on September 26, 2006, 09:05:58 pm
Quote from: "EgonOlsen"
The signing is required because the applet uses native libs. You can't work around this unless you are not using them. The example is not meant to be a general applet example but as a starting point for OpenGL implementations in an applet. A more generic example (using the software renderer) can be found in this (german) thread: http://www.jpct.net/forum/viewtopic.php?t=474


Thank you Egon, I'll try the German thread. Fortunatelly the code is in English.  :D
Just out of curiosity, this page (http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/applet) says the upcoming release of LWJGL 1.0 would contain signed packages, in order to allow users to create signed applets (using native libraries) without purchasing their own certificate. It sounds great because that's exactly what I need.
Do you plan to add this functionality to jPCT after the LWJGL 1.0 is out?

Filip
Title: The car demo as an applet
Post by: EgonOlsen on September 26, 2006, 11:01:13 pm
If the LWJGL packages are signed now, it's up to you to use it. jPCT works fine with all the recent LWJGL versions. Just find the correct way to embed it into an applet and you are done. I've stopped researching this topic with  the modified car example, but i'm sure that it's possible somehow. jPCT itself doesn't require signing.
Title: The car demo as an applet
Post by: Fencer on September 27, 2006, 07:42:07 am
Quote from: "EgonOlsen"
If the LWJGL packages are signed now, it's up to you to use it. jPCT works fine with all the recent LWJGL versions. Just find the correct way to embed it into an applet and you are done. I've stopped researching this topic with  the modified car example, but i'm sure that it's possible somehow. jPCT itself doesn't require signing.


Thank you. I am new to all these things, so I better ask instead of spending days to develop what is already developed.

Filip
Title: Re: The car demo as an applet
Post by: z_____ on May 24, 2007, 03:28:07 pm
I decided to write here, because my problem is somehow related with this question.
I  tried to make the fps-like level demo in applet, but some problems occur. When I'm compiling the demo on my machine, there is no problem - the applet is running, but when i try to load the applet from the web, nothing happens. Java Console shows the following errors:

ava Plug-in 1.5.0_05
Using JRE version 1.5.0_05 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\user


----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
p:   reload proxy configuration
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

load: JPCTDemo.class can't be instantiated.
java.lang.InstantiationException: JPCTDemo
   at java.lang.Class.newInstance0(Unknown Source)
   at java.lang.Class.newInstance(Unknown Source)
   at sun.applet.AppletPanel.createApplet(Unknown Source)
   at sun.plugin.AppletViewer.createApplet(Unknown Source)
   at sun.applet.AppletPanel.runLoader(Unknown Source)
   at sun.applet.AppletPanel.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-4" java.lang.NullPointerException
   at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
   at sun.plugin.AppletViewer.showAppletException(Unknown Source)
   at sun.applet.AppletPanel.runLoader(Unknown Source)
   at sun.applet.AppletPanel.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
   at sun.plugin.util.GrayBoxPainter.showLoadingError(UųP?
Title: Re: The car demo as an applet
Post by: z_____ on May 24, 2007, 03:31:55 pm



...And I don't know what to do. :(
btw, the Textures are uploaded on the same server, but not in the same directory. I use the Texture method with loading texture from URL. Here is the web address where the applet must appear, but no success for now :(  :
http://z.arttoday.org/gallery/deploy/start.html

I'm sure, that I'm making some very stupid mistake, but unfortunately I can't locate it.. If somebody can help me, please :)
Thanks!
Title: Re: The car demo as an applet
Post by: EgonOlsen on May 24, 2007, 05:46:34 pm
Have you tried to put it all in one archive?
Title: Re: The car demo as an applet
Post by: Kearnan on July 30, 2007, 01:36:39 am
    An applet using OpenGL or JOGL or whatever can work fine on your own computer because it's on your own computer.  Once it becomes an applet on a web page, or thinks it's on a web page via clicking the html file from a directory on your computer, it's restricted to the usual sandbox restrictions and cannot use OpenGL or JOGL or any library that uses either.  It sounds like your applet is getting as far as the openGL/GL calls (ie.,. creating the JFrame and such) but stopping as soon as it hits OpenGL.

    Looks like you've solved the signed jar file problem so I won't go into how to make and sign a jar that works but...you can actually sign the jpct.jar yourself or take it apart and rebuild it and sign it that way.  Jar signing yourself works on any jar file signed or not, it doesn't know it's already signed.

    However, I'd suggest abandoning the applet idea completely and create a web application which uses "Java Web Start" and a .jnlp (not .html) file, which enables you to use OpenGL or any other fancy implimentation the user happens to have on his/her computer and uses a Java "application" rather than an "applet".

    Once you have an application that works and has signed jar files you can start it, on your own computer or from a web site using your .jnlp file which has XML code looking like...

(This is what's in a jnlp file among other things, for the rest go to "lopica.sourceforge.net/ref.html#application-desc")

    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+"
          codebase="http://www.yourwebsite.com/test" href="yourjarstarter.jnlp">
    <information>
    <title>Your Jar Worker title that shows up on the screen like an html title</title>
    <vendor>Your Name Incorporated or whatever</vendor>
    <homepage href="http://www.yourwebsite.com/" />
    <description>The place where my application works</description>
    <description>These can go on and on and...</description>
    <description>and on and on....description>
    </information>
    <offline-allowed/>
    <security>
         <all-permissions/>
    </security>
    <resources>
    <j2se version="1.2+" />
    <jar href="yourjarthing.jar" download="eager" main="true"/>
    <jar href="jogl.jar"/>
    <jar href="lwjgl.jar"/>
    <jar href="jpct.jar"/>
    </resources>
    <application-desc main-class="yourmainclassfilenamewithno".class"extensionandnotanapplet!!" />
    </jnlp>

    The only thing that'll keep it from running would be an error in finding the main-class, an ill-formed jar file or that the user doesn't have the proper dll on their system which, happily, you could install for them using the nifty "Transferer" class from the aforementioned Car Demo applet.  "all-permissions" lets you do almost wheatever you want which is scary but usefull.

Happy coding
Title: Re: The car demo as an applet
Post by: Kearnan on August 13, 2007, 12:03:02 am
Actually, let me clarify.  You certainly can run opengl from an applet, Iíve done it recently, implementing jpct and lwjgl in an applet, and quite successfully.   I've tested it on EI, Netscape and Mozilla using an html web page and getting hundreds of frames/sec running from the browser window (Not as a seperate Frame/JFrame).   Itís just a little more effort than using Java Web Start; applets being the particular creatures that they are.  But itís certainly cool.

Thank you, EgonOlson, for JPCT.  It's truly excellent.