Drawing two Rendering Context in same time

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.

how can i do that?

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).

Thanks, oddhack.

I already render two thread.
In my application, First Context is MFC Main Window View and Second Context is created by modeless dialog box.

my code flow like that…

Modeless Dialog Box create()
{
Second Context created…
}

Main window Initialize()
{
First Context created…
}

Main window Draw()
{
eglMakeCurrent(First Context, Fist Display, Fisrt Surface)
draw…

}

Modeless Dialog Box Draw()
{
eglmakeCurrent(Second Context, Second Display, Second Surface)
draw…(in picture box control(MFC))…

}

the result is two context is added and displayed only modeless dialog RECT area.

I have problem??

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.

What EGL / OpenGL implementation are you using?

Regards,
Nils Pipenbrinck

My application is developed on desktop.
So I use the PowerVR OpenGL ES libraries(PC Version)

That is support??

If it’s possible…
I guess the bad result is my mistake…

Can I get some example code?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.