简体   繁体   English

Android NDK,Opengl ES 2,VBO使渲染崩溃

[英]Android NDK, Opengl es 2, VBO crashes the render

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. 几天前,我一直在使用c ++ NDK中的渲染部分开发适用于Android的游戏引擎,对此我没有任何问题,我可以在任何android设备上正确看到我的游戏,然后,我编写了更多代码,并从1.5.2到2.1.3,将实验性gradle插件从0.7.0更新到了0.7.3,并且一直以来我只在android 6的Nexus 6p上测试了该应用,一切正常,但是,哦,当我测试在Android 4上它什么也没显示,而当我在Android 5上进行测试时,它却显示了一些东西,但是没有正常显示。

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 . 现在,我开始调试该应用程序,当使用VBO进行绘制时,我会注意到渲染已损坏,并且没有渲染任何内容,仅显示了背景色和glClearColor设置的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. 因此,当我绘制不带VBO的三角形时,它会正确渲染,但是如果我绘制相同的三角形或什至使用VBO绘制另一个三角形,则当我绘制不带VBO的三角形并随后绘制其他三角形时,渲染会崩溃并仅显示背景一个使用VBO的程序,我注意到如果我调用glDrawElementsglDrawElements ,只要代码到达glBindBuffer ,渲染器就会崩溃。

so thats it, I've already tried: 就是这样,我已经尝试过:

  • go back to Android Studio 1.5.2 回到Android Studio 1.5.2
  • downgrade experimental plugin 降级实验插件
  • downgrade gradle from 2.14.1 to 2.10 将gradle从2.14.1降级到2.10
  • I've checked all the GLerrors, every single call to gl, and all return 0. 我检查了所有GLerrors,对gl的每个调用都返回0。
  • I've even started to write all the code from scratch (just the c++ code), and I got the same result 我什至开始从头开始编写所有代码(只是C ++代码),我得到了相同的结果

This is driving me crazy. 这真让我抓狂。 I wasted 5 days with this, and the more time passes, I feel dumber. 我为此浪费了5天,随着时间的流逝,我感到无聊。

these are my files: 这些是我的文件:

  • InterfaceJNI.h 接口JNI.h
  • InterfaceJNI.cpp 接口JNI.cpp
  • OpenGLMng.h OpenGLMng.h
  • OpenGLMng.cpp OpenGLMng.cpp
  • File.h 文件.h
  • File.cpp File.cpp
  • tmp.h tmp.h
  • tmp.cpp 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 编辑:也许问题不在代码中,也许在gradle设置中,或在清单中,或在Java渲染器部分中,或在任何地方,但是我找不到在哪里

    Well finally I solved it. 好吧,终于我解决了。 so I found 2 problems: 所以我发现了2个问题:

    1. I need to put an explicit glBindBuffer(GL_ARRAY_BUFFER, 0); 我需要放置一个明确的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. GL_UNSIGNED_INT似乎在android 4上不存在,再次,我不知道为什么现在不存在,而几天前,它确实存在。

    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, 现在,我将修改proyect中的每个类,

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM