【发布时间】:2015-01-03 05:16:31
【问题描述】:
我已经编写了一堆函数来加载 collada (.dae) 文档,但问题是 opengl glut (console) 窗口对键盘响应的响应很慢,我只使用了 string.h、stdlib.h、和 fstream.h,当然还有 gl/glut.h 我的程序的主要功能是:
Void LoadModel()
{
COLLADA ca;
double digits[3];
ca.OpenFile(char fname);
ca.EnterLibGeo();// get the position of <library_geometries>
ca.GetFloats();// search for the <float_array> from start to end, and saves thier position in the file
ca.GetAtrributes("count", char Attrib); //same as collada dom's function but its mine
Int run=atoi(Attrib); // to convert the attributes of count which is string in the file to integer
glBegin(GL_TRIANGLES);
for (int i=0;i<=run;i++)
{
MakeFloats(digits); // will convert string digits to floating point values, this function uses the starting position and ending position which GetFloats() stored in variables
glVertex3f(digits[0], digits[1], digitd[2]);
}
glEnd();
glFlush();
}
此应用程序在不将整个文件内容加载到内存的情况下搜索标签,LoadModel() 函数将由 void display() 调用,因此每当我尝试使用 glut 的键盘功能时,它都会从文件中重新加载顶点数据,这对于小的 .dae 文件是可以的,但是大的 .dae 文件使我的程序响应缓慢,这是因为我的程序通过每秒加载 file() 来绘制顶点,这是加载模型的正确方法吗??
【问题讨论】:
标签: c++ parsing opengl collada