View Full Version : Atomic Ball & Stick Model

03-17-2004, 04:43 AM
I must come up with a model for a molecule.
How do you utilise gluSphere and coordinates
so that various 'atoms'(the spheres) can be placed at certain locations.

03-17-2004, 04:58 AM
gluSphere is a glu Quadric.
Here's some code:

GlUquadric *mySphere;
mySphere = gluNewQuadric();
// Draw the sphere, we give a pointer to the quadric object
// followed by the radius of the sphere, the
// slices and the stacks. The radius speeks
// for itself. Slices and stacks is how
// smooth you want your sphere.
gluSphere(mySphere, 10, 20, 20);
// Termination
mySphere = NULL;

Initialization and Termination should be done usually only once and not every frame. Also search google for gluSphere and other glu functions. There are a lot of parameters you can define on how you want your object to be drawn.

[This message has been edited by moucard (edited 03-17-2004).]

03-18-2004, 03:15 AM
Thanks for that code, but how do I allocate each sphere with its own coordinates to place them at different positions?

03-18-2004, 11:07 PM
Use glTranslatef to move to a desired location and then draw your sphere there. Repeat as required.