eglBindApi scope.

Just a minor question:

I assume that eglBindApi sets the API for the current context, is that right? So a eglBindApi before a valid eglMakeCurrent will always return an error.

I’m a bit worried because the only source that calls eglBindApi is from the OpenVG reference code, and it calls eglBindApi right after eglInitialize (which does not make much sense unless the current API is per thread, not per context).

Could someone please shed some light on this?


btw - I just read this powerpoint from the 2006 siggraph and they call eglBindApi right after eglInitialize as well.

Siggraph talk

Does this make sense?

eglBindAPI just sets some global state, the “current rendering API”. It has nothing to do with the current context(s), and you can call it at any time. The current rendering API is used by other calls that need to know which client API is being operated on. This is admittedly, ugly. EGL was originally specified with only one client API in mind, and supporting more than one required either a new set of calls with an additional parameter, or a global value like this. As the spec says:

Applications using multiple client APIs are responsible for ensuring the current rendering API is correct before calling the functions eglCreateContext, eglGetCurrentContext, eglGetCurrentDisplay, eglGetCurrentSurface, eglMakeCurrent (when its ctx parameter is EGL_NO_CONTEXT), eglWaitClient, or eglWaitNative.

I think its very old thread…but anyone can suggest me the right way to do a switch between OPENVG and OPENGLES rendering using the same EGL surface, that will be helpful for my prgrm…
i tried to do like this
1 Create EGL surface
2 Create OpenVG context
3 Create OpenGL ES context
4 Make OpenVG context current
5 Render OpenVG drawings
6 call VGFinish
7 Make OpenGL ES context current to the same surface
8 Render OpenGL ES drawings
9 Call EGLSwapBuffer
but it doesn’t give any result and application crashes…can any one suggest the right method…? thanks n advance…

DO I need to add a EGLBindApi function before rendering…? if yes where is the right place to add it…

Before creating an EGL context is probably a good spot.