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

Camera functions after a push() when drawing to a framebuffer flip the canvas #6470

Closed
1 of 17 tasks
davepagurek opened this issue Oct 13, 2023 · 0 comments · Fixed by #6471
Closed
1 of 17 tasks

Camera functions after a push() when drawing to a framebuffer flip the canvas #6470

davepagurek opened this issue Oct 13, 2023 · 0 comments · Fixed by #6471

Comments

@davepagurek
Copy link
Contributor

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build Process
  • Unit Testing
  • Internalization
  • Friendly Errors
  • Other (specify if possible)

p5.js version

1.7.0

Web browser and version

Firefox 117

Operating System

macOS 14.0

Steps to reproduce this

Steps:

  1. Create a framebuffer
  2. Draw something to the famebuffer inside begin/end, and with a camera function like ortho, then draw that to the screen. e.g.:
    let fbo
    function setup() {
      createCanvas(400, 400, WEBGL)
      fbo = createFramebuffer()
    }
    
    function draw() {
      fbo.begin()
      background(100)
      ortho(-width/2, width/2, -height/2, height/2, 0.1, 2000)
      translate(0, -100)
      box()
      fbo.end()
      
      imageMode(CENTER)
      image(fbo, 0, 0)
    }
    So far, this should look correct:
    image
  3. Then, add a push/pop around the camera call:
      function draw() {
        fbo.begin()
        background(100)
    +   push()
        ortho(-width/2, width/2, -height/2, height/2, 0.1, 2000)
        translate(0, -100)
        box()
    +   pop()
        fbo.end()
        
        imageMode(CENTER)
        image(fbo, 0, 0)
      }
    Now, the camera is flipped:
    image

Live: https://editor.p5js.org/davepagurek/sketches/GMWJ1-n9n

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

Successfully merging a pull request may close this issue.

1 participant