我正在尝试绘制一些已存储为顶点数组的轮廓:
typedef struct
{
float* vertices;
int nrPoints;
}VertexCurve;
list<VertexCurve> CurveList;
我正在使用 opengl es 2.0 书中的一些示例:http: //opengles-book.com/
绘图方法如下所示:
void Draw ( ESContext *esContext )
{
UserData *userData = (UserData*)esContext->userData;
// Set the viewport
glViewport ( 0, 0, esContext->width, esContext->height );
// Clear the color buffer
glClear ( GL_COLOR_BUFFER_BIT );
// Use the program object
glUseProgram ( userData->programObject );
//glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
//glEnable(GL_SAMPLE_COVERAGE);
//glSampleCoverage(0.5, GL_FALSE);
glEnableVertexAttribArray ( 0 );
//glLineWidth(1);
for (list<VertexCurve>::iterator it = CurveList.begin();
it != CurveList.end(); it++)
{
// Load the vertex data
glVertexAttribPointer ( 0, 3, GL_FLOAT, GL_FALSE, 0, (*it).vertices );
glDrawArrays ( GL_LINE_LOOP, 0, (*it).nrPoints );
}
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
}
绘图的结果还有:
我需要的是在 OpenGL ES 2 中拥有更平滑的线条(抗锯齿),并且可以通过多重采样来完成。您可以从代码中看到我尝试使用特定于该技术的一些方法,但我无法完全理解它们的用法并得到了不好的结果:
如果有人可以向我解释如何获得抗锯齿线条并使轮廓更平滑,我将非常感激。