Android手机转动时的OpenGL
翻转/倾斜手机时它叫什么(我应该谷歌什么术语),以便在运行 Android 时旋转视图?
当我执行此操作时,我的 (OpenGL) 应用程序崩溃了,当发生这种情况时,在处理 OpenGL 时是否应该执行一些特定步骤?
还有什么我可能想考虑的吗?
What is it called ( what term should i google) when flipping/tilting the phone, so that the view rotates when running android?
My (OpenGL) application crashes when I do this, are there some certain steps you should do when handling OpenGL when this occures?
Is there something else I might want to think about?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您没有为处理自己的旋转的活动设置 AndroidManifest.xml 的属性,您的活动将重新启动,GL 上下文将被重新创建,并且至少,您使用的任何表面和缓冲区都将无效。
在我的gles 1.1应用程序中,我的AndroidManifest.xml中有以下内容,它指定我的应用程序活动希望通过键盘和方向配置更改继续存在,并且应用程序支持任何方向,但不希望它改变 -因为我不想处理重新加载纹理或重做游戏布局(还)
if you don't set the AndroidManifest.xml 's attributes for activities that handle their own rotations, your activity will be restarted, the GL context will be recreated, and at least, any surfaces and buffers that you were using will be invalid.
in my gles 1.1 application, I have the following in my AndroidManifest.xml, which specifies that my application activity wants to live on through keyboard and orientation configuration changes, and that the application supports any orientation, but doesn't want it to change -because I don't want to deal with reloading textures or redoing the game layout (yet)
该问题就像屏幕方向发生变化时发生的配置更改一样。请参阅配置更改。您可能想告诉 Android 您将自己处理方向更改,通过 configChanges 属性。
The problem is like the configuration change that occurs when the screen orientation change occurs. See Configuration Changes. You might want to tell Android that you will handle the orientation change yourself, via the configChanges attribute.
一些不错的阅读: http://android- Developers.blogspot.com/2010/09/one-screen-turn-deserves-another.html
Some good reading: http://android-developers.blogspot.com/2010/09/one-screen-turn-deserves-another.html
您可以尝试搜索“屏幕旋转 android”或“屏幕旋转 android OpenGL”,因为您正在尝试执行 3D。当屏幕旋转时,当前表面将被破坏,并根据新的屏幕尺寸创建一个新表面。
我建议查看一些示例代码,只是为了了解处理屏幕旋转的正确方法,在 Android 中查找“ApiDemos.apk”(顺便说一下,它是开源的),特别是那些使用 GL 的人,它们都处理屏幕旋转。
You could try searching for "Screen rotation android" or "Screen rotation android OpenGL" since you're trying to do 3D. When the screen rotates the current surface gets destroyed and a new one gets created already accounting for the new screen dimensions.
I'd recommend looking into some sample code just to see the correct way to handle screen rotation, look for "ApiDemos.apk" in Android (it's open sourced by the way), specifically the ones who use GL", all of them handle screen rotation.