gpt4 book ai didi

java - 不需要在 android 中执行 opengl 删除功能?

转载 作者:行者123 更新时间:2023-11-29 03:06:18 35 4
gpt4 key购买 nike

我看到了这个:Android SurfaceView doc .在上下文丢失的情况下,它说:

There are situations where the EGL rendering context will be lost. This typically happens when device wakes up after going to sleep. When the EGL context is lost, all OpenGL resources (such as textures) that are associated with that context will be automatically deleted.

这是否意味着我不必调用例如 GLES20.GLES20.glDeleteTextures( ... ); 并且 android 会为我清理它?我还看到没有关于 android opengl es 的教程提到删除功能,甚至没有 Developer.android 上的“官方”功能。 .

(当然,我认为这仅适用于我的对象不需要更多内存的情况)

你们知道吗?我必须手动删除 opengl 内容吗?

最佳答案

当上下文被销毁时,在上下文中创建的所有对象都会自动删除。此行为在“对象删除行为”下附录 C 的 ES 2.0 规范中定义:

Once the last context on the share list is destroyed, all shared objects, and all other resources allocated for that context or share list, will be deleted and reclaimed by the implementation as soon as possible.

如果您有多个上下文,事情就会变得有点复杂。但在单一上下文的情况下,所有对象都随上下文一起消失。

当然,如果在执行过程中有您不再需要的对象,您仍然应该使用相应的 glDelete*() 调用删除它们。否则你会堆积越来越多的对象。但是在清理过程中不需要删除对象。

关于java - 不需要在 android 中执行 opengl 删除功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32030252/

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