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/