【发布时间】:2020-04-12 02:19:08
【问题描述】:
AM 试图从 CSV 文件中绘制一些点。由于文件很大(>2GB),将文件内容加载到向量std::vector<std::vector<std::string> >parsedCsv 会引发内存不足异常。
所以我想,与其将文件读取到矢量然后绘制它,不如直接从 CSV 绘制它。我正在寻找下面glVertex3f(x,y,z)的一些修改@
std::ifstream data("D:\\Files\\Dummy2.csv");
std::string line;
while (std::getline(data, line))
{
std::stringstream lineStream(line);
std::string cell;
std::vector<std::string> parsedRow;
while (std::getline(lineStream, cell, ','))
{
glBegin(GL_POINTS);
glColor3f(0.0f, 1.0f, 1.0f);
glVertex3f(----how to represent the points--?)
glEnd();
}
CSV 文件已经是所需的格式:
x1,y1,z1
x2,y2,z2
x3,y3,z3
-------
----
--
有什么建议吗?
【问题讨论】:
-
小提示:这种工作方式需要每渲染一帧通读整个文件。如果您打算在程序中添加缩放/平移/任何内容,您将需要重新读取文件或使用 VBO 将点上传到 GPU。
标签: c++ opengl visual-c++ freeglut opengl-compat