Hi.
In order to draw two rendering context at same time in one window app.
I declared two EGLDisplay, EGLSurface, EGLContext.
and I did each initialization.
after that,
I call eglMakeCurrent(); before I call each draw() function.
But, it’s don’t work well.
You cannot have more than one OpenGL ES rendering context bound to a single thread simultaneously. It does not matter whether or not the contexts were created on different EGLDisplays or not; this restriction is inherent to the API design choice of using an implicit rendering context.
So if you want to render to two contexts “simultaneously”, you’ll need to be rendering from two threads. I put “simultaneously” in quotes because the GPU is probably not itself multithreaded => you may sustain large performance drops due to GPU context switching (though this is very implementation- and platform-specific).
As Jon said, it’s not possible directly. Going multithreaded is the simplest and the most performance hungry way to do it, if your OpenGL / EGL is capable of supporting multiple contexts at all.
If you prefix your rendering calls with eglMakeCurrent, it should to work without problems. You don’t have to do this for every draw call. It’s sufficient if you do it every time you change the rendering context.
However, I have my doubts (and some bad experience on pocketpc) that multiple context rendering from a single thread is supported and tested in all EGL implementations.
Most EGL implementations I’ve seen so far only do the bare minimum, or even less.