添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

There's a set of these eglCreate*Surface APIs to create surface s in Android, I understand that API like eglCreatePbufferSurface create a backing buffer which can be rendered with GL calls, but I can't wrap my head around this one, eglCreateWindowSurface(EGLDisplay display, EGLConfig cfg, Object window, ...) , if I pass a Surface as the window, how could the system make what I draw using OpenGL on the window surface appear on the screen? I know it couldn't, because it doesn't even have a place in the layout in my Activity.

My confusion is if what I draw to the window surface doesn't appear automatically on the screen, why it ever exists? isn't it the same as the pixel buffer surface created with eglCreatePbufferSurface ?

In the 3rd paragraph of this doc , which states:

From that point onward, rendering to that EGLSurface results in a buffer being dequeued, rendered into, and queued for use by the consumer. (The term "window" is indicative of the expected use, but bear in mind the output might not be destined to appear on the display.)

which confuses me more.

if I pass a Surface as the window, how could the system make what I draw using OpenGL on the window surface appear on the screen?

If you don't pass a valid operating system level native window handle as the native_window parameter of eglCreateWindowSurface it will throw an error. In short, if you pass junk into an API don't expect it to do anything sensible.

I was not saying to pass junk as the window parameter to it. Since eglCreateWindowSurface accepts Surface as its 3rd parameter, and I can create a Surface using new Surface(new SurfaceTexture(textureId)) , then what does it mean when I do that? I didn't associate the Surface with any view, what's the difference between eglCreateWindowSurface and eglCreatePbufferSurface in this case? neevek Jun 20, 2017 at 15:18 Accepting a non-window surface into eglCreateWindowSurface is Android-specific, and definitely not portable. Other operating systems will expect a real native_window type, and throw an error if you don't give one. solidpixel Jun 20, 2017 at 16:30

My confusion is if what I draw to the window surface doesn't appear automatically on the screen, why it ever exists? isn't it the same as the pixel buffer surface created with eglCreatePbufferSurface?

eglCreateWindowSurface and eglCreatePbufferSurface both create rendering surfaces, I think the difference is eglCreateWindowSurface needs an on-screen native platform window as parameter, which is the main purpose of EGL, connect the native platform window system with OpenGL ES.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question . Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers .