Java Reference
In-Depth Information
made it a viable choice for mobile device vendors to include in their devices. The pairing of
M3G with OpenGL ES is ideal since it greatly facilitates the implementation of M3G for mobile
device vendors, allowing them to adopt 3D graphics with less effort (and cost). More information
on OpenGL ES can be located at
http://www.khronos.org/opengles/
Figure 15-1 depicts the relationship between M3G, MIDP, OpenGL ES, and CLDC.
Figure 15-1. M3G, MIDP, CLDC, and OpenGL ES relationship
In Figure 15-1, you can see the dependence of M3G on CLDC, MIDP, and potentially a
native 3D implementation such as Open GL ES.
Rendering 3D Graphics
The javax.microedition.m3g package contains all the 3D API classes.
Similar to the 2D Graphics context class that you get within the paint() method of a Canvas ,
you will need an instance of the Graphics3D class to render 3D graphics. Graphics3D is a singleton.
You can obtain the one and only instance using this factory method:
static Graphics3D getInstance();
To render a single frame of 3D graphics, you need to follow these steps:
Obtain the Graphics3D instance.
1.
Obtain a 2D Graphics instance (from Canvas , GameCanvas , etc.), which will be used to
display the frame.
2.
Bind the Graphics3D instance to the 2D Graphics instance; the frame of the 3D image
will be drawn onto the 2D context.
3.
Search WWH ::




Custom Search