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

Fix bugs in saveGif for WebGL2 contexts #6201

Merged
merged 1 commit into from
Jun 13, 2023

Conversation

davepagurek
Copy link
Contributor

Resolves #6200

Changes

  • Uses a more futureproof method of detecting a WebGL sketch that will work regardless of the WebGL version
  • Moves p out of an if statement to avoid errors accessing the variable

Screenshots of the change

I ran into this when trying to export a gif that uses framebuffers from the main branch. Here's the gif I exported after making these changes 🙂

feedback

let prev, next;
function setup() {
  createCanvas(200, 200, WEBGL)
  prev = createFramebuffer({ format: FLOAT });
  next = createFramebuffer({ format: FLOAT });
}

function draw() {
  // Swap prev and next
  [prev, next] = [next, prev];
  
  imageMode(CENTER);
  
  next.begin();
  clear();
  push()
  tint(255, 250)
  rotate(0.01)
  scale(0.99)
  image(prev, 0, 0)
  pop()
  translate(sin(frameCount*0.1)*50, sin(frameCount*0.11)*50)
  noStroke()
  normalMaterial()
  sphere(25)
  next.end();
  
  background(255);
  image(next, 0, 0);
}

function keyPressed() {
  saveGif('feedback.gif', 5)
}

PR Checklist

@Qianqianye Qianqianye merged commit 2474be4 into processing:main Jun 13, 2023
@davepagurek davepagurek deleted the fix/savegif-webgl2 branch June 13, 2023 11:48
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

Successfully merging this pull request may close these issues.

saveGif() throws errors on main branch
2 participants