Jump to content
  • Advertisement


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


Z-Buffer read error

This topic is 5735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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....
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
float mouseX

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

>>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 );


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


Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!