The Android system includes OpenGL (Open Graphics Library), which provides high-performance support for 2D and 3D Graphics, especially OpenGL ES APIs. OpenGL is a cross-platform graphics API that specifies a standard software interface for 3D graphics processing. OpenGL ES is an OpenGL specification for embedded devices. Since Android1.0, it has provided support for OpenGL ES1.0 and 1.1API specifications. Since Android2.2 (API Level 8), the framework began to support OpenGL ES2.0 API specifications.
Note: The APIS specified by the Android framework are a bit similar to the JSR239 OpenGL es api of j2m2. however, they are still different. If you are familiar with the JSR239 specification of j2m's, be careful with the changes.
Basic
Android uses its framework API and NDK (Native Development Kit) to support OpenGL. This article focuses on the Android framework interface. For more information about NDK, see Android NDK (www.2cto.com)
There are two OpenGL es api class libraries in the Android framework to create and maintain images: GLsurfaceView and GLSurfaceView. Renderer. To use OpenGL in an application, understanding how to implement these classes in an Activity should be the first goal.
GLSurfaceView
This class is a View. In this class, you can draw and maintain objects called using OpenGL APIs, and it is similar to the SurfaceView class. Create an instance of the GLSurfaceView class and add a Renderer object to it to use this class. However, if you want to capture touch screen events, you should inherit the GLSurfaceView class and implement its touch screen listener. Sample program TouchRotateActivity (www.2cto.com ).
GLSurfaceView. Renderer
This interface defines the methods required to draw graphics in an OpenGL GLSurfaceView class. You must provide a separate class to implement this interface, and use the GLSurfaceView. setRenderer () method to bind it to the GLSurefaceView class instance.
The following are the required GLSurfaceView. Renderer interface methods:
1. onSurfaceCreated ()
When creating a GLSurfaceView object, the system calls this method once. This method is used to execute actions that only occur once, such as setting OpenGL environment parameters or initializing OpenGL graphics objects.
2. onDrawFrame ()
This method is called every time you repaint a GLSurefaceView object. This method is used as the initial execution point for drawing a graphic (including drawing and redrawing) object.
3. onSurefaceChanged ()
This method is called when the glry of the GLSurfaceView object changes (including the size or the orientation of the device screen. For example, the system calls this method when the device changes from portrait to landscape. Use this method to respond to changes in the GLSurfaceView container.
By FireOfStar