Android opengl issue (weird)

半腔热情 提交于 2019-12-09 17:48:25

问题


this is a weird one. I have a basic application (dashboard, ...) and a GLSurfaceview in which I draw 3D objects and textures. All runs pretty but when I go back in other activities, hmm well a screenshot is better than words:

This is the dashboard before

this is the opengl:

And this is my dashboard when I press back:

As you can see, the images are gone and text too. I run on 4.0+ so I suppose this is because android draws elements with opengl, as it doesn't do that on my 2.2 device.

Do you have an idea of what is causing this? It does not happen when I don't use texture btw.


回答1:


Ok I found what was wrong to me. I was deleting textures on the UI Thread, by calling mTextureManager.deleteAllTextures() on my fragment's onPause();

I solved it by deleting my textures with a

mSurfaceView.queueEvent(new Runnable(){
    //delete all textures here
}

Hope this will help other guys...




回答2:


If you are using textures and vertex buffers I believe those get cleared when you navigate away from a view. If you are getting a SurfaceDestoyed or SurfaceCreated call then I believe you have to recreate the textures and vbos and reload them to the graphics card.

I had a similar problem once where I introduced a bug that messed up the open gl state. Then when I went to another activity (that was hardware accelerated) that activity was all messed up as well. In my case I had to locate the open gl bug I made and fix it.




回答3:


Could your issue be related to mine? Have a read to make sure it's not: Text only thing visible after pausing GLSurfaceView on Galaxy S3 - Text blur when moved. No button backgrounds

My issue was executing openGL functionality on the UI thread, which corrupted the openGL context used for hardware acceleration.

If you want to test: disable hardware acceleration app wide in the android manifest. If your issue disappears, it's likely the same issue I had. Read my answer to my own question to learn how to fix this issue while leaving hardware acceleration on.

<application android:hardwareAccelerated="false" ...>


来源:https://stackoverflow.com/questions/14531868/android-opengl-issue-weird

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!