Skip to main content
gamedev.net
🔒 Locked

Z-Buffer read error

Started by Grizwald Oct 3, 2002 at 9:51 PM 2 replies 500+ views
Original Post
Grizwald
Grizwald
ok...i can''t get anything other than a one from my z-buffer. yes i''m clearing it. Yes i''m checking after i render . z-buffer init code....
  
	glEnable(GL_DEPTH_TEST);
	glClearDepth(1.0f);															
	glDepthFunc(GL_LEQUAL); 
  
read code...MouseX and MouseY are window coordinates...
  
	float MouseZ = 1;
	RECT r;
	GetWindowRect (Driver->hWnd ,&r);
	float MouseY2 = r.bottom - r.top - Driver.TitleSize - MouseY;

	glReadPixels (MouseX,MouseY2,1,1,GL_DEPTH_COMPONENT, GL_FLOAT, &MouseZ); 
  
i can read color values fine, but z-buffer values don''t give me anything but a one. thanks for help
I love me and you love you.
zedzeek
zedzeek
float mouseX

check the spec i think those floats have to be ints.

anyways
>>float MouseY2 = r.bottom - r.top - Driver.TitleSize - MouseY;<<

i can see that easily going wrong

chuck this just before the read to see if that points actually on the screen
printf("%d\n", mouseY );

-------------

glClearDepth(0.445f);
try it now if it saiz 0.445 then its not seeing anything under the mouseX,mouseY position are u sure youve drawn something there


http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html
moore52
moore52
Problem can be in creating gl window.

Make sure you use 32 and TWO buffers.
Dont know why but if you using triple buffering you SOMETIMES cannot use glReadPixels

ah and more:
glClearColor (or something like that)
Grizwald
Grizwald
my z-bits are 32, and i''m using double buffering, yes i am rendering before I test. It works with everything BUT DEPTH_COMPONENT (LUMINANCE, RED, BLUE etc...) but why not depth?!?!?! this is sooo frustrating. Everything i have coded until this has gone soo smoothly
I love me and you love you.

Topic Locked

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

Sign in to reply to this topic.