问题描述
我有一个android全屏opengl es应用程序.
i have an android fullscreen opengl es app.
当设备从纵向旋转到横向并向后旋转时,gl上下文会被破坏并重新创建.
when the device is rotate from portrait to landscape and back the gl context is destroyed and recreated.
有办法避免这种情况吗?即总是保持肖像或风景?
is there a way to avoid this? i.e. always stay in portrait or landscape?
我已经在活动中包含以下代码:
edit: i already have this code in my activity:
@Override
protected void onResume()
{
super.onResume();
mGLSurfaceView.onResume();
}
@Override
protected void onPause()
{
super.onPause();
mGLSurfaceView.onPause();
}
推荐答案
不幸的是,直到API级别11 (3.0) GLSurfaceView 始终会破坏GL上下文.对于11岁或以上的人,您可以 setPreserveEGLContextOnPause (boolean preserveOnPause)
.
Unfortunately until API Level 11 (3.0) GLSurfaceView will always destroy the GL context. For 11 and higher you have the ability to setPreserveEGLContextOnPause (boolean preserveOnPause)
.
可以通过更改GLSurfaceView的来源来解决此问题,但是遇到任何问题将很难获得其他人的帮助.
There are ways around this by changing the source of GLSurfaceView but any problems you encounter it will be a lot harder to get help from others.
这篇关于android:设备旋转时禁用opengl ES上下文切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!