Android NDK,Opengl es 2,VBO导致渲染崩溃 [英] Android NDK, Opengl es 2, VBO crashes the render

查看:166
本文介绍了Android NDK,Opengl es 2,VBO导致渲染崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这是我第四次发布此问题.我知道这是一个复杂的问题.

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.

几天前,我一直在使用c ++ NDK中的render部分开发适用于Android的游戏引擎,对此我没有任何问题,我可以在任何android设备上正确看到我的游戏,然后,我编写了更多代码,并进行了更新从1.5.2到2.1.3的Android Studio,将实验性gradle插件从0.7.0更新到0.7.3,并且在所有时间里,我仅在装有android 6的Nexus 6p上测试了该应用,一切都很好,但是,哦,哦,当我在Android 4上进行测试时,它什么也没显示;而当我在Android 5上进行测试时,它却显示了什么,但没有正确显示.

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.

现在,我开始调试该应用程序,当使用VBO进行绘制时,我会注意到渲染已损坏,并且没有渲染任何内容,仅显示了背景颜色,该颜色与我在glClearColor中设置的颜色相同.

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的三角形时,它会正确渲染,但是如果我绘制相同的三角形或什至使用VBO绘制另一个三角形,则当我绘制不带VBO的三角形时,渲染会崩溃并仅显示背景,然后我用VBO绘制了另一个,我注意到如果我调用glDrawElements没关系,只要代码到达glBindBuffer,渲染器就会崩溃.

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:

  • 回到Android Studio 1.5.2
  • 降级实验性插件
  • 将gradle的等级从2.14.1降低到2.10
  • 我已经检查了所有GLerror,对gl的每个调用都返回0.
  • 我什至开始从头开始编写所有代码(只是c ++代码),我得到了 相同的结果
  • 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

这让我发疯.我为此浪费了5天,时间越流逝,我感到无聊.

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

这些是我的文件:

  • InterfaceJNI.h
  • InterfaceJNI.cpp
  • OpenGLMng.h
  • OpenGLMng.cpp
  • File.h
  • File.cpp
  • tmp.h
  • tmp.cpp
  • 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

    也许问题不在代码中,可能不是在gradle设置中,在清单中,在Java渲染器部分中或在任何地方,但我找不到哪里

    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

    推荐答案

    好吧,我终于解决了.所以我发现了2个问题:

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

    1. 我需要放置一个明确的glBindBuffer(GL_ARRAY_BUFFER, 0);来取消绑定缓冲区,我不知道 为什么在这个阶段必须这样做,因为我不需要它 之前.
    2. GL_UNSIGNED_INT似乎在android 4上不存在,再次,我 不知道为什么现在不存在,而几天前确实如此.
    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.

    现在,我要修改proyect中的每个类,

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

    这篇关于Android NDK,Opengl es 2,VBO导致渲染崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆