Introduction


 TWL is a very good library to create a 2D Graphical User Interface (GUI) in a 3D-setting. This is not only very interesting, but even a requirement if you want to make decent games.

When I first wanted to try out TWL, I found myself stuck in missing libraries, missing resource and what not. Luckily, the author of the library (Matthias Mann) was available at IRC to help me out. After half an hour or trail-and-error, I finally managed to get everything working.

Many people may come across these problems, and therefore I decided to make a Wiki page where people are informed of anything they need to know to avoid them.

Please note that I used Netbeans when setting up the project, but this will most likely be somewhat similar in Eclipse. Remember, this Wiki tries to explain everything as simple as possible, in order to avoid any problems you might encounter.



 What you need

 * Obviously, a JDK. TWL was made solely in JDK 1.5, but you can also use JDK 1.6. Explained later is how to set up your project to work with 1.6.

* The test project, which includes both the TWL library itself and an extra example project. There are many examples in there, which you can use when you are developing your own GUI

* The following libraries:

  • LWJGL, you need the latest version, versions older than 2.4 will not work
  • XPP3


 Setting up your project

* Extract the twl.zip file file anywhere on your PC, and you will have 2 project folders: TWL and TWLExamples.
 * Extract the LWJGL library anywhere on your PC. Then go into the folder 'lwjgl-2.4.2', select all folders, and copy them into your TWL project folder. Do the same for the TWLExamples project.
 * Extract the XPP3 library anywhere, and copy the file 'xpp3-1.1.4c.jar' into yoru TWL project folder. You do not need anything else from XPP3.
 * Open up Netbeans
 * Do 'Open Project' and open the project 'TWL', do the same with 'TWLExamples'. You will get reference errors, which we will resolve right away.


 Resolving the missing libraries

Now you will have 2 projects with missing libraries.
 
 First of all: if you are using JDK 1.5, you will can skip this step. For those who use 1.6, right-click on the project and click 'Properties'. Select 'Libraries' and select 'JDK 1.6 (Default)'. Do this for both projects.

 Now that the JDK has been set correctly, we can resolve the other library reference errors.

Right-click the TWL project, and select 'Properties'. Select 'Libraries' and remove all libraries.
Click 'Add JAR/Folder...'. Browse to the place where you put 'xpp3-1.1.4c.jar', select the file and click 'Open' to add it.
Do the same for LWJGL. For that, you need to browse to the 'jar' folder of LWJGL, and select 'lwjgl.jar'.

For the TWLExample project, right-click it, select 'Properties', 'Libraries', and remove all libraries aswell. Add the lwjgl.jar library (same as with the TWL project). Then click 'Add Project...' and select the TWL project.

 All reference problems for both projects have now been solved.


 But we're not ready yet...

If you would now try to run any of the TWLExample files, it would give you 'Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path'. This is because you need to set the native libraries for lwjgl. These are unique for every Operating System.

To add the native libraries to your TWLExamples project:
 * Right-click the project and click 'Properties'. Click 'Run'. There you will see '-ea -DwarnOnUnhandledAction -Djava.security.policy=applet.policy' in the VM Options field.
 * Now you need to know what Operating system you have.
 * If you have Windows, this is what you have to do: behind the currently set VM Options, you need to add the following: -Djava.library.path="native/windows/". For linux, this would be -Djava.library.path="native/linux/"

Now, you can run any file in your TWLExamples project just fine :) we recommend trying them all, and playing a bit around with them.


Creator: Michiel Hebben on 2010/06/13 14:18
This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 1.8.17790 - Documentation