depth function usage in opengl es 2.0 -


i tried use gldepthfunc in opengl es 2.0 (at pc emulator) , don't understand behavior.

in init function call define these values:

glcleardepthf( 0.5f ); glclearcolor ( 1.0f, 0.0f, 0.0f, 0.0f ); 

and in drawing function code:

glclear ( gl_color_buffer_bit | gl_depth_buffer_bit); glenable( gl_depth_test ); gldepthfunc(gl_lequal); gluniform4fv(unifcolor, 1, vercolor); gldrawarrays ( gl_triangle_fan, 0, 4 ); eglswapbuffers 

i'm drawing green square (half of screen size). when z value of drawn square 0.5.

i expect depth test true , i'll see green square drawn, see red screen (the color used in clear color). when define clear depth value 1.0 receive expected behaviour: grren squar on red screen, think depth used needed (all initialzed defines depth).

what can problem?

thanks

there things go wrong. there might precision issues. however, have guess here:

i'm drawing green square (half of screen size). when z value of drawn square 0.5.

wrriting somehting (x, y, 0.5, 1) gl_position not result in window space z value of 0.5, in 0.75. ndc coords of [-1,1] mapped depth range (by default [0,1]). try drawing @ z=0 window space z value of 0.5 (and prepared additional precision issues). assumes there no further transformation, no perspective, of course.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -