绘制的 OpenGL 点消失,绘制调用和交换缓冲区问题

OpenGL points drawn disappear, draw call and swap buffer issue?

本文关键字:绘制 交换 缓冲区 问题 调用 OpenGL 消失      更新时间:2023-10-16

我想从已经使用 GL_POINTS 发送到 GPU 的顶点数据中在屏幕上绘制点。此刻,它们被绘制了一瞬间,然后消失了。我正在使用时间相关的循环,因为我希望点按顺序出现......

if (currentTime > insertionRateTime)
{
    cout << "insertionRateTime = " << insertionRateTime << "index" << index << endl;
    insertionRateTime += insertionRate;
    glDrawArrays(GL_POINTS, index, 1); 
    index += 1;
}
glfwSwapBuffers(window);
glfwPollEvents();

有人能在这里透露什么吗?如果我将 glDrawArray 放在 if 语句之外,那么绘制的点将保留,直到绘制下一个点:(

按照 BDL 在评论中的建议,通过在 glDrawArrays 中增加 'count' 参数来解决此问题!谢谢!