FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[OpenGL] Serious bug in clear() · Issue #4131 · processing/processing · GitHub

Repository navigation

[OpenGL] Serious bug in clear() #4131

Closed

Description

Using clear on a PGraphics makes the main canvas black:

PGraphics result;

public void settings() {
  size(512, 512, P2D);
}

public void setup() {

  result = createGraphics(512, 512, P2D);
  result.beginDraw();
  result.endDraw();
}

public void draw() {

  // a white background...
  background(255);
  // just became black...
  result.clear();
}

Processing 3.0.1
(fuck) Mac OS X 10.11

Activity

  1. codeanticode commented on Nov 11, 2015

    Contributor

    You need to enclose any drawing call on a PGraphics surface between begin/endDraw(), i.e.:

    public void draw() {
      background(255);
      result.beginDraw();
      result.clear();
      result.endDraw();
    }
  2. clankill3r commented on Nov 11, 2015

    Author

    In that case, is it wrong to use clear like this:
    https://processing.org/reference/clear_.html
    ?

  3. codeanticode commented on Nov 11, 2015

    Contributor

    ok, I think you are right @REAS @alignedleft what do you think? pg.clear() without begin/endDraw() works with JAVA2D, but does not with P2D/P3D, shouldn't the reference be updated so the example works irrespective of the renderer?

  4. scotthmurray commented on Nov 11, 2015

    Member

    @codeanticode Good catch. My first choice would be to make the behavior consistent across renderers, so we don't have to complicate the documentation. Assuming that's not possible, we could either:

    • address this difference between renderers explicitly in the description, and provide two separate examples, or
    • just modify the current example to use pg.clear() only within begin/endDraw()

    Do you have a preference?

  5. REAS commented on Nov 13, 2015

    Member

    I like your second option, @alignedleft in addition to starting that in the Reference. I'll open an issue, can I assign it to you?

  6. scotthmurray commented on Nov 13, 2015

    Member

    Yes, please! Thanks.

  7. benfry commented on Nov 13, 2015

    Contributor

    clear() should definitely only be used between beginDraw() and endDraw(). I'm surprised it would work with Java2D, but it's likely that it won't in all (most?) cases.

  8. github-actions commented on Jun 16, 2021

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  9. locked as resolved and limited conversation to collaborators on Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL