[RotBoxES MIDlet PIC] JOGL-ES Chapter 1.   Rotating Boxes


[ This chapter does not appear in the book. ]

With the release of the Java Wireless Toolkit (WTK) 2.5, developers now have two 3D APIs to play with in their MIDlets -- the familiar M3G (also known as Mobile 3D, and JSR-184), and a new Java binding for the OpenGL ES API (JSR-239). The new API doesn't have an official nickname or abbreviation, but I'll be using the name JOGL-ES.

I examined M3G at some length in a series of chapters available at the Killer Game Programming in Java website. Starting with this chapter, I'll run through the basics of programming with JOGL-ES.

I'll begin by describing a basic programming framework for utilizing JOGL-ES inside a MIDlet. It's essentially an animation loop inside a thread, which repeatedly updates the application's state, renders the 3D scene, and perhaps sleeps for a while so that the animation maintains the desired frame rate. This chapter's example also shows how to:

The screenshot at the top of the page shows the application running. The two textured cubes continuously rotate around the y-axis; the one with the brick texture is centered at the origin, while the wooden cube orbits a short distance from the y-axis. A cube's texture is repeated on each of its faces.

The floor is covered in a grid image with x- and z- axes.

The text at the top of the display is drawn by 2D commands after the 3D scene has been rendered. The red text on the left-hand side shows positional, rotational, and mode information for the camera, and the black number on the right is how long the execution of the current frame took to complete in milliseconds.




Dr. Andrew Davison
E-mail: ad@fivedots.coe.psu.ac.th
Back to my home page