PDA

View Full Version : Depth Testing Problem



plates
01-01-2002, 04:33 PM
if (planet[loop].atmos_phere != 0)
{
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D, bmptexture[planet[loop].atmos_texid]);
DrawSphere(planet[loop].radius + 0.05f, 32, 32);
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
}

The bit of code is used to draw a sphere surrounding another sphere (For an atmosphere on a planet), then map a texture to it, - The problem is the planet sphere is depth tested correctly, but the atmosphere sphere isn't, and consequently the atmosphere sphere shows up behind the planets (specifically the sun) as it rotates around it. I've tried every order of DEPTH TESTING statements, but I can't seem to get it right - the ones above seem, in my mind anyway, logically correct. If someone could point out what exactly I am doing wrong, would be fantastic.
I've posted my full Code & exe on http://www.sigmat.demon.co.uk/planets.zip - You need to read the readme.txt first before you run it tho. Anyway, as you will see when Uranus goes behind the sun, atmosphere is still rendered. Any help (code specific espeically) as always greatly appearicted.

Plates.

zed
01-01-2002, 05:36 PM
enable depth test
glDepthMAsk( GL_FALSE ); // turn depth writes off
draw atmosphere

nemesis
01-01-2002, 11:37 PM
I don't know if it could be the problem but, you can just try it out:

glEnable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glBindTexture(GL_TEXTURE_2D, bmptexture[planet[loop].atmos_texid]);
DrawSphere(planet[loop].radius + 0.05f, 32, 32);
glDisable(GL_BLEND);

-nemesis-

[This message has been edited by nemesis (edited 01-02-2002).]