hi,
I'm working on drawing protein molecules, and as some of u might know, protein molecules are made up of 1000's & 1000's of atoms.
For a basic representation of these molecules, i'm just rendering each atom as a gluSphere, with 10 slices and 10 stacks.
the problem is, when the number of atoms gets large (say 8000) the frame rate drops down to less than 1 fps.
I have frustum culling, but that only helps when only a small portion of the molecule is on the screen.
i've also tried glCullFace(GL_BACK); glEnable(GL_CULL_FACE); but i can't see any difference (maybe gluSphere is handled differently?)
i've also tried to lower the number of slices/stacks depending on how close to the molecule the camera is, but as soon as the slice/stack count is less than 5, even from a distance the "spheres" don’t really look like spheres
i'm about to try use a display list for each kind of atom there is (because i plan to make each atom type a different size/color/etc).
but i was also thinking about using NURBS to draw the spheres.
however, i don't know if it's even possible to draw spheres using nurbs, and if it is possible, i was unable to make google point me to any good examples. I don't really know anything about nurbs tho, so i was wondering if anyone thinks this will help me. i assume it would create a more accurate surface, but how much extra work does the computer need to do to make them, compared to say the gluSphere?
anyways, here is the code i use to display the molecules. suggestions, comments, criticisms whatever will be greatly appreciated.
Thanks in advance
--Tristan
[This message has been edited by torisutan (edited 09-05-2003).]Code :/* off somewhere in the init section of code */ glClearColor(0.0f, 0.0f, 0.0f ,0.0f); glClearDepth(1.0f); glClearStencil(0); glShadeModel(GL_SMOOTH); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glEnable(GL_DEPTH_TEST); glEnable(GL_ALPHA_TEST); glEnable(GL_BLEND); glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* ----------------------------------------- */ void OpenGLMolecule::draw() { GLUquadric *pObj = gluNewQuadric(); gluQuadricNormals(pObj, GL_SMOOTH); gluQuadricTexture(pObj, GL_TRUE); Molecule::Atom tempAtom; glColor3f(1.0f, 1.0f, 1.0f); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); int count = 0; for (int i = 0 ; i < getNumberOfAtoms() ; i++) { tempAtom = getAtom(i); if (CFrustum::getInstance()->checkSphere(tempAtom.getXpos() - origin.x, tempAtom.getYpos() - origin.y, tempAtom.getZpos() - origin.z, 1.0f)) { count++; glPushMatrix(); glTranslatef(tempAtom.getXpos() - origin.x, tempAtom.getYpos() - origin.y, tempAtom.getZpos() - origin.z); gluSphere(pObj, 1.0f, 10, 10); glPopMatrix(); } } glDisable(GL_CULL_FACE); gluDeleteQuadric(pObj); }




