How does processing set its renderer?

I can't figure it out: https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L1465

Basically this is all happening:

  public void size(int w, int h) {
    size(w, h, sketchRenderer(), null);
  }

  public void size(int w, int h, String renderer) {
    size(w, h, renderer, null);
  }


  public void size(final int w, final int h, String renderer, String path) {
    if (!renderer.equals(sketchRenderer())) {
      throw new RuntimeException("The sketchRenderer() method is not implemented.");
    }
    surface.setSize(w, h);
    g.setPath(path);
}

  public String sketchRenderer() {
    return JAVA2D;
  }

To make it even more strange:

  println(P3D); // processing.opengl.PGraphics3D
  println(P2D); // processing.opengl.PGraphics2D
  println(sketchRenderer()); // processing.core.PGraphicsJava2D

sketchRenderer() always returns JAVA2D, so someone please tell how processing can set it to P2D or P3D?

Answers

  • edited December 2014

    Processing devs are being naughty and are messing up w/ the PApplet for v3.x.x! :)]
    Actually, PApplet isn't an Applet anymore, thus it's a misnomer now! :O)

    I believe they've modified Processing's pre-processor to override sketchRenderer() automatically.
    But of course, if it fails to find out where size() is located within the sketch
    or it's not Processing's IDE, it's gonna fail if we don't override it ourselves! :-L

    IMO, they're focused on useless modifications which will only bring pain & bugs! X(

  • edited December 2014

    It seems to be commented out in the current source code. This is probably because in preparation for Processing 3 there are some major, major changes going on right now, for example PSurface. Also see the main repo warning:

    If you need a stable version, use the source or tag for version 2.2.1 or 3.0a5.

    Development of Processing 3 has started, so major changes are underway inside this repository. Many things are broken at the moment while we sort it all out. Do not expect this code to be stable.

    "Major changes" means possible breakage to libraries/tools/modes (as we make API changes) and the removal of Applet as the base class for PApplet. Some of these will be sorted out before the release, others are changes that will break some code between 2.x and 3.x. Obviously, we will work hard to break as few things as possible.

    Might be a good idea to use the tag or wait until the dust settles.

  • Might be a good idea to use the tag or wait until the dust settles.

    I'm pretty sure dust won't settle down until Processing 4! =))

  • Yeah GoToLoop, you're right I looked it up. It happens in the pre processor.

    void setup() {
     size(400, 400, theRendererIWant());
    
    }
    
    void draw() {
     box(10); 
    }
    
    
    String theRendererIWant() {
      return P3D;  
    }
    

    The above won't work.

    What are the positive things of PApplet not being an Applet anymore?

  • "What are the positive things of PApplet not being an Applet anymore?"
    It was an applet for allowing to show sketches in browsers.
    But this approach has been dropped, because most browsers disable applets by default, now. So such dependency is no longer necessary.

    Beside, this allows probably a finer control over the lifecycle of a sketch (it was more or less controlled by Applet so far), and it might allow, perhaps, to run Processing as a graphical library on a headless server.

  • edited December 2014

    What are the positive things of PApplet not being an Applet anymore?

    So such dependency is no longer necessary.

    Though not necessary, yet it's a complete waste of effort to drop it. Is it gonna be any faster by chance? :O)
    And like I've mentioned, it's gonna break everything and bring pain for both of us answerers & users! ~X(

    Doesn't Processing got more important things to fix like full Java 8/9 compatibility rather than creating more bugs?
    I really wish Processing 1.5.1 would be resurrected & forked, so we may still find shelter from all this chaos! [-O<

  • Sometimes things have to get worst before they get better. Let's hope this is the same for processing.

    And I can't run 1.5.1 anymore :(

    Even worse I can't run 1.2.1 which was the latest version that supported point type text in pdf export.

    And benfry doesn't believe me... https://github.com/processing/processing/issues/2544

  • Is it possible to talk with the people who are working on Processing 3 ? Is there a forum or something like that ?

  • Yeah and often close issues before you bite back :)

  • edited December 2014

    Close & lock so we can't reply/bite back ever: 8-X
    https://github.com/processing/processing/pull/2903

  • You can reply on a closed one, it opens the issue again. It also triggers a script to send a hitman to where your pc is located. :-h

  • edited December 2014

    I guess you haven't noticed that was LOCKED, not merely closed! b-(

  • O yeah :)

    About forking 1.5.1, you could name it progressing =))

  • "it's gonna break everything"
    I don't see how dropping Applet will break anything. What I have missed?

  • edited December 2014

    If such simple thing as having chained PVector was enough to break some libraries which relied on reflection, I wonder how losing PApplet inheritance gonna pan out! At least I know frame.setTitle()'s gonna break for sure! :-w

  • I don't really mind breaking some libraries. I kinda dislike they reverted the chaining. All the libraries had to do was a recompile, nothing more.

  • I also hated "they" (benfry) reverted the chaining PVector's decision.
    I was just pointing out how easy it is to break something even w/ something as simple as that 1.
    I foresee removing Applet's gonna be many times more catastrophic! :-SS

Sign In or Register to comment.