LWJGL Forum

Programming => LWJGL Documentation => Topic started by: CaseyB on September 09, 2005, 21:02:07

Title: LWJGL Applet
Post by: CaseyB on September 09, 2005, 21:02:07
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!
Title: LWJGL Applet
Post by: Kokoni on January 20, 2006, 15:31:55
CaseyB,

is it possible for you to provide a sample of inclusing Lwjgl in applet ?
Title: LWJGL Applet
Post by: Matzon on January 20, 2006, 16:02:30
consider rewriting the jogllauncher for seamless native installation:
http://www.vlsolutions.com/free/jogltest/
Title: LWJGL Applet
Post by: CaseyB on January 20, 2006, 16:53:53
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.
Title: LWJGL Applet
Post by: Kokoni on January 20, 2006, 17:22:34
Ok CaseyB, I'm going to investigate more on the subject., thanks for your quick reply.

Matzon, thanks for the link.
Title: LWJGL Applet
Post by: clilian on February 06, 2006, 17:33:32
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)
Title: LWJGL Applet
Post by: CaseyB on February 06, 2006, 21:37:24
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.
Title: LWJGL Applet
Post by: Kokoni on February 17, 2006, 13:07:44
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.
Title: LWJGL Applet
Post by: clilian on February 17, 2006, 13:16:26
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
Title: LWJGL Applet
Post by: Kokoni on February 17, 2006, 13:51:34
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.
Title: LWJGL Applet
Post by: clilian on February 17, 2006, 14:00:56
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
Title: LWJGL Applet
Post by: Matzon on February 17, 2006, 14:48:32
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.
Title: LWJGL Applet
Post by: clilian on February 17, 2006, 15:00:26
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
Title: LWJGL Applet
Post by: Kokoni on February 17, 2006, 15:11:03
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.
Title: LWJGL Applet
Post by: Kokoni on February 17, 2006, 21:14:37
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.
Title: LWJGL Applet
Post by: clilian on February 17, 2006, 21:37:51
You just have to use another class to initialize the boolean (like "SysContext.setAppletExecution(true)")
and then use SysContex.isAppletExcecution() to enable Sys lib loading

It will work as long as the "SysContext" is invoked/references before the Sys class.

Lilian
Title: LWJGL Applet
Post by: Matzon on February 19, 2006, 09:04:51
Quote from: "Kokoni"
I have tested with Firefox and IE, no changes, I'm always around 120 fps./quote] Great!
you have something we can test - and a patch file or list of changes ?
Title: LWJGL Applet
Post by: Kokoni on February 20, 2006, 10:12:42
Matzon,

I'm going to put the applet online then people will see the result. Before that I have to clean the Lwjgl launcher class file. Some Lilian's JOGL comments are still in source code.

Concerning the Sys class, currently I have commented the static part, but I think the Lilian's solution is really better. So I will create a SysContext class with a static method which will enabled/disabled the load of the lib (in the Sys static part).

When it will be ready, I will post the link here, with the changes of Sys.class
Title: LWJGL Applet
Post by: Matzon on February 23, 2006, 12:27:37
whats the status of this? - I would like to get this in the code base - so if you need some help?
Title: LWJGL Applet
Post by: Kokoni on February 23, 2006, 19:13:33
Sorry for the delay, I have currently many things to do. I've not completly performed the code clean up, it will be probably done tomorrow.

For now, I can just put a link with the applet working : http://nicolas.esteban.free.fr/lwjgl/lwjgl-applet.html

too many jar are loaded, it was just for my test  :roll: The final version will be more    light.
Title: LWJGL Applet
Post by: Matzon on February 23, 2006, 21:15:56
cool, I got it working - however not without issues:
The very first time I ran it in Firefox I got a:

QuoteInstalling native files
Download complete
Starting GeoApplet
C:\Documents and Settings\Brian Matzon\.geoapplet\nicolas_esteban_free_fr_lwjgl_\lwjgl.dll
Exception in thread "AWT-EventQueue-1" 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.geo4j.applet.test.LWJGLApplet.init(LWJGLApplet.java:43)
   at org.geo4j.applet.GeoAppletLauncher.startSubApplet(GeoAppletLauncher.java:511)
   at org.geo4j.applet.GeoAppletLauncher.access$3(GeoAppletLauncher.java:493)
   at org.geo4j.applet.GeoAppletLauncher$2.run(GeoAppletLauncher.java:487)

second time, and subsequent times worked fine, though speed was slow in both IE and Firefox:
QuoteGL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce 6600 GT/AGP/SSE2
GL_VERSION: 2.0.1

glLoadTransposeMatrixfARB() supported: true
340 frames in 5.0 seconds = 68.0
299 frames in 5.0 seconds = 59.8

additionally I got some random exceptions:

(startup, once, first time)
QuoteException in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
   at java.util.EventObject.<init>(Unknown Source)
   at java.awt.AWTEvent.<init>(Unknown Source)
   at java.awt.event.ComponentEvent.<init>(Unknown Source)
   at java.awt.event.WindowEvent.<init>(Unknown Source)
   at java.awt.event.WindowEvent.<init>(Unknown Source)
   at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Window.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.SequencedEvent.dispatch(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForFilter(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)

(every shutdown)
QuoteThread[AWT-EventQueue-2,4,http://nicolas.esteban.free.fr/lwjgl/-threadGroup] already has the context current
   at org.lwjgl.opengl.Context.checkAccess(Context.java:169)
   at org.lwjgl.opengl.Context.forceDestroy(Context.java:226)
   at org.lwjgl.opengl.AWTGLCanvas.destroyContext(AWTGLCanvas.java:220)
   at org.lwjgl.opengl.AWTGLCanvas.removeNotify(AWTGLCanvas.java:166)
   at java.awt.Container.removeNotify(Unknown Source)
   at java.awt.Container.removeNotify(Unknown Source)
   at java.awt.Container.remove(Unknown Source)
   at java.awt.Container.remove(Unknown Source)
   at sun.applet.AppletPanel.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

additionally Firefox didn't quit like expected - it shutdown, but the process hung in the background - probably related to the exception on shutdown
Title: LWJGL Applet
Post by: Matzon on February 23, 2006, 21:33:27
btw: Doesn't work with opera at all - but neither does the jogl launcher.
Title: LWJGL Applet
Post by: Matzon on February 23, 2006, 22:01:04
got it running full speed in IE *AND* Firefox - thou still no where near native display :(
apparently vsync was on - disabled in drivers and good to go.
Title: LWJGL Applet
Post by: Kokoni on February 24, 2006, 06:33:32
First of all, thanks for the feedback.

the "geoapplet" which is my own project will become "lwjglapplet" for generic reasons. For the issue, I will try to reproduce it, but for now I have to go to my office  :lol:
Title: LWJGL Applet
Post by: clilian on February 24, 2006, 06:33:59
Hi, I just wanted to add that according to my own tests (well, with a test case provided by Ken Russel from JOGL), LWJGL is facing the same problem than JOGL : slow frame rate for applets on firefox (around 100 fps) instead of > 2000 in IE. better than the current build of JOGL, but not yet perfect...

Regards,

Lilian
Title: LWJGL Applet
Post by: Matzon on February 24, 2006, 07:26:17
I get full speed in both. Where is that jogl test case ?
Title: LWJGL Applet
Post by: clilian on February 24, 2006, 07:47:01
well it's just a simple applet with a rotating triangle (I've put the lwjgl jars and natives in the jre/lib/ext and jre/bin folders).

On my laptop JOGL/LWJGL run at full speed with FF, on my desktop pc both are dog slow (but LWJGL is faster).

Lilian
Title: LWJGL Applet
Post by: radvani on March 23, 2006, 23:59:36
Hi everyone,

So, did anyone manage to get that Firefox LWJGL applet up to speed with explorer?

Also, is an LWJGLAppletLauncher available now in the CVS tree? I haven't seen it yet. I'd like to give it a shot and work on debugging some of the issues.

Raj
Title: LWJGL Applet
Post by: radvani on March 24, 2006, 15:56:58
I just realized my previous post made no sense: it should have read, "did anyone get that LWJGL applet to run fast in firefox?"
Title: LWJGL Applet
Post by: renanse on May 26, 2006, 18:35:42
Is there anything further on this?  When I run the example a few posts above in FireFox, fraps is maxing out at 999FPS, so it looks like things are running nicely....  Is there an official way of displaying in an applet in lwjgl yet?
Title: LWJGL Applet
Post by: Matzon on May 26, 2006, 20:34:33
nothing concrete unfortunately. UlfJack has made something though:
http://www.random-equation.net/xjar

works fine for me, but the demo doesn't exit cleanly, so you get a bunch of errors when nuking the applet.