使用 OpenGL ES 显示图形
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android 框架提供了许多标准工具,可用于创建具有吸引力且功能强大的图形界面。但是,如果您希望更好地控制应用在屏幕上绘制的内容,或者想要尝试一下三维图形,则需要使用其他工具。Android 框架提供的 OpenGL ES API 提供了一组工具,用于显示只限于您的想象的高端动画图形,也可以受益于许多 Android 设备上提供的图形处理单元 (GPU) 加速。
本课程将介绍开发使用 OpenGL 的应用的基础知识,包括设置、绘制对象、移动绘制的元素以及响应触控输入。
此类中的示例代码使用 OpenGL ES 2.0 API,这是推荐用于当前 Android 设备的 API 版本。如需详细了解 OpenGL ES 的版本,请参阅 OpenGL 开发者指南。
注意:请勿将 OpenGL ES 1.x API 调用与 OpenGL ES 2.0 方法混用!这两个 API 不可互换,尝试将它们结合使用只会导致失望和悲伤。
课程
- 构建 OpenGL ES 环境
- 了解如何设置 Android 应用,以便能够绘制 OpenGL 图形。
- 定义形状
- 了解如何定义形状,以及为何需要了解面和环绕。
- 绘制形状
- 了解如何在应用中绘制 OpenGL 形状。
- 应用投影和相机视图
- 了解如何使用投影视图和相机视图从新的视角来审视所绘制的对象。
- 添加动画
- 了解如何使用 OpenGL 对绘制的对象进行基本移动及添加动画效果。
- 响应轻触事件
- 了解如何与 OpenGL 图形进行基本交互。
更多示例代码
如需下载 NDK 示例,请参阅 NDK 示例。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[],[],null,["# Displaying graphics with OpenGL ES\n\nThe Android framework provides plenty of standard tools for creating attractive, functional\ngraphical user interfaces. However, if you want more control of what your application draws on\nscreen, or are venturing into three dimensional graphics, you need to use a different tool. The\nOpenGL ES APIs provided by the Android framework offers a set of tools for displaying high-end,\nanimated graphics that are limited only by your imagination and can also benefit from the\nacceleration of graphics processing units (GPUs) provided on many Android devices.\n\nThis class walks you through the basics of developing applications that use OpenGL, including\nsetup, drawing objects, moving drawn elements and responding to touch input.\n\nThe example code in this class uses the OpenGL ES 2.0 APIs, which is the recommended API version\nto use with current Android devices. For more information about versions of OpenGL ES, see the\n[OpenGL developer\nguide](/develop/ui/views/graphics/opengl/about-opengl#choosing-version).\n\n**Note:** Be careful not to mix OpenGL ES 1.x API calls with OpenGL\nES 2.0 methods! The two APIs are not interchangeable and trying to use them together only results in\nfrustration and sadness.\n\nLessons\n-------\n\n**[Build an OpenGL ES environment](/develop/ui/views/graphics/opengl/environment)**\n: Learn how to set up an Android application to be able to draw OpenGL graphics.\n\n**[Define shapes](/develop/ui/views/graphics/opengl/shapes)**\n: Learn how to define shapes and why you need to know about faces and winding.\n\n**[Draw shapes](/develop/ui/views/graphics/opengl/draw)**\n: Learn how to draw OpenGL shapes in your application.\n\n**[Apply projection and camera views](/develop/ui/views/graphics/opengl/projection)**\n: Learn how to use projection and camera views to get a new perspective on your drawn\n objects.\n\n**[Add motion](/develop/ui/views/graphics/opengl/motion)**\n: Learn how to do basic movement and animation of drawn objects with OpenGL.\n\n**[Respond to touch events](/develop/ui/views/graphics/opengl/touch)**\n: Learn how to do basic interaction with OpenGL graphics.\n\nAdditional sample code\n----------------------\n\nTo download NDK samples, see\n[NDK Samples](https://github.com/googlesamples/android-ndk/)."]]