Android graphics-OpenGL (1)

Source: Internet
Author: User

This article translated from: http://developer.android.com/guide/topics/graphics/opengl.html

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. From android2.2 (API
Level 8). The framework starts to support the OpenGL es2.0 API specification.

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 Android framework interface, about ndk more information, please see Android ndk (http://developer.android.com/sdk/ndk/index.html)

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. Touchrotateactivity (http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/TouchRotateActivity.html ).

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.