纹理小部件呈现 OpenGL 示例
Texture widgets render OpenGL example
我的 Flutter 应用需要显示 3d 模型并允许用户旋转它。我通过本机视图 (ViewController & Activity) 和用于渲染的 C++ 代码实现了这一点,下一步我尝试 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 并将其连接到纹理小部件?
SurfaceTexture 应在配置 OpenGL 堆栈时传递给 eglCreateWindowSurface
。
我花了一段时间构建了示例项目和文章:
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);
}
我的 Flutter 应用需要显示 3d 模型并允许用户旋转它。我通过本机视图 (ViewController & Activity) 和用于渲染的 C++ 代码实现了这一点,下一步我尝试 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 并将其连接到纹理小部件?
SurfaceTexture 应在配置 OpenGL 堆栈时传递给 eglCreateWindowSurface
。
我花了一段时间构建了示例项目和文章: 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);
}