1

我编写了一个使用 opengl es 2.0 绘制对象的应用程序。该应用程序在装有 iOS 5.1.1 和 6+ 的 iPhone 上进行了测试。iOS 5.1.1 渲染没问题。但是 iOS 6+ 在渲染时会显示一个不需要物理绘制的对象。它是一个正方形,根据缩放或平移场景而变化。我附上截图和视频。我是 OpenGL 和 Objective-C 的初学者,这将是我的愚蠢错误。

图片: 有错误的图片。
视频: 有错误

的视频 感谢您的建议。

viewDidLoad:


    ....
    GLKView *glkView = (GLKView *)self.view;
    glkView.delegate = self;
    glkView.context = self.context;
    glkView.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;
    glkView.drawableDepthFormat = GLKViewDrawableDepthFormat24;
    self.preferredFramesPerSecond = 60;
    [EAGLContext setCurrentContext:self.context];
    effect = [[GLKBaseEffect alloc] init];
    effect2 = [[GLKBaseEffect alloc] init];
    textures = [[NSMutableArray alloc] init];
    ....

画法:


    - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
    {
        glClearColor([[set.paperColor objectAtIndex:0] floatValue]/255.0, [[set.paperColor   objectAtIndex:1] floatValue]/255.0, [[set.paperColor objectAtIndex:2] floatValue]/255.0,  [[set.paperColor objectAtIndex:3] floatValue]);
        glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
        // draw point
        if ([[root objectAtIndex:i] isKindOfClass:[PointO class]])
        {
            [effect prepareToDraw];
            [self drawPoint:[root objectAtIndex:i]];
        }
        // example draw texture
        if ([[root objectAtIndex:i] isKindOfClass:[Text class]])
        {
            glEnable(GL_BLEND);
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
            for (int j = 0; j < indexes.count; j++)
            {
                int index = [[indexes objectAtIndex:j]intValue];
                if (index == (i+1)) {
                    Sprite *sprite = [textures objectAtIndex:j];
                    [sprite render:[root objectAtIndex:i]];
                }
            }
            glDisable(GL_BLEND);
        }

4

0 回答 0