EXC_BAD_ACCESS在打开WEPopover时崩溃glDrawArrays
问题描述:
关于该应用程序:自定义openGL地图,由具有在基本地图上绘制叠加层功能的图块构建。该应用程序对于iPad和iPhone都是通用的。一些覆盖图是基于图块的,它们工作得很好。有些是由地图上的特定坐标绘制的圆圈构成的。点击圆圈打开弹出视图,并在地图上显示关于此特定点的信息。在iPhone库WEPopover用于实现类似于UIPopoverViewController的功能。EXC_BAD_ACCESS在打开WEPopover时崩溃glDrawArrays
这个问题只发生在iPhone上,只在设备上出现。当覆盖图由大量圆圈组成时,使用info打开弹出视图有时会导致覆盖层闪烁,并最终导致EXC_BAD_ACCESS在行上崩溃:glDrawArrays(GL_LINE_LOOP,0,360); 这只发生在iPhone上,永远不会在iPad或模拟器上。
代码点点:
绘制黑色圆圈与白色的轮廓:在iPhone
for (int i = [pointsArray count]-1; i >= 0; i--) {
int pinColor = 0xffff0000;
static GLfloat vertices[720];
for (int i = 0; i < 720; i += 2) {
vertices[i] = (cos(DEGREES_TO_RADIANS(i)) * scale * 1.5);
vertices[i+1] = (sin(DEGREES_TO_RADIANS(i)) * scale * 1.5);
}
glVertexPointer(2, GL_FLOAT, 0, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for (int dx = x0; dx <= x1; dx++)
{
glPushMatrix();
GLubyte a = (pinColor >> 24) & 0xff;
a = MIN((GLubyte) (opacity * 255), a);
glColor4ub(0, 0, 0, a);
GLfloat xx = point.x - centerX + dx * mapWidth;
xx *= zoom;
glTranslatef(xx, yy, 0);
glDrawArrays(GL_TRIANGLE_FAN, 0, 360); <-----sometimes crash here
int color = 0xffffffff;
GLubyte n = (color >> 24) & 0xff;
GLubyte r = (color >> 16) & 0xff;
GLubyte g = (color >> 8) & 0xff;
GLubyte b = (color >> 0) & 0xff;
n = MIN((GLubyte) (opacity * 255), n);
glColor4ub(r,g,b,n);
glLineWidth(1);
glDrawArrays(GL_LINE_LOOP, 0, 360); <------crash here
glLineWidth(1);
glPopMatrix();
}
glDisable(GL_BLEND);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, 0);
}
开幕酥料饼:
WEPopoverController *_popover = [[WEPopoverController alloc] initWithContentViewController:pointDetails];
_popover.popoverContentSize = pointDetails.view.frame.size;
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)
{
CGRect myrect2 = CGRectMake(xx,yy, 1, 1);
[_popover presentPopoverFromRect:myrect2 inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
} else {
CGRect myrect2 = CGRectMake(xx, yy, 1, 1);
[_popover presentPopoverFromRect:myrect2 inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
self.detailsPopIphone = _popover;
[_popover release];
每次触摸屏幕时
(移动规模的地图,open popover)重新渲染openGL地图。
我很乐意提供任何附加信息或代码。
答
解决了这个问题。 问题是,渲染的OpenGL覆盖WEPopover的动画是同时发生的,是什么导致冲突。组织代码的方式是渲染和动画一个接一个地解决问题。