Java OpenGL Demos with LWJGL

by napier <at> potatoland.org

These applications demonstrate the use of the LWJGL Java/OpenGL binding to create simple 3D scenes with lighting, textures, mouse interaction, and 2D overlays. They contain sample Java code and utility classes that wrap the most critical and commonly used features of OpenGL.

These demos are meant to provide practical reusable code for programmers learning the LWJGL OpenGL Java binding. Although they illustrate aspects of OpenGL they are not meant to be OpenGL tutorials. For excellent tutorials on OpenGL go to Nehe at nehe.gamedev.net or Nate Robbins tutorials

Requires LWJGL version .97 and Java JRE 1.4_1 or higher. Tested in Win32 and Mac OS X.

Updated Aug 7 2005 (converted to lwjgl .97, added GLModel.java).

 

Source code, docs, links:

All demos, source and libes for Win32
All demos, source and libes for Mac OS X

GLApp.java
GLImage.java
GLModel.java
SoundScape.java

Documentation


OpenGL "Red Book"
OpenGL "Red Book" 1.1 online

More LWJGL Demos by Chman


 

I use these classes as the foundation code to make digital artwork

GLApp and GLImage base classes

GLApp.java contains functions to init and run an OpenGL app using LWJGL, including many useful functions to load images, convert pixel formats, setup display, keyboard, mouse, create textures, lights, etc. GLImage.java loads and stores an image, converting pixels for use in OpenGL. GLModel.java uses part of Peter Walser's IDX3D graphics library to load 3DS models. This piece can be easily removed to use alternative mesh loading code.

GLApp.java,   GLImage.java,   GLModel.java,   idx3d  

Basic Scene

Creates a simple 3D scene with lighting, textures, and mouse interaction. Demonstrates basic features such as setting up the display, handling mouse input, and running a rendering loop.

Source code

Ortho vs. Perspective

Combines perspective rendering with a 2D overlay.

Source code

Navigation

Use arrow keys to move around scene.

Source code

Drawing Text using texture mapping

Draws text by mapping a texture image of a font onto quads. Text is drawn over the 3D scene. Scene can be navigated; text stays in place.

Source code

OpenAL Audio demo

Uses OpenAL to place sounds in a space and sync the sound with motion in the space. The SoundScape class wraps OpenAL and provides functions to load sounds, place them in the scene, set listener position, etc.

Source code for demo       SoundScape.java   WaveData.java  

Model Loading

Use GLModel to load and render a 3DS model. Places the model in a simple scene with lighting and arrow-key navigation.

Source code for demo       GLModel.java  

All Demos

The complete set of demos, including the LWJGL libraries for Windows. Ready to run.

Source code and libraries for Win32
Source code and libraries for Mac OS X