Deploying with the LWJGL Applet Loader 2 - Customising

From LWJGL
Jump to: navigation, search

Introduction

Basics - Part 1

Customisation - Part 2

Compression - Part 3

Polish and Tweaks - Part 4


You can customise the AppletLoader to better fit and integrate into your webpage and even have a nice looking animation playing while it loads.


Logo and Progress Bar

You can change the logo or progress bar used by the AppletLoader. You can use any image format supported by the Java Toolkit, this includes jpeg, png and animated gif files. The parameters used to specify the logo and progress bar are al_logo and al_progressbar. To produce the progress bar effect the progress bar image will start totally clipped and as the appletloader loads it will unclip horizontally until its fully visible.

<param name="al_logo" value="appletlogo.gif">
<param name="al_progressbar" value="appletprogress.gif">

The images you point to can either be insides the jars you specify in the applet archive tag e.g. in lwjgl_util_applet.jar, outside the jars on the codebase or any other location on the web.

Both the logo and progress bar images will be centred on the applet window so keep this in mind if you want for example the progressbar to align on a certain part of the logo. One way to ensure this is by making the logo and progressbar images the same size.

Finally if for whatever reason you don't want a logo and/or the progressbar to be shown you can just set the value to "" and nothing will be shown or loaded.

<param name="al_logo" value=""> 


Color

You can change the background color of the AppletLoader using the boxbgcolor parameter and the foreground (text color) using the boxfgcolor parameter.

<param name="boxbgcolor" value="black">
<param name="boxfgcolor" value="#FF0022">

You can specify the color in either RGB format (0-255) example "255,0,0" (red) or you can use html hex colors in the "#FFFFFF" format or you can use any string value of an existing java.awt.Color example "red","blue","green", etc


Integration with the LWJGL Native Display

LWJGL uses a native window system and this is initialised when you call Display.create(). Generally when the window is created you get a clear black screen while everything like opengl, some initial resources, etc initialise. If your AppletLoader and LWJGL Applet inital background color isn't black, you get an odd looking effect, such as a sudden black flash as your applet switches from the AppletLoader to the LWJGL Applet.

To remedy this you can choose the initialisation color of LWJGL native window. This is done by setting Display.setInitialBackground(float r, float g, float b). Where r,g,b are float values 0.0 to 1.0.

Display.setInitialBackground(0, 1.0f, 0); // green background
// make sure the initial background color is set before create() is called
Display.create();


Pre-AppletLoader Customisation

Before the Java Plugin downloads any of the AppletLoader Jars and even initialises the AppletLoader, it will display its own Java logo, this is generally the java teacup logo with some spinning arrows around it. You may consider this fine, however many will want to hide it for various reasons.

To do this you simply set the image logo to use nothing.

<param name="image" value="">

You can also make the preloader java logo use the same logo as that of the AppletLoader so the whole startup just looks like one seamless loader. This is useful as the preloader java logo appears quickly (before the AppletLoader has started) and is displayed while the permission dialog is showing.

To do this you have to set a few things to position the preloader logo exactly like the AppletLoader logo. Firstly you remove the useless border java's preloader adds by setting boxborder to false, and second you center the image to match the AppletLoader behaviour by setting centerimage to true. Lastly you set the logo to the same as the one used by the AppletLoader al_logo variable.

You should have something that looks like the following:

<param name="boxborder" value="false">
<param name="centerimage" value="true">
<param name="image" value="logo.gif">

Just a note the Java Plugin preloader has a limitation in that it only supports gif and jpeg images and they must be outside any jars.


Introduction

Basics - Part 1

Customisation - Part 2

Compression - Part 3

Polish and Tweaks - Part 4


Tutorial Credit - Ninja Cave