Sign in to follow this  
Deathanatos

Visualizing the depth buffer

Recommended Posts

Deathanatos    122
I'm attempting to visualize the depth buffer for debugging purposes. It's mostly working, but the resulting image appears to be zoomed in. Why is it not the same size as the color buffer?
void get_gl_size(int &width, int &height)
{
	int iv[4];
	glGetIntegerv(GL_VIEWPORT, iv);
	width = iv[2];
	height = iv[3];
}

void visualize_depth_buffer()
{
	int width, height;

	get_gl_size(width, height);

	float *data = new float[width * height];

	glReadPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, data);
	glDrawPixels(width, height, GL_LUMINANCE, GL_FLOAT, data);

	delete [] data;
}
Thanks...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this