Android는 OpenGL ES(GLES) API를 사용하여 그래픽을 렌더링합니다. Android는 GLES 컨텍스트를 생성하고 GLES 렌더링을 위한 창 지정 시스템을 제공하기 위해 EGL 라이브러리를 사용합니다. GLES 호출은 텍스처 다각형을 렌더링하는 반면 EGL 호출은 렌더링을 화면에 배치합니다.
GLES로 그리려면 먼저 GL 컨텍스트를 생성해야 합니다. 이는 EGL에서 EGLContext 및 EGLSurface를 생성하는 것을 의미합니다. GLES 연산은 인수로 전달되는 대신 스레드 로컬 저장소를 통해 액세스되는 최신 컨텍스트에 적용됩니다. 렌더링 코드는 UI 스레드가 아닌 최신 GLES 스레드에서 실행되어야 합니다.
EGLSurfaces
EGLSurface는 EGL에 의해 할당되는 화면 밖의 버퍼일 수 있으며, 이를 pbuffer 또는 운영체제에 의해 할당되는 창이라고도 부릅니다. eglCreateWindowSurface() 함수를 호출하면 EGL 창 노출 영역이 생성됩니다.
eglCreateWindowSurface()는 Android에서는 노출 영역인 창 객체를 인수로 취합니다. 노출 영역은 BufferQueue의 생산자 측입니다. SurfaceView, SurfaceTexture, TextureView 또는 ImageReader인 소비자는 노출 영역을 생성합니다.
eglCreateWindowSurface()를 호출하면 EGL은 새로 EGLSurface 객체를 생성한 후 이 객체를 창 객체 BufferQueue의 생산자 인터페이스에 연결합니다. 이 시점부터는 해당 EGLSurface에 렌더링할 경우 버퍼가 대기열에서 제외되고 렌더링된 후 소비자가 사용할 수 있도록 대기열에 등록됩니다.
EGL은 잠금/잠금 해제 호출을 제공하지 않습니다. 그리기 명령어를 실행한 다음 eglSwapBuffers()를 호출하여 최신 프레임을 제출하세요. 메서드 이름은 보편적인 전면 및 후면 버퍼의 교환에서 비롯되지만 실제 구현은 다를 수 있습니다.
한 번에 하나의 EGLSurface만 노출 영역에 연결할 수 있지만(1개의 생산자만 BufferQueue에 연결할 수 있음) EGLSurface를 삭제하면 다른 노출 영역이 연결될 수 있도록 EGLSurface가 연결 해제됩니다.
스레드는 최신 요소를 변경하는 방식으로 여러 EGLSurface 간에 전환될 수 있습니다. EGLSurface는 한 번에 하나의 스레드에 대해서만 최신이어야 합니다.
EGL은 SurfaceHolder와 같은 단순한 노출 영역의 한 측면이 아닙니다. EGLSurface는 관련성은 있지만 독립적인 개념입니다. 노출 영역으로 지원되지 않는 EGLSurface에는 그리기를 수행할 수 있으며, ELG 없이도 노출 영역을 사용할 수 있습니다. EGLSurface는 그리기를 위한 장소만 GLES에 제공합니다.
공개 노출 영역 클래스는 자바 프로그래밍 언어로 구현됩니다. C/C++에서는 Android NDK로 반 노출되는 ANativeWindow 클래스에 상응합니다. 노출 영역에서 ANativeWindow를 가져오려면 ANativeWindow_fromSurface() 호출을 실행하세요. 유사한 형식의 자바 언어와 마찬가지로 이 역시 잠그고 소프트웨어에서 렌더링한 다음 잠금 해제하여 게시할 수 있습니다. 기본 네이티브 창 유형은 BufferQueue의 생산자 측입니다.
네이티브 코드에서 EGL 창 노출 영역을 생성하려면 EGLNativeWindowType의 인스턴스를 eglCreateWindowSurface()로 전달하세요. EGLNativeWindowType은 ANativeWindow의 동의어이므로 상호 변환이 가능합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 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,["# EGLSurfaces and OpenGL ES\n\nAndroid uses the [OpenGL ES (GLES)](https://www.khronos.org/opengles/)\nAPI to render graphics. To create GLES contexts\nand provide a windowing system for GLES renderings, Android uses the\n[EGL\nlibrary](https://www.khronos.org/egl). GLES calls render textured polygons, while EGL calls put renderings on\nscreens.\n\nBefore you draw with GLES, you need to create a GL context. In EGL,\nthis means creating an EGLContext and an EGLSurface. GLES operations apply to\nthe current context, which is accessed through thread-local storage rather than\npassed as an argument. Rendering code should execute on a current GLES thread,\nnot the UI thread.\n\nEGLSurfaces\n-----------\n\nThe EGLSurface can be an off-screen buffer allocated by EGL, called a\n*pbuffer* , or a window allocated by the operating system. Calling the\n`eglCreateWindowSurface()` function creates EGL window surfaces.\n`eglCreateWindowSurface()` takes a *window object* as an\nargument, which on Android is a surface. A surface is the *producer*\nside of a BufferQueue. *Consumers* , which are SurfaceView,\nSurfaceTexture, TextureView, or ImageReader, create surfaces.\nWhen you call `eglCreateWindowSurface()`, EGL creates a new\nEGLSurface object and connects it to the producer interface of the window\nobject's BufferQueue. From that point onward, rendering to that EGLSurface\nresults in a buffer being dequeued, rendered into, and queued for use by the\nconsumer.\n\n| Though windows are typically displayed, in this case, the output of an EGLSurface window may not appear on the display.\n\nEGL doesn't provide lock/unlock calls. Issue drawing commands and\nthen call `eglSwapBuffers()` to submit the current frame. The\nmethod name comes from the traditional swap of front and back buffers, but the actual\nimplementation may be different.\n\nOnly one EGLSurface can be associated with a surface at a time (you can have\nonly one producer connected to a BufferQueue), but if you destroy the\nEGLSurface it disconnects from the BufferQueue and lets something else\nconnect.\n\nA given thread can switch between multiple EGLSurfaces by changing what's\n*current*. An EGLSurface must be current on only one thread at a time.\n\nEGL isn't another aspect of a surface (like SurfaceHolder). EGLSurface is a\nrelated but independent concept. You can draw on an EGLSurface that isn't\nbacked by a surface, and you can use a surface without EGL. EGLSurface just\nprovides GLES with a place to draw.\n\nRefer to the Android [Compatibility\nDefinition Document](/docs/compatibility/overview) for OpenGL ES and EGL requirements.\n\nANativeWindow\n-------------\n\nThe public surface class is implemented in the Java programming language. The\nequivalent in C/C++ is the ANativeWindow class, semi-exposed by the [Android NDK](https://developer.android.com/ndk/index.html). You\ncan get the ANativeWindow from a surface with the `ANativeWindow_fromSurface()`\ncall. Just like its Java-language cousin, you can lock it, render in software,\nand unlock-and-post. The basic *native window* type is the producer side of a\nBufferQueue.\n\nTo create an EGL window surface from native code, pass an instance of\nEGLNativeWindowType to `eglCreateWindowSurface()`. EGLNativeWindowType is\na synonym for ANativeWindow, so you can cast one to the other."]]