[Solved] Get Handle to OpenGL Unity Render Context

I was wondering if anyone knows how to get a handle to the opengl unity render context. I need to create a texture in a external application and render it in Unity using Texture2D.CreateExternalTexture(). When I create the texture in my external application I get a texture id of 1, which seems wrong. I’m guessing its because it has its own render context and does not share a texture pool with Unity. I could be totally wrong about this because I’m a bit of a OpenGL noob. If anyone could point me in the right direction it would be greatly appreciated.

I was able to grab the handle to the opengl unity render context by using a low-level native plugin and fetching the handle with wglGetCurrentContext(). Unity - Manual: Low-level native plug-in interface

Using GetRenderEventFunc() allowed me to call GL.IssuePluginEvent() directly from the render thread, which in turn allowed me to grab the context handle. I am now able to render my textures externally and then display them in Unity using Texture2D.CreateExternalTexture().

Thanks for posting your solution. Have you find anyway to get context directly from android java?