我的 Android opengl 应用程序在睡眠后崩溃
我知道这是我在从软件绘图切换到 opengl es 1.0 之前应该学习的东西,但我一直无法找到有关该主题的任何信息...
如果一段时间没有接触任何东西,我的 opengl 应用程序在睡觉后崩溃...我想知道是否是因为我在进入睡眠状态之前没有卸载纹理或顶点/颜色/纹理/索引缓冲区...我真的不确定如何做到这一点,或者即使它会有所帮助。 ..有人可以指导我吗或者告诉我一个关于什么必须重新加载、销毁等等的规则的快速指南?我真的对这一切感到困惑......
我不知道它是否有帮助,但我的主类扩展了 GLSurfaceView 并实现了“渲染器”,它加载 onScreenCreated 中的所有纹理和缓冲区对象并修复 onSurfaceChanged 上的屏幕缩放。在主活动(主类链接的位置)中覆盖 onResume 和 onPause 调用 onResume 和 onPause openGL 表面命令...
任何可能出错的线索都会非常有帮助...我的游戏引擎是半编码的但我担心这样的故障只会停止我当前和未来的项目。
我正在使用 Froyo (android 2.2) 和 openGL ES 1.0。
从 logcat 打印出错误:
10-24 03:13:41.988:错误/AndroidRuntime(9888):致命异常:GLThread 26
10-24 03:13:41.988: 错误/AndroidRuntime(9888): java.lang.IllegalThreadStateException: 线程已启动。
10-24 03:13:41.988: 错误/AndroidRuntime(9888): 在 java.lang.Thread.start(Thread.java:1322)
10-24 03:13:41.988: 错误/AndroidRuntime(9888): 在 or.gl.m5.Screen.onSurfaceCreated(Screen.java:161)
10-24 03:13:41.988: 错误/AndroidRuntime(9888): 在 android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1317)
10-24 03:13:41.988: 错误/AndroidRuntime(9888): 在 android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
I know this is something i should have learned before switching to opengl es 1.0 from software drawing, but I've been unable to find any information on the subject...
My opengl app crashes after going to sleep if nothing is touched for a while... I'm wondering if it's because i'm not unloading textures or vertex/colour/texture/index buffers before it goes to sleep... I'm really unsure on how to do this or even if it would help... could someone direct me to or tell me a quick guide to the rules of what has to be reloaded, destroyed and so on? I'm really confused by all this...
I dunno if it's helpful, but my main class extends GLSurfaceView and implements "Renderer", which loads all the textures and buffer objects in onScreenCreated and fixes the screen scaling on onSurfaceChanged. In the main activity (which is where the main class is linked in) overides onResume and onPause calling the onResume and onPause openGL surface commands...
Any clue to what might be wrong would be very helpful... My game engine is halfway coded but I'm worried that a glitch like this will just halt my current and future projects.
I'm using Froyo (android 2.2) and openGL ES 1.0.
error print out from logcat:
10-24 03:13:41.988: ERROR/AndroidRuntime(9888): FATAL EXCEPTION: GLThread 26
10-24 03:13:41.988: ERROR/AndroidRuntime(9888): java.lang.IllegalThreadStateException: Thread already started.
10-24 03:13:41.988: ERROR/AndroidRuntime(9888): at java.lang.Thread.start(Thread.java:1322)
10-24 03:13:41.988: ERROR/AndroidRuntime(9888): at or.gl.m5.Screen.onSurfaceCreated(Screen.java:161)
10-24 03:13:41.988: ERROR/AndroidRuntime(9888): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1317)
10-24 03:13:41.988: ERROR/AndroidRuntime(9888): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有看到堆栈跟踪或它抛出什么样的异常,就很难说些什么。但无论如何,我大胆猜测它会崩溃,因为您必须在恢复活动后重新加载纹理。一旦您的视图转到背景,您之前创建的纹理就会变得无效。
Without seeing a stack trace or what kind of exception it throws out it is kind of hard to say something. But anyway I'm throwing a wild guess that it crashes because you have to reload textures after your activity is resumed. The textures you have previously created become invalid once your view goes to background.