• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 908
  • Last Modified:

Opengl spin shape

I am trying to get a sphere to spin on user input in opengl.

I have a class for my sphere which is a weapon in my game like below.

void Weapon::DrawWeapon()
    // Draw the Handle
   glScalef (2.0, 0.4, 1.0);
  //glRotatef ((GLfloat) weapon, 0.0, 0.0, 1.0);



I have a function for the spin of the sphere

void spinDisplay(void)
   spin = spin + 2.0;
   if (spin > 360.0)
      spin = spin - 360.0;

How do I use this spin function with the sphere can you use it with glrotatef
1 Solution
Hi tango2009,

this sounds pretty much like a duplicate of http://www.experts-exchange.com/Programming/Game/Game_Graphics/OpenGL/Q__26899124.html

See my answer there, basically you must swap the glTranslate and glRotate calls in order to rotate the object inplace, meaning first translate then rotate.

Since this is discussed in the other q too, I would suggest we delete this question.

There is also the potential problem that your rotation vector is not a unit length.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now