I am developing a graphics framework and I would like to have a separate thread for my 3D rendering.
I would like to render my 2D stuff from the application's main thread (or something like UI thread) and all 3D from a separate thread.

I am using opengl es textures for rendering the 2D surface after it is created. So this makes me to use OpenGL ES calls from 2 threads. I am creating separate contexts from both threads and making the context current in their corresponding thread. When eglmakecurrent() is called for the first time from thread 1 it succeeds. When eglmakecurrent() is called again from thread 2 it fails. Any suggestions?

I am using the same surface created from eglCreateWindowSurface() on both the threads.
Is there any other way to mix the 3D and 2D is this environment?

The OS used is Linux.