הצגת גרפיקה באמצעות OpenGL ES
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מסגרת Android מספקת שפע של כלים סטנדרטיים ליצירת ממשקי משתמש גרפיים אטרקטיביים ופונקציונליים. עם זאת, אם אתם רוצים לשלוט יותר במה שהאפליקציה מציירת על המסך, או אם אתם מתנסים בגרפיקה תלת-ממדית, אתם צריכים להשתמש בכלי אחר. ממשקי ה-API של OpenGL ES שמסופקים על ידי מסגרת Android מציעים ערכת כלים להצגת גרפיקה מתקדמת ומונפשת, שהמגבלה היחידה שלה היא הדמיון שלכם. בנוסף, אפשר ליהנות מההאצה של מעבדים גרפיים (GPU) שקיימים במכשירי Android רבים.
בשיעור הזה נלמד את היסודות של פיתוח אפליקציות שמשתמשות ב-OpenGL, כולל הגדרה, ציור אובייקטים, הזזת רכיבים מצוירים ותגובה לקלט מגע.
קוד הדוגמה במחלקה הזו משתמש ב-APIs של OpenGL ES 2.0, שהיא גרסת ה-API המומלצת לשימוש במכשירי Android הנוכחיים. מידע נוסף על גרסאות של OpenGL ES זמין במדריך למפתחים של OpenGL.
הערה: חשוב לא לערבב קריאות ל-API של OpenGL ES 1.x עם שיטות של OpenGL ES 2.0. אי אפשר להשתמש בשני ממשקי ה-API לסירוגין, וניסיון להשתמש בהם ביחד רק יגרום לתסכול ולעצב.
שיעורי מוזיקה
- איך יוצרים סביבת 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/)."]]