Java OpenGL Demos with LWJGL
 

These applications demonstrate basic features of OpenGL, using the LWJGL Java/OpenGL binding.

The demos are built on the GLApp foundation class, that provides easy access to OpenGL through a light, thin layer of clearly commented code. GLApp is intended for programmers that are new to OpenGL and want to get results quickly without having to learn a heavy code framework or game library. Most of the code in GLApp can be easily cut-n-pasted to other programs.

Some of the features provided by GLApp: initialize and run the application, handle timing, load images, convert pixel formats, create textures, lights and materials, load OBJ and 3DS models, render text, save screenhots, stencil buffer operations, create custom cursors, and more. GLApp has been extended with additional classes that provide advanced features such as: cameras, dynamic fonts, and shadows.

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 2 and Java JRE 1.4_1 or higher. Tested in Win32 and Mac OS X.

All the GLApp source code and demos are released under the Simplified BSD license, which allows this code to be reused and modified.

Updated May 23 2009 (fixed Mac window size).
Updated Feb 5 2009 (fixes, and new GLLine class).
Updated Jan 3 2009 (now compatible with lwjgl 2).

napier <at> potatoland.org

 
 

Source code:

All demos, source and libes for Win/Mac

Eclipse project for Win/Mac

glapp.jar version .5

browse source code

LICENSE
 


Documentation:

Reference (Javadoc)

Instructions to setup Eclipse GLApp project
 


Resources:

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

     

     
 


Projects:

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

GLApp and GLImage base classes

This "Hello World" app is a bare bones demo of an OpenGL program made with GLApp. GLApp.java contains functions to initialize and run an OpenGL app using LWJGL, including many useful functions to load images, setup display, keyboard, mouse, create textures, lights, etc. GLImage.java loads images for use in OpenGL.

GLApp_Demo_HelloWorld.java     GLApp.java   GLImage.java  

Light and Materials

Use textures, light and material properties to illuminate a small scene. Animate the scene with GLApp's timer.

GLApp_DemoLight.java

Ortho vs. Perspective

Combines perspective rendering with 2D rendering. Use "ortho" mode to layer an image over a 3D scene, create a custom cursor, and draw text on screen.

GLApp_DemoOrtho.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. Airplane model by Michael Speigner, available on TurboSquid.com

GLApp_DemoModel.java       glmodel  

Cameras

Use two cameras to move the viewpoint in a scene. Use billboarding to orient an object to face another. Airplane model by Michael Speigner, available on TurboSquid.com

GLApp_DemoCamera.java       GLCamera.java

Big Text

Draws text by mapping a texture image of characters onto quads. Text can be drawn at any size, over the 3D scene or textured onto geometry, using any font supported by Java.

GLApp_DemoText.java       GLFont.java

Fat Lines

Create wide smoothly joined lines that can be textured and expanded into 3D shapes.

GLApp_DemoLine.java       GLLine.java

OpenAL Audio demo

Uses OpenAL to place sounds in a space. The SoundScape class wraps OpenAL and provides functions to load and position sounds, control volume and pitch, and set listener position.

GLApp_DemoSound.java       glsound