Android NDK, Opengl es 2, VBO crashes the render

只愿长相守 提交于 2019-12-12 03:09:47

问题


Ok this is the fourth time that I post this issue. It is a complicate problem, I know that.

I'm going to explain all, beacuse I dont know what is important or not, and this problem looks like is something stupid in the code, that I don't realize.

I had been developing a game engine for Android with the render part in c++ NDK, few days ago, I had no problem with this, I could see my game correctly in any android device, then, I wrote more code, updated Android Studio from 1.5.2 to 2.1.3, updated experimental gradle plugin from 0.7.0 to 0.7.3, and all that time I only tested the app on a Nexus 6p with android 6, all was fine, but, oh oh, when I tested it on Android 4, it showed nothing, and when I tested on Android 5, it showed something, but no properly.

Now, I started to debug the app, and I could notice when I draw with VBO the render is broken and nothing is rendered, only the background is showed with the color that I set in glClearColor.

So when I draw a triangle without VBO, it is rendered properly, but if I draw the same triangle or even other one with VBO, the render crashes and only shows the background, when I draw a triangle without VBO, and then I draw other one with VBO, I could notice that not matter if I call glDrawElements, as soon as the code reach glBindBuffer, the renderer crashes.

so thats it, I've already tried:

  • go back to Android Studio 1.5.2
  • downgrade experimental plugin
  • downgrade gradle from 2.14.1 to 2.10
  • I've checked all the GLerrors, every single call to gl, and all return 0.
  • I've even started to write all the code from scratch (just the c++ code), and I got the same result

This is driving me crazy. I wasted 5 days with this, and the more time passes, I feel dumber.

these are my files:

  • InterfaceJNI.h
  • InterfaceJNI.cpp
  • OpenGLMng.h
  • OpenGLMng.cpp
  • File.h
  • File.cpp
  • tmp.h
  • tmp.cpp
  • I hope I can solve this and feel stupid, for so insignificant problem.

    I'll appreciate any idea or help, thanks

    EDIT: maybe the problem is not in the code, maybe is in the gradle settings, or in the manifest, or in the java renderer part, or wherever, but I can not find where


    回答1:


    Well finally I solved it. so I found 2 problems:

    1. I need to put an explicit glBindBuffer(GL_ARRAY_BUFFER, 0); to unbind the buffers, I don't know why I have to do that, at this stage, because, I didn't need it before.
    2. GL_UNSIGNED_INT seems doesn't exist on android 4, and again, I don't know why right now it doesn't exist and few days ago, it did.

    So the main problem is solved, but if someone wanted to explain more why is this, it would be great.

    Now I'm going to modify every class in my proyect,



    来源:https://stackoverflow.com/questions/39313325/android-ndk-opengl-es-2-vbo-crashes-the-render

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