Skip to main content
gamedev.net
🔒 Locked

Error when using glColorMask

Started by whathappened 1 reply 1k views
Original Post
whathappened
whathappened
Im trying to do some shadow effects in OpenGL and I need to be able to draw only to the depth buffer (ie not to the screen). When I tried to find the error, I noticed that the following code doesnt work, why is that? glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); DrawFloor(); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); DrawFloor(); DrawFloor just draws a quad. But the screen is totally black (if I remove the glColorMask-rows, it'll work). But why isnt the above code working?
Brother Bob
Brother Bob
It most likely work, just not the way you expect it to. First pass draws it to the depth buffer as you probably expect. Second pass, unless you change default depth test function, won't draw anything. Default depth test function is GL_LESS, which will only draw if the incomming depth is less than the depth buffer value. You need to draw if it's less than OR EQUAL TO the depth buffer value.

Set depth buffer function to GL_LEQUAL. GL_LESS won't work. Also, keep in mind that you must set this depth function before drawing the first pass, since OpenGL doesn't guarantee depth invariant rendering if depth test function is changed between passes.
whathappened
whathappened
Thanks :) Sorry for that stupid question, realized it myself after a while. Guess I must blame it on some frustration and the 30 degrees heat :)

Topic Locked

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

Sign in to reply to this topic.