-
Notifications
You must be signed in to change notification settings - Fork 65
Setup
This small guide is just to show you how to setup LWJGL3.
- The very first step is of course downloading the library, you can get it here.
This tutorial was made with LWJGL 3.0.0a. - After that just extract the
lwjgl.zip
file to any location you want it to be. - You should now have the folders
doc
,jar
andnative
and a filesrc.zip
.
Now that you have downloaded the library start up your IDE.
You have to do the following steps just once.
- Go to Tools -> Libraries
- Click on New Library
- Type any name for the library like LWJGL3
- Select the newly made library
- At the Classpath tab click on Add JAR/Folder... and go into the folder where you extracted the
lwjgl.zip
and go into thejar
folder and selectlwjgl.jar
- At the Source tab click on Add JAR/Folder... and go into the folder where you extracted the
lwjgl.zip
and selectsrc.zip
- At the Javadoc tab click on Add ZIP/Folder... and go once again in the folder where you extracted
lwjgl.zip
and go into thedoc
folder and selectjavadoc.zip
Now you can create a new project to test your setup. The following steps have to be done at each project.
- Create a new Java Application project via File -> New project...
- In your project right-click on Libraries and select Add Library...
- Of course select your LWJGL3 library
- Now right-click your project and click on Properties
- Go to the Run category
- Click into VM Options and type
-Dorg.lwjgl.librarypath="<path to the extracted lwjgl.zip>/native
with this LWJGL3 will choose the right native files for you, depending on your system.
Note that you could also set it programmatically withSystem.setProperty("org.lwjgl.librarypath", "<path to the native folder>")
.
The following steps have to be done for each project.
- Create a new project via File -> New -> Java Project
- Right-click your project and select Properties
- Go into the Java Build Path category
- Select the Libraries tab
- Click on Add External Jars..., then go to your folder where you extracted
lwjgl.zip
and go in thejar
folder and selectlwjgl.jar
- Expand lwjgl.jar
- Select Source attachment and click on Edit...
- Click on *External File... and go to your folder where you extracted
lwjgl.zip
and selectsrc.zip
- Select Javadoc location and click on Edit...
- Click on Browse... next to Archive path, go to your folder where you extracted
lwjgl.zip
and into thedoc
folder and selectjavadoc.zip
- Now in your main menu select Run -> Run Configurations...
- Select the Arguments tab
- Click into VM arguments and type
-Dorg.lwjgl.librarypath="<path to the extracted lwjgl.zip>/native
with this LWJGL3 will choose the right native files for you, depending on your system.
Note that you could also set it programmatically withSystem.setProperty("org.lwjgl.librarypath", "<path to the native folder>")
.
The following steps have to be done for each project.
- Create a new Java project via File -> New Project
- In your main menu select File -> Project Structure
- Select the Modules category
- Select the Dependencies tab
- Click on the green + -> Library... -> Java and choose your LWJGL3 global library, if you haven't made that before do the following steps
- Click on the green + -> Library... -> Java, then go to your folder where you extracted
lwjgl.zip
and go in thejar
folder and selectlwjgl.jar
- Click on the green +, then go to your folder where you extracted
lwjgl.zip
and selectsrc.zip
- Click on the green +, then go again to the folder where you extracted
lwjgl.zip
and go into thedoc
folder and selectjavadoc.zip
- Set the Level to Global Library so you can add the library in a new project faster
- Click on the green + -> Library... -> Java, then go to your folder where you extracted
- Now in your main menu select Run -> Edit Configurations
- Click on the green + and select Application
- Click into Main class and type the path to your main class
- Click into VM options and type
-Dorg.lwjgl.librarypath="<path to the extracted lwjgl.zip>/native
with this LWJGL3 will choose the right native files for you, depending on your system.
Note that you could also set it programmatically withSystem.setProperty("org.lwjgl.librarypath", "<path to the native folder>")
.
After setting up your IDE just copy and paste this code, then run it. If it runs successfully then your setup is complete.
On Mac OS X you may need to add -XstartOnFirstThread
as JVM argument to start the application.
You may also need to add -Djava.awt.headless=true
as JVM argument to get access to the AWT classes.
If you get Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to load the native library: lwjgl
you have not set the org.lwjgl.librarypath
correctly. This is the most important part when setting up your project, so make sure you have set the native path to the right folder.
import org.lwjgl.Sys;
public class TestSetup {
public static void main(String[] args) {
System.out.println("LWJGL Version " + Sys.getVersion() + " is working.");
}
}
After setting up the library and your IDE it is time to get started.
This tutorial and it's source code is licensed under the MIT license.
Written by Heiko Brumme, Copyright © 2014-2018