Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Q] How to prevent drawing of duplicate frames? #645

Open
tim-steg opened this issue Mar 14, 2022 · 2 comments
Open

[Q] How to prevent drawing of duplicate frames? #645

tim-steg opened this issue Mar 14, 2022 · 2 comments

Comments

@tim-steg
Copy link

tim-steg commented Mar 14, 2022

Hi,

I am currently developing a video player in Regl that allows the user to zoom and pan whilst playing a live video feed. In an effort to reduce system resource consumption, I would like to make sure a frame is not drawn to the screen if nothing has changed from the last frame (which I have successfully kept track of), but is there a way to keep the old frame around and temporarily not draw anything in the regl.frame() loop?

Would something like this work?:

regl.frame(() => {
  if (dontDraw() === true) {
    return;
  }

  drawVideoShader({
     // shader params go here
  });
});

Thank you!

@rreusser
Copy link
Member

Yes, the above should work just fine! Come to think of it, I don't know exactly what triggers this mechanism, but since WebGL uses double-buffering, if you don't draw anything the image should stay on the screen.

@rreusser
Copy link
Member

Ah, maybe this is roughly what triggers it. I'd just always taken it for granted and hadn't thought about how it works: https://stackoverflow.com/questions/33327585/why-webgl-clear-draw-to-front-buffer

Anytime you do anything that effects the WebGL drawingBuffer (think "backbuffer) it gets marked to swap/copy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants