การแสดงกราฟิกด้วย OpenGL ES
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เฟรมเวิร์ก Android มีเครื่องมือมาตรฐานมากมายสำหรับการสร้างอินเทอร์เฟซผู้ใช้แบบกราฟิกที่น่าสนใจและใช้งานได้
อย่างไรก็ตาม หากต้องการควบคุมสิ่งที่แอปพลิเคชันวาดบนหน้าจอมากขึ้น หรือกำลังจะเข้าสู่กราฟิกสามมิติ คุณจะต้องใช้เครื่องมืออื่น
OpenGL ES API ที่เฟรมเวิร์ก Android มีให้เป็นชุดเครื่องมือสำหรับแสดงกราฟิกเคลื่อนไหวคุณภาพสูง
ซึ่งจำกัดอยู่เพียงจินตนาการของคุณ และยังใช้ประโยชน์จากการ
เร่งความเร็วของหน่วยประมวลผลกราฟิก (GPU) ที่มีให้ในอุปกรณ์ Android หลายรุ่นได้อีกด้วย
คลาสนี้จะอธิบายพื้นฐานของการพัฒนาแอปพลิเคชันที่ใช้ OpenGL รวมถึง
การตั้งค่า การวาดออบเจ็กต์ การย้ายองค์ประกอบที่วาด และการตอบสนองต่ออินพุตแบบสัมผัส
โค้ดตัวอย่างในคลาสนี้ใช้ OpenGL ES 2.0 API ซึ่งเป็น API เวอร์ชันที่แนะนำ
ให้ใช้กับอุปกรณ์ Android ปัจจุบัน ดูข้อมูลเพิ่มเติมเกี่ยวกับเวอร์ชันของ OpenGL ES ได้ที่คู่มือสำหรับนักพัฒนาซอฟต์แวร์ OpenGL
หมายเหตุ: โปรดระมัดระวังอย่าเรียกใช้ OpenGL ES 1.x API ร่วมกับเมธอด OpenGL ES 2.0 API ทั้ง 2 รายการนี้ใช้แทนกันไม่ได้ และการพยายามใช้ API ทั้ง 2 รายการร่วมกันจะทำให้เกิดความหงุดหงิดและเศร้าใจเท่านั้น
บทเรียน
- สร้างสภาพแวดล้อม OpenGL ES
- ดูวิธีตั้งค่าแอปพลิเคชัน Android เพื่อให้วาดกราฟิก OpenGL ได้
- กำหนดรูปร่าง
- ดูวิธีกำหนดรูปร่างและเหตุผลที่คุณต้องทราบเกี่ยวกับใบหน้าและการพัน
- วาดรูปร่าง
- ดูวิธีวาดรูปร่าง OpenGL ในแอปพลิเคชัน
- ใช้มุมมองการฉายภาพและกล้อง
- ดูวิธีใช้มุมมองการฉายภาพและกล้องเพื่อดูมุมมองใหม่ของออบเจ็กต์ที่วาด
- เพิ่มการเคลื่อนไหว
- ดูวิธีเคลื่อนไหวและสร้างภาพเคลื่อนไหวพื้นฐานของออบเจ็กต์ที่วาดด้วย OpenGL
- ตอบสนองต่อเหตุการณ์การแตะ
- ดูวิธีโต้ตอบขั้นพื้นฐานกับกราฟิก OpenGL
โค้ดตัวอย่างเพิ่มเติม
หากต้องการดาวน์โหลดตัวอย่าง NDK โปรดดู
ตัวอย่าง NDK
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","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-27 UTC"],[],[],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/)."]]