Skip to main content
gamedev.net
🔒 Locked

zDepth

Started by BloodLust666 0 replies 700+ views
Original Post
BloodLust666
BloodLust666
in my engine, i render all the sprites first, (quads), with lighting enabled; then my drawing components (lines, rectangles, etc), without lighting. I'm drawing a sprite at Z of -1 and a rectangle with Z -5, but when the scene is drawn, the transparent red background (the drawing component quad), is being draw in front of the sprite. here's the code

// loop
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(false);
glEnable(GL_LIGHTING);

EntityManager.Render(m_fTimeElapsed);
ParticleManager.Render(m_fTimeElapsed);

// Disable textures
glDisable(GL_TEXTURE_2D);
glDepthMask(true);
glDisable(GL_LIGHTING);

DrawingManager.Render();
// end loop

-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
jmaupay
jmaupay
What arrives if you do glDepthMask(true); instead of
glDepthMask(false); for your sprites ?

If I understand well, you want to blend sprites and quads, but if you suppress the depth writing [glDepthMask(false)] for the sprites, then when you draw quads, they never find any sprite to blend with, because nothing was written in the depth buffer.
jma

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.