From 8b1b2885964c2078ca42f84122fd43b53683e6c3 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 21 Jul 2018 00:03:22 +0200 Subject: [PATCH] Add some missing clears. --- flow.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/flow.cpp b/flow.cpp index 3c69089..9264123 100644 --- a/flow.cpp +++ b/flow.cpp @@ -593,22 +593,17 @@ void ComputeSmoothness::exec(GLuint flow_tex, GLuint diff_flow_tex, GLuint smoot glViewport(0, 0, level_width, level_height); - // Make sure the smoothness on the right and upper borders is zero. - // We could have done this by making (W-1)xH and Wx(H-1) textures instead - // (we're sampling smoothness with all-zero border color), but we'd - // have to adjust the sampling coordinates, which is annoying. - // - // FIXME: We shouldn't scissor width for horizontal, - // and we shouldn't scissor height for vertical - glScissor(0, 0, level_width - 1, level_height - 1); - glEnable(GL_SCISSOR_TEST); - glDisable(GL_BLEND); glBindVertexArray(smoothness_vao); glBindFramebuffer(GL_FRAMEBUFFER, smoothness_fbo); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glDisable(GL_SCISSOR_TEST); + // Make sure the smoothness on the right and upper borders is zero. + // We could have done this by making (W-1)xH and Wx(H-1) textures instead + // (we're sampling smoothness with all-zero border color), but we'd + // have to adjust the sampling coordinates, which is annoying. + glClearTexSubImage(smoothness_x_tex, 0, level_width - 1, 0, 0, 1, level_height, 1, GL_RED, GL_FLOAT, nullptr); + glClearTexSubImage(smoothness_y_tex, 0, 0, level_height - 1, 0, level_width, 1, 1, GL_RED, GL_FLOAT, nullptr); } // Set up the equations set (two equations in two unknowns, per pixel). @@ -1026,6 +1021,7 @@ int main(void) GLuint dense_flow_tex; glCreateTextures(GL_TEXTURE_2D, 1, &dense_flow_tex); glTextureStorage2D(dense_flow_tex, 1, GL_RGB16F, level_width, level_height); + glClearTexImage(dense_flow_tex, 0, GL_RGB, GL_FLOAT, nullptr); // And draw. { @@ -1075,6 +1071,7 @@ int main(void) GLuint du_dv_tex; glCreateTextures(GL_TEXTURE_2D, 1, &du_dv_tex); glTextureStorage2D(du_dv_tex, 1, GL_RG16F, level_width, level_height); + glClearTexImage(du_dv_tex, 0, GL_RG, GL_FLOAT, nullptr); // And for smoothness. GLuint smoothness_x_tex, smoothness_y_tex; -- 2.39.2