3

I'm using drawing a glDrawArrays to draw a GL_LINE_STRIP and want to make them smooth. I've seen on a couple questions here people recommend using glEnable(GL_LINE_SMOOTH) and glHint(GL_LINE_SMOOTH_HINT, GL_NICEST), but when I do so, I'm getting an error. Here's my code:

- (void)setupGL
{
    [EAGLContext setCurrentContext:self.context];

    self.effect = [[[GLKBaseEffect alloc] init] autorelease];
    self.effect.light0.enabled = GL_FALSE;
    self.effect.light1.enabled = GL_FALSE;
    self.effect.light2.enabled = GL_FALSE;
    self.effect.lightModelAmbientColor = GLKVector4Make(0.0f, 0.0f, 0.0f, 1.0f);

    glDisable(GL_DEPTH_TEST);
//    glEnable(GL_LINE_SMOOTH);
//    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glGenVertexArraysOES(1, &_vertexArray);
    glBindVertexArrayOES(_vertexArray);

    glGenBuffers(1, &_vertexBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_DYNAMIC_DRAW);

    glEnableVertexAttribArray(GLKVertexAttribPosition);
    glVertexAttribPointer(GLKVertexAttribPosition, VERTEX_POS_DATA_SIZE, GL_FLOAT, GL_FALSE, VERTEX_DATA_SIZE * sizeof(GLfloat), BUFFER_OFFSET(0));

    glEnableVertexAttribArray(GLKVertexAttribColor);
    glVertexAttribPointer(GLKVertexAttribColor, VERTEX_COLOR_DATA_SIZE, GL_FLOAT, GL_FLOAT, VERTEX_DATA_SIZE * sizeof(GLfloat), BUFFER_OFFSET(VERTEX_POS_DATA_SIZE * sizeof(GLfloat)));    

    glLineWidth(10.0);
}

If I uncomment either (or both) of those lines, I get a GL ERROR. Any thoughts?

4

1 回答 1

0

我在 ES1.1 上下文中工作(很好!),即

self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];

我正在编写新代码并尝试顺应未来的潮流(或者至少是现在最近的过去)并跳到 ES2.0。在 2.0 宇宙中,我取得了适度的成功

view.drawableMultisample = GLKViewDrawableMultisample4X;

在我GLKViewController-viewDidLoad覆盖中设置,在我的GLKView. YMMV。

于 2013-07-20T02:51:28.837 回答