线程1:程序接收信号exc_bad_access?

时间:2012-05-03 06:22:52

标签: opengl-es

目前我正在使用简单的游戏应用程序,使用GL_TRIANGLE_STRIP绘制球形图像(从左向右移动)并使用GL_LINES在Touch中绘制一条线开始代表,当我触摸屏应用程序将退出程序接收信号exc_bad_access ,我花了14个小时,但我无法解决这个问题,请帮助我任何人。

先谢谢

我尝试了源代码:

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    Test =YES;
    [self.effect prepareToDraw];
     const GLfloat line[] =
     {
         0, 2,
         0,-3,
     };

     GLuint bufferObjectNameArray;
     glGenBuffers(1, &bufferObjectNameArray);
     glBindBuffer(GL_ARRAY_BUFFER, bufferObjectNameArray);
     glBufferData(
     GL_ARRAY_BUFFER,   // the target buffer 
     sizeof(line),      // the number of bytes to put into the buffer
     line,              // a pointer to the data being copied 
     GL_STATIC_DRAW);   // the usage pattern of the data 
     glEnableVertexAttribArray(GLKVertexAttribPosition); 
     glVertexAttribPointer(
     GLKVertexAttribPosition, // the currently bound buffer holds the data 
     2,                       // number of coordinates per vertex 
     GL_FLOAT,                // the data type of each component 
     GL_FALSE,                // can the data be scaled 
     2*4,                     // how many bytes per vertex (2 floats per vertex)
     NULL);                   // offset to the first coordinate, in this case 0 
     glDrawArrays(GL_Lines,0,3);
}


- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect 
{
    glClearColor(1, 1, 1, 1);
    glClear(GL_COLOR_BUFFER_BIT); 
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);

    NSLog(@"Children count:%d",[self.children count]); // Store ball image in NSMutable array
    for (SGGSprite * sprite in self.children)
    {
    self.effect.texture2d0.name = self.textureInfo.name;
    self.effect.texture2d0.enabled = YES;
GLKMatrix4 modelMatrix = GLKMatrix4Identity;    
    modelMatrix = GLKMatrix4Translate(modelMatrix, -self.position.x, -self.position.y, 0);
    modelMatrix = GLKMatrix4Translate(modelMatrix, self.contentSize.width, self.contentSize.height+140, 0);
    return modelMatrix;
    [self.effect prepareToDraw];
    long offset = (long)&_quad;

    glEnableVertexAttribArray(GLKVertexAttribPosition);
    glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
    NSLog(@"TexturedVertex:%ld",offset);

    glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, sizeof(TexturedVertex), (void *) (offset + offsetof(TexturedVertex, geometryVertex)));
    glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, sizeof(TexturedVertex), (void *) (offset + offsetof(TexturedVertex, textureVertex)));
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // When i tab the screen, the app will quit in this line like thread 1 :program received signal exc_bad_access.

    }
}

0 个答案:

没有答案