How to manipulate(translate\rotate) massive model in opengl more fast?

Started by
11 comments, last by biki_ 15 years ago
language:vc++ graphic platform: opengl a Large Model Visualization, more than one million triangles element, onece i display the model, if i translate or ratate it, it's display very slowly. i hope it can be like the cad system performce, can you give me some good propose?
Advertisement
You should try to give more information, like the algorithm you are using ;)

Do you only redraw the screen when the model moves? Then your drawing is the issues. Or is the rotating/translating the problem. You are doing the translate/rotate part on the GPU, right? You aren't using immediate mode, right?
And... you are rotating the matrix before drawing the model, not translating/rotating each vertex?

"Game Maker For Life, probably never professional thou." =)
oh, my use like this:

glTranslatef();
glRotatef();
glScalef();

//draw model
glBegin(GL_TRIANGLES)
glVertex3f();
glVertex3f();
glVertex3f();
glEnd();


if my model is too big, once i ratate the my model, the display is very slowly,

i just use opengl only , i didn't write other algorithm!

thank you!
For large models (and certainly by the time you are drawing million vertex models), you need to ditch immediate mode (glBegin/glEnd/etc.), and use Vertex Buffer Objects (VBO) instead.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

swiftcoder is right - even if not VBO just using vertex arrays (glVertexPointer() etc) will be a huge step up.

Your display is going to be slow even if its not rotating, you just don't notice because nothing is moving :)
Thanks swiftcoder and Exorcist very much!

But someone says displaylist is better than VBO ,

How do you think?
Display lists is a feature of the past, and will even be removed in the future. Use VBO.
VBO is good, you should also try to exploit structure of model you want to display. for example if it's a dense scan of simple object then you could use some LOD technique (simple clustering might work) and display reduced object when user is manipulating it. when user stops, you draw full detail.
if object is not densely sampled but has big depth complexity like large buildings then you should also use occlusion query.
Hey,I use VBO like below,but the speed is still not satisfied to me. it's just faster than immediate mode (glBegin/glEnd/etc.) a little.


static int isFirstCall=1;
if (GLEE_ARB_vertex_buffer_object)
{

if (isFirstCall)
{
//asign a buffer,vertex to it
glGenBuffersARB(1,&g_pMesh->m_nVBOVertices);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,g_pMesh->m_nVBOVertices);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,g_pMesh->m_nVertexCount*sizeof (CVec),g_pMesh->m_pVertices,GL_STATIC_DRAW_ARB);

//assign a buffer, indices to it
glGenBuffersARB(1,&g_pMesh->m_nVBOIndices);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,g_pMesh->m_nVBOIndices);
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, g_pMesh->m_nIndexCount*sizeof(int),g_pMesh->m_pIndices,GL_STATIC_DRAW_ARB);

delete [] g_pMesh->m_pVertices;
delete [] g_pMesh->m_pIndices;
isFirstCall=0;
}


glBindBufferARB(GL_ARRAY_BUFFER_ARB,g_pMesh->m_nVBOVertices);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,g_pMesh->m_nVBOIndices);

//most likely vertex array
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,sizeof(CVec),NULL);
glDrawElements(GL_TRIANGLES,unvModel.iCTETRANum*12,GL_UNSIGNED_INT,NULL);

}
else
{
//no support vbo,using vertex array
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,sizeof(CVec),g_pMesh->m_pVertices);
glDrawElements(GL_TRIANGLES,unvModel.iCTETRANum*12,GL_UNSIGNED_INT,g_pMesh->m_pIndices);
}

This topic is closed to new replies.

Advertisement