文本文件与大存储在openGL
Text-file with large storage in openGL
我正在编写一个程序,它必须存储对象的位置。这个数据可以达到100MB以上,我想把它存储在硬盘上。现在,我搜索了一下,有几种方法可以做到这一点:txt-file, sql, xml,…
我已经知道如何在c++中制作文本文件。但是,.txt文件存储大量数据的优势是什么呢?最好的方法是什么?
目前我逐行存储数字,所以我可以用getline()
读取它。但它给我带来了问题,它读起来不太好。也许是因为。txt不能处理很多数据,也许是因为逐行读取很慢,这给我带来了问题。有人知道怎么解这个吗?
_chdir("c:/Documents and Settings/Bram/Bureaublad/cloth3d");
ofstream mfile;
mfile.open("example.txt", ifstream::out);
some calculations...
mfile << (double) vervangplaats[i][j][0] << "n";
mfile << (double) vervangplaats[i][j][1] << "n";
mfile << (double) vervangplaats[i][j][2] << "n";
// the data is stored in the .txt file
mfile.close();
将数据存储在TXT文件中现在我把它提取出来。
std::string b;
ifstream file("example.txt", ifstream::out);
if(file.is_open())
{
getline(file, b);
result[0][teller_x][teller_y] = (double) atof(b.c_str());
getline(file, b);
result[1][teller_x][teller_y] = (double) atof(b.c_str());
getline(file, b);
result[2][teller_x][teller_y] = (double) atof(b.c_str());
}
最后一个带有getline的函数在一帧中使用2500次。
并且帧不加载,可能是因为每帧的getline量很高,或者只是因为txt不适合存储太多数据?
嗯,每帧从磁盘加载数据从来都不是一个好主意,那将会太慢。在开始渲染之前,必须将数据加载到内存一次。
也就是说,文本文件最适合于需要人类可读和可移植的数据。
像这样的低级数据通常以二进制形式存储,这使得文件更小,加载更简单,更快。
相关文章:
- 将字符串存储在c++中的稳定内存中
- OpenGL - 在抛出"__gnu_cxx::recursive_init_error"实例后终止调用?
- std::原子加载和存储都需要吗
- C++:将控制台输出存储在宏中更好吗
- opengl-VAO也存储Texrture单元调用
- 使用OpenGL和Eigen来存储顶点数据和glVertexAttribPointer
- 如何使用OpenImageio将RGB值存储在数组中?(使用C ,OpenGL)
- 将 OpenGL 颜色附件存储在 constexpr GLenum 数组中
- c++OpenGL发布用存储在对象中的vbo和vao绘制网格
- 正在存储OpenGL状态
- 手动检索和存储指向 OpenGL 函数的指针时遇到问题
- 着色器存储缓冲区中的 OpenGL 顶点
- OpenGL:将Z深度设置为统一深度,而不是冗余存储在顶点内
- OpenGL:着色器存储缓冲区映射/绑定
- OpenGL 上下文存储在哪里
- 自定义分配器,用于将stl矢量存储在OpenGL缓冲区对象中
- 文本文件与大存储在openGL
- OpenGL/ c++将所有纹理资源作为静态成员存储在一个单独的类中
- 在opengl阴影映射中存储纹理中的顶点深度信息
- 为什么着色器和程序在OpenGL中存储为整数