-
-
Notifications
You must be signed in to change notification settings - Fork 485
Description
I want to render OpenGL inside Flutter. I've already made it work in Java and I know it's possible in C++.
Flutter has this external texture concept where it creates a SurfaceTexture surfaceTexture that I can render into. Given the surfaceTexture, this is how I render things in Java:
eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfig, surfaceTexture, null);
egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)
after that, it's all a matter of calling opengl functions like glTexImage to send textures, glDraw to draw, etc.
Can I use this lib or even glium to simply create an eglSurface from a surfaceTexture and then draw things on it?
I don't think glium or glutin have the power to do anything with a surfaceTexture. But maybe I can create the eglSurface (from a surfaceTexture) in java calling from Rust, then it returns and then I can issue opengl calls using glutin? Something like this:
flutter engine calls java code
java code creates the surfaceTexture from flutter call and gives it an id
java starts rust code
rust code starts glutin or glium and fills vertex buffers, etc
rust code calls java with the id and thus java code can create the egl surface and make it current
java code call returns, now glium can issue opengl calls like glTexImage and glDraw, since the eglSurface is current, things will be drawn to it