Is it possible to draw from the same application on multiple surfaces, one by one, by using only the handler returned by eglCreateWindowSurface ?
What i want to achieve is to create two or more surfaces and pass them to a client who will draw on them, and then, when done, basically, i will only need to perform swapBuffers. A simple surface handler ( EGLSurface ) will be enough for the client to draw shapes etc ?
I cannot find any examples; each examples just draws in the current context.
I have never tried this, but it should be possible. On the EGL level, the association between context and surface is established when you make a context current with the eglMakeCurrent()
call:
EGLBoolean eglMakeCurrent( EGLDisplay display,
EGLSurface draw,
EGLSurface read,
EGLContext context);
The EGLSurface
you pass to this call (typically the same for read
and draw
) can come from the return value of eglCreateWindowSurface()
.
So if you're currently drawing to surface1
, and you want to start rendering to surface2
, you can use:
eglMakeCurrent(eglGetCurrentDisplay(), surface2, surface2,
eglGetCurrentContext());
Note that each surface can only be current for one context at a time. From the EGL 1.4 spec:
at most one context may be bound to a particular surface at a given time