LWJGL Applet

Started by CaseyB, September 09, 2005, 21:02:07

Previous topic - Next topic

CaseyB

I just wanted to let you guys know that my co-worker and I got LWJGL running as an applet with very little trouble!  I created an applet that has an AWTGLCanvas as the main bit inside of a JApplet.  All we had to do was sign our jar and resign the LWJGL jars with our certificate and make sure the native libs were in the system path.  We are currently working on automating this process, but there was no slow-down while running as an applet!  It renders 12800 triangles all moving independantly at 52 FPS!

Kokoni

CaseyB,

is it possible for you to provide a sample of inclusing Lwjgl in applet ?

Matzon

consider rewriting the jogllauncher for seamless native installation:
http://www.vlsolutions.com/free/jogltest/

CaseyB

Unfortunately I can't, it was done for my work so I can't link you guys to it (it the whole non-disclosure thing)!  But, like I said in my other post it was suprisingly easy.  Just set it up like you would any other applet, ensure that the native libs are in the client system path and that you have signed all of the jars with your certificate.  If you don't sign the lwjgl jars it'll complain about the certificates not matching.  Using this we were able to serve up our application from a Debian server and run on a WindowsXP and a RedHat box.  Just give it a go and let me know if you run into specific problems.

Kokoni

Ok CaseyB, I'm going to investigate more on the subject., thanks for your quick reply.

Matzon, thanks for the link.

clilian

Hi !

to CaseyB (and others)

Do you have the same problems with your lwjgl applet on firefox than the jogl one : refresh rate really slow (never above 35 fps) for a simple scene, whereas its > 1000 on IE ?

with JOGL, I'm using glSetSwapInterval(0) to disable vsync... and there is a lag of many millis on swapBuffers...

Thanks for the help (if you can !)

Best regards,

(test case : my prototype game Jack Flowers is here http://www.javapause.com/games/jack and runs at 300 fps with IE, and 27 with Firefox)

Lilian (co-author of the JOGLAppletInstaller)

CaseyB

Because of our application we run at a limited frame rate anyway.  If the user is not interacting with the display it only updates every 30 sec.  but when the user is interacting with it we update as fast as possible so it's impossible to get a reliable framerate, but I can say that it seems to run smoother in firefox than in IE.   :?  Sorry I can't be of more help.  Also it could be that I am at work now and we have a hellasious firewall, but when I followed your link it said that it was installing the native files and then firefox shut down.  Here is the trace log
loadFromText() called
retrieved 'info/icusernav.txt' from jar
turning link checking off
findNode called with: rzahl/rzahllogonscripts.htm
Node found: Logon scripts
getBreadCrumbs() returning: <a href="rzahl/rzahlusergoal.htm" class="crumb" target="text">iSeries NetServer</a> > <a href="rzahl/rzahldmnlogonspt.htm" class="crumb" target="text">iSeries NetServer domain logon support</a> > <a href="rzahl/rzahllogonscripts.htm" class="crumb" target="text">Logon scripts</a>
opening http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/rzahgicfeedb.htm
findNode called with: rzahl/rzahllogonscripts.htm
findNode called on the selected node! Already in synch.
Node found: Logon scripts
getBreadCrumbs() returning: <a href="rzahl/rzahlusergoal.htm" class="crumb" target="text">iSeries NetServer</a> > <a href="rzahl/rzahldmnlogonspt.htm" class="crumb" target="text">iSeries NetServer domain logon support</a> > <a href="rzahl/rzahllogonscripts.htm" class="crumb" target="text">Logon scripts</a>
opening http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/rzahgicfeedb.htm
findNode called with: rzahl/rzahllogonscripts.htm
findNode called on the selected node! Already in synch.
Node found: Logon scripts
getBreadCrumbs() returning: <a href="rzahl/rzahlusergoal.htm" class="crumb" target="text">iSeries NetServer</a> > <a href="rzahl/rzahldmnlogonspt.htm" class="crumb" target="text">iSeries NetServer domain logon support</a> > <a href="rzahl/rzahllogonscripts.htm" class="crumb" target="text">Logon scripts</a>
panel paint !
panel paint !
panel paint !

Looks like it was supposed to be running!  I don't know what happened.

Kokoni

From the JOGL Applet Launcher, I'm trying to create a LWJGL one.
I manage to copy in the home user the dll, I don't forget to load it with the code :

System.out.println(nativeLib.getPath());
System.load(nativeLib.getPath());


My subapplet just start the test AWTGears from lwjgl_test.jar.

But I got the following error message :
Exception in thread "AWT-EventQueue-3" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
	at java.lang.ClassLoader.loadLibrary(Unknown Source)
	at java.lang.Runtime.loadLibrary0(Unknown Source)
	at java.lang.System.loadLibrary(Unknown Source)
	at org.lwjgl.Sys$1.run(Sys.java:67)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.lwjgl.Sys.<clinit>(Sys.java:65)
	at org.lwjgl.opengl.AWTGLCanvas.<clinit>(AWTGLCanvas.java:63)
	at org.lwjgl.test.opengl.awt.AWTGears.<init>(AWTGears.java:80)
	at org.geo4j.applet.test.LWJGLApplet.init(LWJGLApplet.java:22)
	at org.geo4j.applet.GeoAppletLauncher.startSubApplet(GeoAppletLauncher.java:507)
	at org.geo4j.applet.GeoAppletLauncher.access$3(GeoAppletLauncher.java:489)
	at org.geo4j.applet.GeoAppletLauncher$2.run(GeoAppletLauncher.java:483)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)


So, I don't understand because I'm sure lwjgl is well loaded with the first piece of code (the system output is correct), and the error message tell me it is not the truth. How can I deal with that ?

Thanks in advance.

clilian

The error is not in your code but in Sys inner class that calls a System.loadLibrary(). It should be deactivated first (That's how I did in JOGLAppletLauncher with the NativeLoader class.

Lilian

Kokoni

Lilian,

You are right. In the Sys.java LWJGL source code, we can see :

AccessController.doPrivileged(new PrivilegedAction() {
         public Object run() {
	[b]System.loadLibrary(LIBRARY_NAME);[/b]
	return null;
         }
});


I don't know why this line can interfer with my code ? And I don't know how to desactivate it, I wouldn't modify the source code of Sys class.

clilian

Well this code is guaranteed to fail when invoked from an applet, you should ask for an update of the Sys class and have a boolean specifying whether this invocation is required or not (or at least surrounded by a try catch (UnsatisfiedLinkError) )

Good luck : if it work better than the JOGLAppletLauncher (better support of ATI cards), I might get converted to LWJGL...

Lilian

Matzon

if Sys isn't allowed to load it - who is ?
is a property for not calling Sys.loadLibrary (-Dorg.lwjgl.Sys.loadlibrary=false) enough ?
I know that Cas wanted to look into applet support after seeing your work clilian.
Let us know what we need to change internally to make it work Kokoni - and I'll commit the needed changes.
Do visit irc://irc.freenode.net/lwjgl if you need something more specific.

clilian

Any class can load a library as long as the class belongs to a signed jar.

the problem here is with loadLibrary(lib) which looks into the library path, whereas load(lib) takes an absolute path to load the library (in JOGLAppletLauncher, the native lib is downloaded, installed in a location specific to the url, and then loaded with load()).

So what you have to do is to disable loadLibrary() and replace it by load() when invoked from an applet.

using a system property to do this is not a good idea as you can't pass them to the applets. You'd better add a static setter method in Sys, or into another class if the loadLibrary is done from a static initializer.

Lilian

Kokoni

Matzon,

I don't think the cmd line "-Dorg.lwjgl.Sys.loadlibrary=false" is enough. It should be a method like Sys.setLoadLibrary(false); because, with the applet launcher, I need in order to  :

- disable the lwjgl load of the native lib, to prevent interference with the next point.
- load from "myself" the lib in the right folder -in the applet launcher, it is based on home user folder.
- execute the "subapplet" which contains LWJGL calls linked with the previous lib.

So the disable/loading are done in running, not in the command.

Something like this in the static part of Sys class:

static {
                if(loadingEnabled){
                      [...]
                }
}


and why not something like :

private static boolean loadingEnabled = true; // true as default value
...
public static void setLoadLibrary(boolean b){
         loadingEnabled = b;
}


But before to ask you this change, I have to test it  :roll:

By the way, I will connect to the IRC.

Kokoni

As the load library in Sys class is in a static part, my solution with the boolean is not good, except if we initialize the loadingEnabled to false.
But I don't think it is suitable for non applet application ...

So, I commented the static part for my use only, I repackaged the lwjgl jar (with error for some class, don't find the com.sun.mirror or the net.java.games.input.ControllerEnvironment libs ...).

And with this pseudo lwjgl.jar, I manage to run the gears demo in an applet. It is so fast that the gears don't run correctly (I have to open several explorers to "slow" the drawing  :lol: ).

I have tested with Firefox and IE, no changes, I'm always around 120 fps.

For information,
I'm working on a laptop DELL Inspiron 8600 with 1Gb and Geforce FX 5650 128mb.