使用 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 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間: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/)."]]