My Flutter app needs to display 3d model and allow user to rotate it. I implemented this via native views (ViewController & Activity) and C++ code for rendering, as next step I tried Texture widget to remove native views and use only Flutter. I managed to display OpenGL rendering on iOS via FlutterTexture, but don't understand how to implement on Android. Could you show any examples how to use OpenGL with SurfaceTexture and connect it to Texture widget?
SurfaceTexture should be passed to eglCreateWindowSurface
, while OpenGL stack is being configured.
I spent a while and built example project and article: https://github.com/mogol/opengl_texture_widget_example https://medium.com/@germansaprykin/opengl-with-texture-widget-f919743d25d9
private void initGL() {
egl = (EGL10) EGLContext.getEGL();
eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
int[] version = new int[2];
egl.eglInitialize(eglDisplay, version);
EGLConfig eglConfig = chooseEglConfig();
eglContext = createContext(egl, eglDisplay, eglConfig);
eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfig, texture, null);
egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With