如何在现代opengl中的几个std :: vector点之间画一条线

时间:2016-05-16 06:58:38

标签: c++ opengl vector opengl-3

    ...   

    glBindVertexArray(LineVertexArrayObject);
    glEnableVertexAttribArray(vertexPosition);
    glBindBuffer(GL_ARRAY_BUFFER, LineVertexBufferObject);

    glBufferData(GL_ARRAY_BUFFER,sizeof(GLfloat)*vector_of_points.size(), &vector_of_points[0] ,GL_DYNAMIC_DRAW);

    glVertexAttribPointer(
        vertexPosition,
        2,
        GL_FLOAT,
        GL_FALSE,
        2*sizeof(GLfloat),
        (GLvoid*)0
    );

    glDrawArrays(GL_LINES,0,NUMBER_OF_LINES);

    glDisableVertexAttribArray(AttributeColor);
    glDisableVertexAttribArray(vertexPosition);
    glBindVertexArray(0);

    ...

上面的代码是在一个std :: vector中绘制线条,但是当标题出现时,我如何在2D空间中的两个或几个不同的std ::矢量点之间绘制一条线,例如,如果我想要每个轴绘制一个parallel coordinate作为std :: vector?

0 个答案:

没有答案