Lwjgl (lightweight Java game Library)

Source: Internet
Author: User

Lwjgl (lightweight Java game Library) helps Java programmers develop games of commercial nature. lwjgl provides developers with easy-to-use APIs to access OpenGL (Open Graphics Library) and openal (open audio library). It also provides APIs for Operation controllers (gamepads, steering wheel, and joystick.

Lwjgl is a Java package bound to OpenGL. You can use lwjgl to write OpenGL programs and release them as jar packages.

My IED is intellij. To include Native files and external jar packages, it is troublesome to release it.

When using lwjgl, you must first import the corresponding jar and native files. There are two methods to connect native files during runtime:

1: Add-djava. Library. Path = NATIVE/windows to the VM option running parameter (native/Windows is the place where DLL files are stored, generally under the project)

2: system. setproperty ("org. lwjgl. librarypath ", system. getproperty ("user. dir ") +"/native/Windows "); this method is written in the program portal, the first line in the main method

The following is a package:

Project directory structure:

Package in intellij is very simple. CTRL + Shift + S, enter the project structure, select artifacts, add jar (the plus sign in the middle), empty and from modules with dependency, if you select empty, you need to customize other jar or class to be added. You have not found how to add the native file in the dependency, so select from modules with dependency directly. Here it is OK, And the artifacts generated by build is as follows:

The native folder is manually copied to it, and then the native directory is manually specified in the Code,
System. setproperty ("org. lwjgl. librarypath", system. getproperty ("user. dir") + "/native/Windows ");
System. getproperty ("user. dir") is the directory where the jar package runs.

Packaging here is different from packaging empty:

Empty mode will hit the dependent package under the current package.

The from modules with dependency method does not package the dependent jar to the current jar package.
Therefore, select the from modules with dependency mode. Now, in the intellijartifact output directory, click Run released jar and run OK.

The running interface is as follows:

Package the project into a jar package:

There are a lot of packaging tools. Here we choose idea.
Note that the DLL file has been imported into the current jar directory, so you do not need to set
2: system. setproperty ("org. lwjgl. librarypath", system. getproperty ("user. dir") + "/native/Windows ");
The packaging result is as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.