@@ -106,11 +106,6 @@ CameraViewWidget::~CameraViewWidget() {
106106 glDeleteVertexArrays (1 , &frame_vao);
107107 glDeleteBuffers (1 , &frame_vbo);
108108 glDeleteBuffers (1 , &frame_ibo);
109- for (auto sync : gl_fences) {
110- if (glIsSync (sync)) {
111- glDeleteSync (sync);
112- }
113- }
114109 }
115110 doneCurrent ();
116111}
@@ -210,13 +205,11 @@ void CameraViewWidget::paintGL() {
210205 int texture_id = latest_texture_id;
211206 if (texture_id == -1 ) return ;
212207
213- // sync with the PBO
214- if (glIsSync (gl_fences[texture_id])) {
215- glWaitSync (gl_fences[texture_id], 0 , GL_TIMEOUT_IGNORED);
216- }
217-
218208 glViewport (0 , 0 , width (), height ());
219209
210+ // sync with the PBO
211+ glWaitSync (gl_fences[texture_id]->sync , 0 , GL_TIMEOUT_IGNORED);
212+
220213 glBindVertexArray (frame_vao);
221214 glActiveTexture (GL_TEXTURE0);
222215 glBindTexture (GL_TEXTURE_2D, texture[texture_id]->frame_tex );
@@ -311,10 +304,7 @@ void CameraViewWidget::vipcThread() {
311304 glBindTexture (GL_TEXTURE_2D, 0 );
312305 assert (glGetError () == GL_NO_ERROR);
313306
314- if (glIsSync (gl_fences[buf->idx ])) {
315- glDeleteSync (gl_fences[buf->idx ]);
316- }
317- gl_fences[buf->idx ] = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0 );
307+ gl_fences[buf->idx ].reset (new WaitFence ());
318308 }
319309 latest_texture_id = buf->idx ;
320310 // Schedule update. update() will be invoked on the gui thread.
0 commit comments