Sorry to be dense, but I simply don’t understand the mechanics of doing this.
It was said:
If you have to do this a lot, it’s better to initialize a depth component texture (you can initialize it with NULL as texturedata to obtain an empty depth texture) and use glCopyTexSubImage2D instead of glCopyTexImage2D.
How on earth do I initialize a depth component texture?
glTexImage2D does not seem to provide a place to do this. If I copy the RGB buffer, I create a texture that looks like:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
I wanted to do GL_DEPTH_COMPONENT somewhere here, like one of the GL_RGBA’s, but the Red Book says you can’t do that. Experimenting shows that it doesn’t work as well.
When ussing glCopyTexSubImage2D, I did
I know I did the whole thing, but I am trying for simple success first.
I am also confused as to what to put for the format and size of the depth buffer. GL_FLOAT should be the type, right?
The end goal is to display the depth buffer, to the screen, so I can see it. Efficiency is not terribly important, but it should be at least somewhat interactive.
Can anyone clarify the mechanics of this for me?
I keep getting non-zero data, but it doesn’t play right.
For playing, I was simply binding the texture, assigning the texture coords to a white polygon that covered the screen, and drawing it.
This works fine for RGB. Is there something else I have to do if the original texture represents the depth buffer? I need to be able to see it. Greyscale is fine. I am worried that if the texture is known as a depth texture, that it will be invisible in RGB space.