SpriteKit和UIKit兼容性:迁移到Swift 2时OpenGL错误? [英] SpriteKit and UIKit compatibility: OpenGL error when migrating to Swift 2?

查看:98
本文介绍了SpriteKit和UIKit兼容性:迁移到Swift 2时OpenGL错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我迁移到Swift 2以来,我只是不了解发生了什么. 我有一个选项卡式应用程序,但出现此错误:

I just don't understand what is going on since I migrated to Swift 2. I have a Tabbed application and I am getting this error:

<CAEAGLLayer: 0x7fb2e053fb40>: calling -display has no effect.
Assertion failed: (length + offset <= _length), function commit_data, 
file /BuildRoot/Library/Caches/com.apple.xbs/Sources/Jet_Sim/Jet-1.50/Jet/jet_types_OpenGL.h, line 863.

我知道它确实很模糊,但是我不知道从哪里开始寻找错误. 谢谢.

I know it is really vague but I don't know where to start looking for bugs. Thanks.

修改: 我只是意识到这可能与我试图将GameViewController嵌入TabbedController的事实有关. 但是,它在iOS 9.0之前没有引起任何错误. 有任何线索吗?

I just realized it might be related to the fact that I am trying to embed a GameViewController into the TabbedController. However, it did not cause any error before iOS 9.0. Any clue?

推荐答案

好,所以问题出在SKShapeNode上.我绘制的环部分的顶点过多.通过减少以下功能中的步骤数,问题消失了!!

Ok, so the problem was with SKShapeNode. I was drawing ring portions with too many vertices. By decreasing the number of steps in the following function, the problem disappeared!!

func drawPortion2(r1:CGFloat, r2:CGFloat, angle1:CGFloat, angle2:CGFloat, fillColor:UIColor, steps:Int)->SKShapeNode{
let vertices=UnsafeMutablePointer<CGPoint>.alloc(2*steps);
let stepsF=CGFloat(steps);

for j in 0..<steps{

    vertices[j]=CGPoint(x: r2*cos(angle2-CGFloat(j)*(angle2-angle1)/stepsF), y: r2*sin(angle2-CGFloat(j)*(angle2-angle1)/stepsF));

}

for j in 0..<steps {

    vertices[steps+j]=CGPoint(x: r1*cos(angle2-CGFloat(steps-j)*(angle2-angle1)/stepsF), y: r1*sin(angle2-CGFloat(steps-j)*(angle2-angle1)/stepsF));

}

let portion=SKShapeNode(points:vertices, count: 2*steps);
//portion.position=centerPos;
portion.fillColor=fillColor;

return portion;

}

这篇关于SpriteKit和UIKit兼容性:迁移到Swift 2时OpenGL错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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