Original Post
Hello, I'm trying to write a 3d editor (as an exercise as much as for the use it will be to me). I'm curently rendering a grid in the world. I'd like the gridlines to get progressively lighter as they become more spaced apart (ala unrealed). I've achieved this by drawing the grid as dark grey at unit 1 width, lighter at unit width 2, lighter at unit width 4 and white at unit width 8, with the following code: This only works if I switch off depth testing. (If depth testing is on, only the darkest grid lines are visible). But, when I draw, say, a triangle in the world, even if depth testing is on when I draw the triangle, the depth testing doesn't work between the triangle and the grid. I just get whichever was drawn last on top. Is there a way of drawing the grid so that it doesn't depth test against itself (each progressive layer of the grid) but still depth tests against the rest of the world. Cheers, Tim
float step = 1.0f;
float color = 0.2f;
for (int i = 0; i < 4; i++)
{
render(step, color);
step*=2f;
color+=0.2f;
}
glPushAttrib(GL_DEPTH_TEST);
glDisable(GL_DEPTH_TEST);
renderGrid();
glPopAttrib();