Can eglCreateWindowSurface be used for off-screen rendering?
we're are wondering if eglCreateWindowSurface can be used for off-screen rendering and benefit from the eglSwapBuffers function instead of using the time consuming function glReadPixels.
Or should we only use eglCreatePbufferSurface which we know is made for off-screen rendering?
Last edited by Wonderketchup; 11-21-2016 at 02:36 AM.
When you use eglCreateWindowSurface, the buffers are generally ownership of the window system and part of the "window". The only way to get to the pixels is to use glReadPixels or use eglLockSurface and query for the buffer and all the attributes that describe its memory layout. But that is not always supported.
eglCreatePbufferSurface was intended for use of offscreen rendering - specifically EGL owns the buffer. However, since the addition of GL/GLES Renderbuffers objects these can be more efficient and have all the same features.
If access to the pixels is paramount, and your driver supports it, creating an EGLImage using eglCreateImage you either provide or have access to a texture, made from the image, or image made from texture, that can be used with a Framebufferobject. Then you can access the pixels of the image - provided you understand the memory layout of the pixels/buffer.
Hope that covers your use case.
To create a window surface, you call the eglCreateWindowSurface() function. Before you call this function, you should initialize your EGLDisplay, EGLConfig, and native window ( screen_window_t). You also need to ensure that EGL_SURFACE_TYPE in your EGL configuration is set to EGL_WINDOW_BIT. The last parameter is reserved for surface attributes using attribute-value pairs, but you can set this parameter to NULL. For more information on valid attribute-value pairs, see the eglCreateWindowSurface() API reference.
Tags for this Thread