Build lwjgl Development Environment on Mac OS (Mac OS 10.8)

Source: Internet
Author: User
1. Check the JDK installation status.

1. How to set the default Java version in Mac?

Let's take a look at the Java link on Mac:
Go to the corresponding directory: CD/usr/bin

View the Java link: ls-l Java
Localhost: Bin root # ls-l Java
Lrwxr-XR-x 1 root wheel 74 May 18 Java->/system/library/frameworks/JavaVM. Framework/versions/current/commands/Java
We can see that Java is connected to the current version. So what version is this? In fact, the current in Mac is just a shortcut to facilitate setting the default Java.

We will continue to analyze how to configure environment variables:

1. In ~ /. Add JDK environment variables to bash_profile

JAVA_HOME=/Library/Java/Home 

2. Check the address of the "java_home =/library/Java/home" link and find:

Lrwxr-XR-x 1 root wheel 48 8 10 home->/system/library/frameworks/JavaVM. Framework/home

3. Check the link "/system/library/frameworks/JavaVM. Framework/home" and find:

Lrwxr-XR-x 1 root wheel 24 8 10 home-> versions/currentjdk/home

Then, we can use"

JAVA_HOME=/Library/Java/Home 

"The configuration path actually points to"/system/library/frameworks/JavaVM. Framework/versions/currentjdk/home/". This path is the actual file path of the current JDK;

2. Download The lwjgl Development Kit

Download the latest library: Address: http://www.lwjgl.org/download.php

3. Configure the development library for the lwjgl development kit.

After the downloaded file is downloaded, the following directory structure is obtained:

-Jar

-- Applejavaextensions. Jar
Asm-debug-all.jar
-- Jinput. Jar
-- Lwjgl_test.jar
-- Lwjgl_util_applet.jar
-- Lwjgl_util.jar
Lwjgl-debug.jar
-- Lwjgl. Jar
-- Lzma. Jar

-Doc

-Res

-Native

-- Linux
-- MacOSX

--- Libjinput-osx.jnilib
--- Iblwjgl. jnilib
--- Openal. dylib

-- Solaris
-- Windows

Configuration:

Current Directory

Zhujinbaomatomacbook-Pro: currentjdk zhuse7en $ ls
Classes home libraries Resources
Commands info. plist MACOs version. plist
Zhujinbaomatomacbook-Pro: currentjdk zhuse7en $ pwd
/System/library/frameworks/JavaVM. Framework/versions/currentjdk

1. Copy the jar Library

zhujinbaomatoMacBook-Pro:Classes zhuse7en$ sudo scp ~/Downloads/lwjgl-2.8.4/jar/*.jar .

2. Copy the native JNI Library

zhujinbaomatoMacBook-Pro:Libraries zhuse7en$ sudo scp ~/Downloads/lwjgl-2.8.4/native/macosx/*.jnilib  .
4. Create a project and add a dependency Library

1. Create a project

2. Add the main program file first. Java

3. Add code to first. Java

Import Org. lwjgl. lwjglexception; import Org. lwjgl. input. keyboard; import Org. lwjgl. openGL. *; public class first {public first () {try {display. settitle ("kame"); display. create (); // fullscreen, available // display. setfullscreen (true); display. setdisplaymode (New displaymode (800,600); display. setvsyncenabled (true);} catch (lwjglexception e) {e. printstacktrace () ;}} public void start () {gl11.glmatrixmode (Gl11.gl _ projection); gl11.glloadidentity (); gl11.glortho (0,800,600, 0, 1,-1); gl11.glmatrixmode (gl11.gl _ modelview); While (! Display. iscloserequested () {// clear the screen and depth buffer gl11.glclear (gl11.gl _ color_buffer_bit | gl11.gl _ depth_buffer_bit); // set the color of the Quad (R, G, B, a) gl11.glcolor3f (0.5f, 0.5f, 0.8f); // draw quad gl11.glbegin (gl11.gl _ QUADS); gl11.glvertex2f (100,100); gl11.glvertex2f (100 + 200,100 ); gl11.glvertex2f (100 + 200,100 + 200); gl11.glvertex2f (100,100 + 200); gl11.glend (); display. update ();} display. destroy ();} public static void main (string [] ARGs) {New first (). start ();}}

4. Add the dependent Library (the JNI file can be run directly if the corresponding JAR file is added according to the preceding requirements, but it cannot be found)

Note: After selecting the newly created game project, go to properties-Java build path

4.1 Add jar Extension

4.2 open lwjgl. jar and add JNI Library

4.3 expansion completed after confirmation

5. Run demo

Right-click Project> Run as> JAVA application to compile the program. If the program runs smoothly, your demo can run smoothly;

Related Article

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.