gpt4 book ai didi

android - 纹理小部件渲染 OpenGL 示例

转载 作者:IT老高 更新时间:2023-10-28 12:37:49 24 4
gpt4 key购买 nike

我的 Flutter 应用需要显示 3d 模型并允许用户旋转它。我通过 native View (ViewController 和 Activity)和用于渲染的 C++ 代码实现了这一点,下一步我尝试了 Texture小部件以删除 native View 并仅使用 Flutter。我设法通过 FlutterTexture 在 iOS 上显示 OpenGL 渲染,但不明白如何在Android上实现。您能否展示一些如何将 OpenGL 与 SurfaceTexture 一起使用的示例?并将其连接到 Texture 小部件?

最佳答案

SurfaceTexture 应该被传递给 eglCreateWindowSurface,同时正在配置 OpenGL 堆栈。

我花了一段时间构建了示例项目和文章: 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);
}

关于android - 纹理小部件渲染 OpenGL 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49576011/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com