OpenGL ES 2.0 GLKit GL_LINE_SMOOTH Error

I am using glDrawArrays drawing to paint GL_LINE_STRIP and want to make them smooth. I saw a couple of questions, here people recommend using glEnable (GL_LINE_SMOOTH) and glHint (GL_LINE_SMOOTH_HINT, GL_NICEST), but when I do this, I get an error. Here is 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 (or both) these lines, I get a GL ERROR. Any thoughts?

+3
source share
1 answer

I had this work (well!) With the context of ES1.1, i.e.

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

I am writing new code and trying to ride on the wave of the future (or at least the recent past) and upgrade to ES2.0. In the 2.0 universe, I had moderate success with

view.drawableMultisample = GLKViewDrawableMultisample4X;

install in my override GLKViewController -viewDidLoad, install on mine GLKView. YMMV.

0
source

All Articles