|
|
@@ -11,7 +11,7 @@
|
|
|
struct frame_buffer_helper {
|
|
|
|
|
|
int tex_width = 2 * image_width, tex_height = image_height;
|
|
|
- GLuint tex = 0, fbo = 0, pbo = 0;
|
|
|
+ GLuint tex = 0, depth_tex = 0, fbo = 0, pbo = 0;
|
|
|
cudaGraphicsResource *pbo_res = nullptr;
|
|
|
|
|
|
~frame_buffer_helper() {
|
|
|
@@ -19,7 +19,7 @@ struct frame_buffer_helper {
|
|
|
cudaGraphicsUnregisterResource(pbo_res);
|
|
|
glDeleteBuffers(1, &pbo);
|
|
|
glDeleteFramebuffers(1, &fbo);
|
|
|
- glDeleteTextures(1, &tex);
|
|
|
+ glDeleteTextures(2, &tex);
|
|
|
}
|
|
|
|
|
|
bool initialize(int width, int height) {
|
|
|
@@ -27,17 +27,22 @@ struct frame_buffer_helper {
|
|
|
tex_height = height;
|
|
|
|
|
|
// create and allocate tex
|
|
|
- glGenTextures(1, &tex);
|
|
|
+ glGenTextures(2, &tex);
|
|
|
glBindTexture(GL_TEXTURE_2D, tex);
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
|
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGB8, tex_width, tex_height);
|
|
|
|
|
|
+ glBindTexture(GL_TEXTURE_2D, depth_tex);
|
|
|
+ glTexStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH_COMPONENT16, tex_width, tex_height);
|
|
|
+
|
|
|
// create and config fbo
|
|
|
glGenFramebuffers(1, &fbo);
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
|
|
glBindTexture(GL_TEXTURE_2D, tex);
|
|
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
|
|
|
+ glBindTexture(GL_TEXTURE_2D, depth_tex);
|
|
|
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth_tex, 0);
|
|
|
CALL_CHECK(check_frame_buffer());
|
|
|
|
|
|
// create and config pbo
|