Probleme mit Reihenfolge der Objekte beim OpenGL-Rendern



  • hi leute,

    i am trying to render my own small coordinate system which basically consists of:
    - 3 axis which are 3 GL_LINES
    glBegin(GL_LINES);
    glVertex3f(0.0, 0.0, 0.0);
    glVertex3f(factor, 0.0, 0.0);
    glEnd();
    - for the 3 arrows i use a GLUquadricObj - gluCylinder and gluDisk which i translate to the end of the arrow
    - the axis names (X Y Z) are textures mapped on quads

    this works fine...BUT...
    i have a funny occurence while rotating everything so that i have the impression that the order how i draw the individual objects matters somehow to the rendered result. here are some pictures so that you see what i am talking \1:

    1. my initial coordinate system - all axis direct out of the screen:
      http://www.cs.uni-magdeburg.de/~kreinema/pics/coordsys1.gif
    2. i rotate the system and x directs out of the screen:
      http://www.cs.uni-magdeburg.de/~kreinema/pics/coordsys002.gif
    3. i rotate again but x directs into the screen...
      http://www.cs.uni-magdeburg.de/~kreinema/pics/coordsys003.gif

    as you can see image 2) and 3) look pretty much the same.
    what i did:
    i put all the individual objects on a matrixstack in the following order (in code):

    1. XYZ textures on quads
    2. gluDisk followed by gluCylinder
    3. axis lines

    has anybody an idea why i have this kind of phenomenon? if i draw the objects in different orders they occlude each other...

    danke. kerstin.



  • Z-Buffer aktivieren



  • ja, du hast recht... irgendwo vorher im code wurde glDisable(GL_DEPTH_TEST); aufgerufen. da ist das ergebnis ja klar.. vielen dank. 🙂

    einziges problem ist jetzt:
    ich habe 2 systeme..

    1. zum zeichnen des modells:
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glSetProjectionMode();
      // Setzen der Modelviewmatrix
      glMatrixMode(GL_MODELVIEW);
      glPushMatrix();
      glOrtho(MyOrthoLeft, MyOrthoRight, MyOrthoBottom, MyOrthoTop, MyOrthoNear, MyOrthoFar);
      ..

    2. zum zeichnen des koordinatensystems:
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glOrtho(0.0, width(), 0.0, height(), -100.0, 100.0);

    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();
    ..

    damit die sich nicht in die quere kommen..
    wenn ich für das koordinatensystem den z-buffer aktiviert habe, werden meine achsen weggeschnitten, sobald sie in den monitor "reinschauen"... ich bin gerade etwas überfragt, warum das der fall ist. mein sichtkörper ist auch groß genug - hatte auch schon versucht, ihn extrem groß zu machen... 😕


Anmelden zum Antworten