在不同的 GLSurfaceView 之间共享 GLES20 上下文和纹理?
是否可以在不同的 GLSurfaceView 之间(在一个 Activity 内)共享 GLES20 上下文?或者,如何在不同的 GLSurfaceView 之间共享一组纹理?
在 iOS 上,如果您想节省内存并在不同的 CAEAGLLayer 支持的 UIView 中重用(大)纹理,您可以在它们之间传递 EAGLContext 对象,或者使用共享公共 EAGLSharegroup 对象的不同 EAGLContext。
我想知道如何在 Android 上实现这一点。有没有等效的技术?
Edit1
最初的建议是实现您自己的 EGLContextFactory(它将返回相同的 EGLContext),但它不起作用,因为每个 GLSurfaceViews 将渲染分派到它自己的私有 gl 渲染线程并在不同线程之间共享相同的 EGLContext是不可能的。
重新表述我最初的问题: 您在一个屏幕(一个 Activity)中有多个 GLSurfaceView,并且需要在每个表面的单独 EGLContext 中访问一组常见但较大的纹理,但多次加载纹理会超出设备的内存。那么你将如何在 GLSurfaceView 之间共享纹理呢?
Is it possible to share the GLES20 context between different GLSurfaceViews (within one Activity)? Alternatively, how would one share a set of texture between different GLSurfaceViews?
On iOS, if you want to conserve memory and reuse (large) textures in different CAEAGLLayer-backed UIViews, you can pass around a EAGLContext object between them or use different EAGLContexts which share a common EAGLSharegroup object.
I wonder how to accomplish this on Android. Is there any equivalent technique?
Edit1
The initial suggestion, to implement your own EGLContextFactory, which will return the same EGLContext, doesn't work since every GLSurfaceViews dispatches the rendering to it's own private gl render thread and sharing the same EGLContext between different threads is not possible.
To rephrase my initial question:
You have several GLSurfaceViews in one screen (one Activity) and you need to access a set of common but large texture in the individual EGLContext of every surfaces, but loading your textures multiple times exceeds the memory of your device. How would you share your textures between GLSurfaceViews then?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下代码适用于某些设备,但不适用于所有设备:
The following code works on some of the devices, but not all of them:
看来 setEGLContextFactory 可以在不同的 GLSurfaceView 之间使用相同的 GLES20 上下文。
伪代码:
It seems that setEGLContextFactory enables to use the same GLES20 context between different GLSurfaceViews.
pseudo code: