Using LWJGL with Applets

NOTE: The old LWJGLInstaller has been deprecated. The documentation has been moved here.

With the new AppletLoader class it's a breeze to run an LWJGL applet in a browser. Simply create a new class that inherits from an Applet and add an AWTGLCanvas to its layout. Package this around the AppletLoader and you're all set.

AppletLoader explained

Unfortunately to be able to run LWJGL you will need to place a local copy of LWJL's native files (lwjgl, openal, jinput etc.) onto the end users system. To do this you will need a signed applet to do the messy work. Fortunately we provide signed jars that you can use to run a generic lwjgl applet. As long as your application doesn't use any features that require signed access, then you should have no problems (If you do need signed access, then you should resign it all with your own valid certificate).

Enter AppletLoader. This class will do all of the work for you, and finish off with substituting itself with your applet! You will need a normal applet tag html, with the lwjgl_util_applet.jar as the code base and org.lwjgl.util.applet.AppletLoader as the code to run. The AppletLoader takes a list of arguments to control its behavior. All of them passed as normal applet param tags:

  • al_title - Name of directory to cache files into (user temp dir + al_title)
  • al_main - Name of class to run when done initializing - must be an applet
  • al_logo - Logo to paint while doing the work required
  • al_progressbar - Progressbar to paint (width clipped to percentage done)
  • al_jars - Your application support jar files
  • al_windows - Name of lwjgl native support files for windows
  • al_linux - Name of lwjgl native support files for linux
  • al_mac - Name of lwjgl native support files for mac
  • al_version - (optional) Version of Applet, important otherwise applet won't be cached, version change will update applet, must be int or float.
  • al_bgcolor - (optional) Background color to paint with, defaults to white
  • al_fgcolor - (optional) Foreground color to paint with, defaults to black
  • al_errorcolor - (optional) Error color to paint with, defaults to red
  • al_debug - (optional) Whether applet will load and extract resources with a delay (to be able to see the loader process)

Getting started

The easiest way to get started, is to get the applet distribution from sourceforge (lwjgl_applet-<version>.zip). This package contains all the needed files, including skeleton html. From the package get the following files:

  • appletloader.html
  • jinput.jar
  • linux_natives.jar
  • lwjgl.jar
  • lwjgl_util_applet.jar
  • macosx_natives.jar
  • windows_natives.jar

These are the files that are provided signed and serves as the base for any LWJGL applet.

  1. Create a new jar with your own applet.
  2. Place it in the same folder where you placed the above files.
  3. Modify appletloader.html, particularly:
    • al_title - your applets name (typically)
    • al_main - full package and class name of your applet
    • al_jars - change it to include your jar - and remove any superfluous packages (res.jar, lwjgl_util.jar), if any.
    • al_debug - set this to true until you've confirmed its all working as expected.
    • test - remove this, only used by the AppletLoaderTest

Open the appletloader in your browser and confirm its all working :)

 
lwjgl/tutorials/applet.txt · Last modified: 2008/02/03 21:13 by matzon
 
Recent changes RSS feed Creative Commons License Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki