Home | History | Annotate | Download | only in drawing
      1 page.title=OpenGL
      2 @jd:body
      3 
      4 <p>Android includes support for 3D hardware acceleration. This functionality is
      5 accessed via the OpenGL API &mdash; specifically, the OpenGL ES API.</p>
      6 
      7 <p>OpenGL ES is a flavor of the OpenGL specification intended for embedded
      8 devices. Versions of OpenGL ES are loosely peered to versions of the primary
      9 OpenGL standard. Android currently supports OpenGL ES 1.0, which corresponds
     10 to OpenGL 1.3. So, if the application you have in mind is possible with OpenGL
     11 1.3 on a desktop system, it should be possible on Android.</p>
     12 
     13 <p>The specific API provided by Android is similar to the J2ME JSR239 OpenGL
     14 ES API. However, it may not be identical, so watch out for deviations.</p>
     15 
     16 <h2>Using the API</h2>
     17 
     18 <p>Here's how to use the API at an extremely high level:</p>
     19 
     20 <ol>
     21 <li>Write a custom View subclass.</li>
     22 <li>Obtain a handle to an OpenGLContext, which provides access to the OpenGL functionality.</li>
     23 <li>In your View's onDraw() method, get a handle to a GL object, and use its methods to perform GL operations.</li>
     24 </ol>
     25 
     26 <p>For an example of this usage model (based on the classic GL ColorCube),
     27 see
     28 <a href="{@docRoot}samples/ApiDemos/src/com/example/android/apis/graphics/GLView1.html">com.android.samples.graphics.GLView1.java</a>
     29 in the ApiDemos sample code project. A slightly more sophisticated version showing how to use
     30 it with threads can be found in 
     31 <a href="{@docRoot}samples/ApiDemos/src/com/example/android/apis/graphics/GLSurfaceViewActivity.html">com.android.samples.graphics.GLSurfaceViewActivity.java</a>.
     32 </p>
     33 
     34 <p>Writing a summary of how to actually write 3D applications using OpenGL is
     35 beyond the scope of this text and is left as an exercise for the reader.</p>
     36 
     37 <h2>Links to Additional Information</h2>
     38 
     39 <p>Information about OpenGL ES can be
     40 found at <a title="http://www.khronos.org/opengles/"
     41 href="http://www.khronos.org/opengles/">http://www.khronos.org/opengles/</a>.</p> 
     42 
     43 <p>Information specifically
     44 about OpenGL ES 1.0 (including a detailed specification) can be found
     45 at <a title="http://www.khronos.org/opengles/1_X/"
     46 href="http://www.khronos.org/opengles/1_X/">http://www.khronos.org/opengles/1_X/</a>.</p>
     47 
     48 <p>The documentation for the Android {@link javax.microedition.khronos.opengles.GL
     49 OpenGL ES implementations} are also available.</p>
     50 
     51 <p>Finally, note that though Android does include some basic support for
     52 OpenGL ES 1.1, the support is <strong>not complete</strong>, and should not be relied
     53 upon at this time.</p>
     54