[英]OpenGL ES 2.0 GLKit GL_LINE_SMOOTH error
I'm using drawing a glDrawArrays to draw a GL_LINE_STRIP and want to make them smooth. 我正在使用绘制glDrawArrays绘制GL_LINE_STRIP并希望使它们平滑。 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. 我在几个问题上看到人们建议使用glEnable(GL_LINE_SMOOTH)和glHint(GL_LINE_SMOOTH_HINT,GL_NICEST),但是当我这样做时,我收到了一个错误。 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. 如果我取消注释这些行中的任何一行(或两者),我会得到GL错误。 Any thoughts? 有什么想法吗?
I had that working (well!) with an ES1.1 context, ie 我有这个工作(好吧!)与ES1.1上下文,即
self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
I'm writing new code and trying to ride the wave of the future (or at least, the now-recent past) and jump to ES2.0. 我正在编写新的代码,并试图驾驭未来的浪潮(或至少,现在最近的过去)并跳到ES2.0。 In the 2.0 universe, I have had moderate success with 在2.0宇宙中,我取得了一定的成功
view.drawableMultisample = GLKViewDrawableMultisample4X;
set in my GLKViewController
's -viewDidLoad
override, set on my GLKView
. 设置在我的GLKViewController
的-viewDidLoad
覆盖中,在我的GLKView
上设置。 YMMV. 因人而异。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.