0

I've started using OpenGL and I'm trying to create a wired sphere with colored longitude lines (like timezones) that rotates. I'm trying to draw them using gluDisk-s and apply shifting in glRotatef func but I get following result (shown on images) How can I fix it? May be there is better way to do this?

The code I'm using:

void CreateDisk(int shift) {
    quad = gluNewQuadric();
    gluQuadricDrawStyle(quad, GLU_LINE); 
    glPushMatrix ();
    glTranslatef (0., 0., 1.);

    glRotatef(shift, 0, 1, 0);
    glRotatef(count, 0, 1, 0);

    gluDisk (quad, 0.5, .5, 50, 1);
    glPopMatrix ();
}

void display() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(30, aspect, .5, 50);
    glMatrixMode(GL_MODELVIEW); //select the modelview matrix.
    glLoadIdentity ();
    gluLookAt(0,0,4,
              0,0,0,
              0,1,0);

    glPushMatrix();
    glColor3f(1, 0, 1);
    CreateDisk(20);
    glColor3f(1, 0, 0);
    CreateDisk(60);
    glPopMatrix();

    glutSwapBuffers();
}

Currently it's creating two disks, that's for testing. First screen Second screen

daria.p
  • 21
  • 2
  • FYI: The OpenGL fixed function pipeline has been deprecated for a number of years. You would be better served updating to modern OpenGL and asking your question again. See: http://stackoverflow.com/questions/13647108/matrix-stacks-in-opengl-deprecated and http://stackoverflow.com/questions/15305879/glpushmatrix-deprecated-gl30-gl43-solution-basic-box-example – Richard Critten Aug 30 '16 at 13:11
  • One reason why the fixed function pipeline is still around is because it is good for learning. So as long as you understand that modern OpenGL is different and that you'll have to learn different style later, it is ok. – michalsrb Aug 30 '16 at 13:50
  • I think it's a perspetive problem. You can draw the axis lines o change gluPerspective by glOrtho. – JMA Aug 30 '16 at 14:08
  • @daria.p I just tried your code and it seems ok, it's just a confusing perspective as JMA said. Try to add more circles and you'll see it more clearly. – michalsrb Aug 30 '16 at 14:09
  • Hard to tell without seeing the full code, but isn't this just an aspect ratio issue? Shouldn't you set up your viewport? – Patrik H Aug 31 '16 at 08:51

0 Answers0