简体   繁体   English

更新到iOS 7.1后,OpenGL ES精灵不再渲染

[英]OpenGL ES sprites no longer render after updating to iOS 7.1

I am using a simple 2D sprite class based on this tutorial to render PNG bitmaps to the screen: 我使用基于本教程一个简单的2D精灵类来渲染PNG位图到屏幕上:

http://www.raywenderlich.com/9743/how-to-create-a-simple-2d-iphone-game-with-opengl-es-2-0-and-glkit-part-1 http://www.raywenderlich.com/9743/how-to-create-a-simple-2d-iphone-game-with-opengl-es-2-0-and-glkit-part-1

Everything worked fine on both my iPhone 4S running iOS 6.1 and my iPhone 5S running iOS 7. Since I updated to iOS 7.1, and on my MacBook Air updated to Mavericks and XCode 5.1, sprites no longer appear on the screen (I just get an empty white screen, which is the color I cleared the background to). 在运行iOS 6.1的iPhone 4S和运行iOS 7的iPhone 5S上,一切正常。由于我更新到iOS 7.1,并且在MacBook Air上更新到Mavericks和XCode 5.1,因此精灵不再显示在屏幕上(我只得到一个空白屏幕,这是我清除背景的颜色)。 When I build the app using XCode 5.1 and run on my iPhone 4S again, it still works. 当我使用的XCode 5.1构建应用程序,并在我的iPhone 4S再次运行,它仍然有效。

Does anyone know what could be causing this? 有谁知道是什么原因造成的? Has anyone run into this issue? 有没有人遇到这个问题? I am having trouble getting to the source of the problem due to my lack of understanding of OpenGL ES among other things. 我有麻烦的问题的根源是由于我缺乏除其他事项外的OpenGL ES的理解。 :) My sprite class is exactly the same as the one in the tutorial. :)我的精灵类与本教程中的类完全相同。

Let me know if more details/code snippets are required. 让我知道,如果需要更多的细节/代码段。

I'm not even going to look at the sample code since it doesn't sound like it's the same as your current code. 我什至不去看示例代码,因为它听起来好像与您当前的代码不同。 (You said 'based on'.) But I'll tell you how to find your problem. (您说“基于”。)但是,我将告诉您如何查找问题。

First, clear to something other than white (like red) as a test. 首先,清除白色(例如红色)以外的东西作为测试。

If the screen turns red you at least know that your view and context and open gl in general is working. 如果屏幕变成红色,则至少知道您的视图和上下文以及打开gl的总体效果。 That knocks out a lot of possible culprits. 这消除了许多可能的罪魁祸首。

Second.. use the debug tools and chances are it will take you right to your problem. 其次..使用调试工具,很可能会带您正确解决问题。 You have to run on a tethered device though and not the sim. 您必须在连接的设备上运行,而不是在SIM卡上运行。 Run your app... 运行您的应用...

OpenGL分析屏幕

Click on FPS in the debug navigator. 在调试导航器中单击FPS。 Then click analyze and be patient. 然后单击分析并耐心等待。 It will take a one frame snapshot of whats happening in open gl. 这将对open gl中发生的情况进行一帧快照。 It has to do a bunch of stuff to make that happen and it takes about 30 seconds. 它必须做很多事情才能实现,并且大约需要30秒。 But then you'll have an interactive thing that shows you the frame and will let you step through processes and see what code is making that happen, and the frame as it draws each element. 但是,然后您将获得一个交互式的东西,向您展示框架,并让您逐步执行流程,查看是什么代码使这种情况发生,以及框架绘制每个元素时的情况。 It's super cool actually. 真的很酷。 And probably it will show you an error message (in red). 可能会显示一条错误消息(红色)。

My guess is that it's no longer loading your sprite images. 我的猜测是它不再加载您的Sprite图片。 Something probably changed between 6 and 7 or the versions of Xcode or of OSX. 在6到7之间或Xcode或OSX的版本之间可能有所更改。 In that case the screen is blank because they're not loaded and therefore not being drawn. 在那种情况下,屏幕是空白的,因为它们没有被加载,因此没有被绘制。

EDIT: I think the analysis will help find your problem. 编辑:我认为分析将有助于发现您的问题。 But to offer more possibilities, in my experience when nothing is drawing it's often one of these things: 但是要提供更多的可能性,以我的经验,什么也没画,通常是这些事情之一:

  1. An overall OpenGL issue - set your clear color to red or blue to test. 整个OpenGL问题-将透明色设置为红色或蓝色进行测试。
  2. Shader didn't compile - always output shader compile errors so you know. 着色器未编译-总是输出着色器编译错误,因此您知道。
  3. Bad Shader math or logic - use gl_FragColor = vec4(0.0,0.0,1.0,1.0) or some contrasting color to test. 错误的Shader数学或逻辑-使用gl_FragColor = vec4(0.0,0.0,1.0,1.0)或一些对比色进行测试。 Can you see your structures? 你看到你的结构了吗?
  4. Program isn't getting an attribute. 程序没有属性。 Did you remember glEnableVertexAttribArray 你还记得glEnableVertexAttribArray
  5. Program isn't getting a uniform. 程序没有统一。 Use the Analyze feature above to check the uniform values to make sure they made it to the shader. 使用上面的“分析”功能检查均匀值,以确保它们到达着色器。

(i'll add more if I think of them) (如果我想到它们,我会添加更多)

When stuff does 什么时候做

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

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