Archived

This topic is now archived and is closed to further replies.

Grizwald

Z-Buffer read error

Recommended Posts

Grizwald    270
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

Share this post


Link to post
Share on other sites
zedzeek    529
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

Share this post


Link to post
Share on other sites
moore52    122
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)

Share this post


Link to post
Share on other sites
Grizwald    270
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

Share this post


Link to post
Share on other sites