GL_QUAD_STRIP results in triangles

Hi Folks,

I’ve been working on a plugin for the flight simulator X-Plane for quite some time now, which also involved OpenGL.
The plugin should project a line in the simulated world one could fly along.

Only recently, I changed from simply drawing a line to drawing multiple cubes with alternating color, so guessing the distance between the line and the aircraft is easier.
However, I seem to have totally misunderstood a (probably several) concept of OpenGL.

On the one hand, the Quads appear as triangles, which even change based on the side you’re looking at them from.
On the other hand, Quads drawn later appear over the quads drawn earlier, even though they are actually behind them.

I’d really appreciate it, if someone could help me!
Thanks in advance,
nik

Some code:

        for(i=0; i<1000; i++){
            glColor3f(1, 0, (i%2) ? 1 : 0);
            glBegin(GL_QUAD_STRIP);
            startX = endX;
            startZ = endZ;
            endX = endX + 100 * sin(degreeNorthPipeline * PI / 180);
            endZ = endZ - 100 * cos(degreeNorthPipeline * PI / 180);
            glVertex3f(endX+xPipeOffset, targetPositionY+2.5, endZ+zPipeOffset);
            glVertex3f(startX+xPipeOffset, targetPositionY+2.5, startZ+zPipeOffset);
            glVertex3f(startX+xPipeOffset, targetPositionY-2.5, startZ+zPipeOffset);
            glVertex3f(endX+xPipeOffset, targetPositionY-2.5, endZ+zPipeOffset);
            glVertex3f(endX-xPipeOffset, targetPositionY-2.5, endZ-zPipeOffset);
            glVertex3f(startX-xPipeOffset, targetPositionY-2.5, startZ-zPipeOffset);
            glVertex3f(startX-xPipeOffset, targetPositionY+2.5, startZ-zPipeOffset);
            glVertex3f(endX-xPipeOffset, targetPositionY+2.5, endZ-zPipeOffset);
            glVertex3f(endX+xPipeOffset, targetPositionY+2.5, endZ+zPipeOffset);
            glVertex3f(startX+xPipeOffset, targetPositionY+2.5, startZ+zPipeOffset);
            glEnd();
        }

Some pics of how it should not look like:
http://imageshack.us/photo/my-images/685/bildschirmfoto20110926u.png/

inside of the tube:
http://imageshack.us/photo/my-images/94/bildschirmfoto20110926u.png/

That is the result of improper vertex order. If you are using quad (or triangle) strips define two-by-two vertices in the strip, like this:


1--3--5--7--...
|  |  |  |
2--4--6--8--...

That’s because you didn’t enable depth test.

Wow, that solved it! Works like a charm!
If I think about all the hours I’d have spent if I had tried to spot the problem…

Thank you very much!
nik