okay guys, i've already created a satellite but now i need it to rotate....i did something like this...

void myDisplayFunc(void)
{
 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

 glPushMatrix();
    glTranslatef(posX, posY, posZ);
    glRotatef(rotateX, 1.0f, 0.0f, 0.0f);
    glRotatef(rotateY, 0.0f, 1.0f, 0.0f);
    glRotatef(rotateZ, 0.0f, 0.0f, 1.0f);
    glScalef(scaleX, scaleY, scaleZ);

    GLUquadricObj *pObj = gluNewQuadric();
    gluQuadricDrawStyle(pObj, GLU_FILL);
    gluQuadricNormals(pObj, GLU_SMOOTH);
    setup();
    drawBackground();
    planet(pObj);
    glRotatef(-90,1,0,0);
    glTranslatef(0,-2,0);
 for(int i = 0; i < 360; i+= 30){
    glPushMatrix();
    glRotatef(ypoz, 0.0f, 1.0f, 0.0f);
        glTranslatef(0,10,0);
        glRotatef(i,0,1,0);
        drawSeat(pObj);
    glPopMatrix();
 }

 glPopMatrix();
 glFlush();
 glutSwapBuffers();
}

the thing is its creating alot of satellite, i juz need one to rotate....help me out pls...

May I guess that it is drawing exactly 12 satellites? Is it drawSeat(pObj); that draws your satellite?

If that is the case, you may want to try something like:

// First declare i as global so its value can be used
// over several iterations:
float i = 0.0f;

void myDisplayFunc(void)
{
 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

 glPushMatrix();
    glTranslatef(posX, posY, posZ);
    glRotatef(rotateX, 1.0f, 0.0f, 0.0f);
    glRotatef(rotateY, 0.0f, 1.0f, 0.0f);
    glRotatef(rotateZ, 0.0f, 0.0f, 1.0f);
    glScalef(scaleX, scaleY, scaleZ);

    GLUquadricObj *pObj = gluNewQuadric();
    gluQuadricDrawStyle(pObj, GLU_FILL);
    gluQuadricNormals(pObj, GLU_SMOOTH);
    setup();
    drawBackground();
    planet(pObj);
    glRotatef(-90,1,0,0);
    glTranslatef(0,-2,0);
    glPushMatrix();
    glRotatef(ypoz, 0.0f, 1.0f, 0.0f);
    glTranslatef(0,10,0);
    glRotatef(i,0,1,0);
    i = (i + 1.0f) % 360.0f; //Rotate one degree each iteration
    drawSeat(pObj);
    glPopMatrix();
 glPopMatrix();
 glFlush();
 glutSwapBuffers();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.