JOGL::www.sjonesart.com/gl.php

If you are using Firefox you may have aesthetic issues as Firefox does not seem to be loading the following pages into the iframe as it ought.

It strikes me that the learning curve for getting into JOGL is steeper than getting into LWJGL, mainly due to the helper classes LWJGL ports such as keyboard handlers. The nice thing about JOGL is that its function calls remain closer to the openGL API and easier to follow in the RedBook eg (but may not be a good thing if it means passing more variables over the JNI barrier). Anyway, as I figure stuff out I like to post it as tutorials (otherwise I am bound to delete and lose it). And besides, the moral thing to do is to facilitate people's self-determination and self direction... the immoral thing is secrecy and intellectual property rights... follows from Kant's deontology

When I am trying to figure stuff out using the web I mostly look for working examples that I can disect to get to the guts of the problem and that pretty much informs the tutorials I have posted. I do not post code that I have not already successfully run in NetBeans 6.9.1 using Java 6. My graphics card is about a year old ATI with the relevant openGL. Rather than write screeds repeating what the code obviously does, I have heavily commented the code and will only write about stuff that is conceptually informative.

01: Keys and Mouse

The code is here. The code provides a basic JOGL setup using GLCanvas. User definable keyboard and mouse events are stored in six boolean variables that are polled every loop.

02: First Person Shooter

The code is here. In this tutorial the events explained in the last are used to construct a model view matrix that gets loaded every loop. This matrix positions and rotates the world about the player giving the illusion that the player is moving through the world. Also included is a weapon that moves with the player.

03: VBO

The code is here. VBO (vertex buffer objects) are becoming the standard means for storing and drawing data in OpenGL. This tutorial also loads data exported from Blender 2.56. The Blender exporter script is here. To run the script you need to open the text editor and paste the code into it, Alt P will run the code. It only works if only one mesh object is selected (object mode), and that model must be textured. You must define filepath at the top of the script. The exported file used for the tutorial is found here. This tutorial also includes code to parse the exported .txt file.

04: Shader Setup

The code is here. The tutorial sets up a simple vertex and fragment shader that colors the weapon the player holds. The color is passed to the shader as a uniform variable initialized in the draw method of the JOGL code. You will need the floor.txt link to above.

05: Texture Using Shaders

The code is here. The tutorial sets up a texture from a png image and passes it to the fragment shader which draws it onto the floor. Any png image will do just ensure you set the filename correctly. Here is a useful bit of code for figuring out what your environment believes is the root folder to begin looking for files/images etc... if you stick images here your environment is bound to find them:

File cdir=new File("."); System.out.println(cdir.getAbsolutePath());

By the way, I forgot in include player.vert and player.frag code that needs to be added. This code can be found in the previous tutorial.

06: Multi-texturing and Defining Your Own Vertex Attributes

The code is here. OpenGL has a set of standard arrays for certain vertex attributes; position, normals, coords, etc. Shaders, however, can require per vertex data that openGL has no standard array for; bump mapping requires per vertex data on tangents and bitangents (although the bitangent can be calculated in the shader from the normal and the tangent, it can also be pre-calculated and sent to the shader as an attribute). As well as setting up multi-texturing, this tutorial sends tangent and bitangent data to the vertex shader.

For the tutorial you will need a png file to be a texture for the floor, and a normal map of that file. You will also need either the Blender export script so you can export your own floor model, or the exported .txt file used in previous tutorials. Both of these can be downloaded from the 03: VBO tutorial.