< Zurück | Inhalt | Weiter >

4.7.1 Immediate mode

Some might say that there is no pure immediate mode in Java 3D, as you must always create the View side of the scenegraph to activate the Java 3D rendering loop, within which the immediate mode code will execute. Syntactic quibbles aside, the ImmediateTest.java example renders an array of points in immediate mode and outputs the rendered FPS to standard output.

The minimal Java 3D scenegraph to activate the View rendering loop consists of a VirtualUniverse, a single Locale, and a BranchGroup with a single ViewPlatform child Node. A View is attached to the ViewPlatform and a Canvas3D is registered with the View (figure 4.17).


Figure 4.17 The minimal Java 3D scenegraph required for immediate mode rendering. The Canvas3D implements the immediate mode rendering callbacks

During the Java 3D rendering loop, the application developer is given several opportunities to prepare and render immediate mode information. The rendering loop calls four methods on the Canvas3D registered with the View. By overriding these callback methods, application−specific immediate mode rendering can be performed.

Canvas3D callback methods are

preRender: Allow you to prepare any data structures for rendering.

renderField: Can be overridden to perform the rendering.

postRender: Called when rendering is complete.

postSwap: Called once the rendered frame has been made visible to the user.


From ImmediateTest.java