我的颤振应用程序需要显示三维模型,并允许用户旋转它。我通过原生视图(VIEW Controller和Activity)和C++代码实现了这一点,因为下一步我尝试了“AA>小部件”来删除本机视图,只使用颤动。我设法通过Texture在iOS上显示OpenGL渲染,但不知道如何在Android上实现。你能举例说明如何使用OpenGL和FlutterTexture并将其连接到纹理小部件吗?
最佳答案
在配置OpenGL堆栈时,应将surfacetexture传递给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);
}