我有一个问题,我无法解决它,只是收到错误:
节目接收信号:“0”。
由于信号 10 (SIGBUS),调试器已退出。由于信号 10 (SIGBUS),调试器已退出。
这是一些方法,如果我将其注释掉,问题就会消失
- (void)loadTexture {
const int num_tex = 10;
glGenTextures(num_tex, &textures[0]);
//TEXTURE #1
textureImage[0] = [UIImage imageNamed:@"wonder.jpg"].CGImage;
//TEXTURE #2
textureImage[1] = [UIImage imageNamed:@"wonder.jpg"].CGImage;
//TEXTURE #3
textureImage[2] = [UIImage imageNamed:@"wall_eyes.jpg"].CGImage;
//TEXTURE #4
textureImage[3] = [UIImage imageNamed:@"wall.jpg"].CGImage;
//TEXTURE #5
textureImage[4] = [UIImage imageNamed:@"books.jpg"].CGImage;
//TEXTURE #6
textureImage[5] = [UIImage imageNamed:@"bush.jpg"].CGImage;
//TEXTURE #7
textureImage[6] = [UIImage imageNamed:@"mushroom.jpg"].CGImage;
//TEXTURE #8
textureImage[7] = [UIImage imageNamed:@"roots.jpg"].CGImage;
//TEXTURE #9
textureImage[8] = [UIImage imageNamed:@"roots.jpg"].CGImage;
//TEXTURE #10
textureImage[9] = [UIImage imageNamed:@"clean.jpg"].CGImage;
for(int i=0; i<num_tex; i++) {
NSInteger texWidth = CGImageGetWidth(textureImage[i]);
NSInteger texHeight = CGImageGetHeight(textureImage[i]);
GLubyte *textureData = (GLubyte *)malloc(texWidth * texHeight * 4);
CGContextRef textureContext = CGBitmapContextCreate(textureData,
texWidth, texHeight,
8, texWidth * 4,
CGImageGetColorSpace(textureImage[i]),
kCGImageAlphaPremultipliedLast);
CGContextDrawImage(textureContext, CGRectMake(0.0, 0.0, (float)texWidth, (float)texHeight), textureImage[i]);
CGContextRelease(textureContext);
glBindTexture(GL_TEXTURE_2D, textures[i]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
free(textureData);
}
}
任何人都可以帮助我在此方法中释放/删除对象吗?谢谢。