Manipulating large models with OpenGL
Hi All,
I use opengl to load 3DS models and then rotated and translate it with mouse control. Some of these model are pretty big(~120K vertices), and I end up with very low frame rate(~2fps). Is there any way to accelerate this operation?
Thanks.
We can be more helpful if you can tell us how you're rendering the objects. I'm guessing you are using immediate mode, and if that's the case you should look into displaylists, and/or VBOs. Anyother possibility is that you don't have opengl setup properly on your computer, and you're stuck with a software implementation of opengl (shouldn't be the case if other opengl programs run at a decent speed).
I am sure my settings of opengl is correct because other GL programs run smoothly.
Here is my display function:
void display(void){
int l_index;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // This clear the background color to dark blue
glMatrixMode(GL_MODELVIEW); // Modeling transformation
glLoadIdentity(); // Initialize the model matrix as identity
gluLookAt(x, y, z,
x + lx,y + ly,z + lz,
0.0f,1.0f,0.0f);
glTranslatef (-eye[0], -eye[1], -eye[2]);
glRotatef(rot[0], 1.0f, 0.0f, 0.0f);
glRotatef(rot[1], 0.0f, 1.0f, 0.0f);
glRotatef(rot[2], 0.0f, 0.0f, 1.0f);
model.draw3ds();
frame++;
time=glutGet(GLUT_ELAPSED_TIME);
if (time - timebase > 1000) {
fprintf(stderr,"FPS:%4.2f\n",frame*1000.0/(time-timebase));
sprintf(s,"FPS:%4.2f",frame*1000.0/(time-timebase));
timebase = time;
frame = 0;
}
glFlush(); // This force the execution of OpenGL commands
glutSwapBuffers();
}
Here is my display function:
void display(void){
int l_index;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // This clear the background color to dark blue
glMatrixMode(GL_MODELVIEW); // Modeling transformation
glLoadIdentity(); // Initialize the model matrix as identity
gluLookAt(x, y, z,
x + lx,y + ly,z + lz,
0.0f,1.0f,0.0f);
glTranslatef (-eye[0], -eye[1], -eye[2]);
glRotatef(rot[0], 1.0f, 0.0f, 0.0f);
glRotatef(rot[1], 0.0f, 1.0f, 0.0f);
glRotatef(rot[2], 0.0f, 0.0f, 1.0f);
model.draw3ds();
frame++;
time=glutGet(GLUT_ELAPSED_TIME);
if (time - timebase > 1000) {
fprintf(stderr,"FPS:%4.2f\n",frame*1000.0/(time-timebase));
sprintf(s,"FPS:%4.2f",frame*1000.0/(time-timebase));
timebase = time;
frame = 0;
}
glFlush(); // This force the execution of OpenGL commands
glutSwapBuffers();
}
I think they are going to be identical. The VBO is used mostly for rendering dynamical objects ,where lists for statical.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement