Smooth being disabled, any way to force smooth()

edited January 2015 in Questions about Code

Hi guys I'm running a sketch with masks and I keep getting this error

"The smooth/noSmooth functions are being called too often. This results in screen flickering, so they will be disabled for the rest of the sketch's execution."

Anybody else faced this issue? Any way to avoid this or to force smooth() to stay enable?

Also any other way to have any kind of anti-aliasing beside smooth()?

Thanks, did some research first but can't find an answer

PS No GPU, doesn't seem to be an issue when running on a GPU system


  • Call smooth() only once, in setup().

  • Hi PhiLho smooth is only being called once in the setup. Also it seems I'm guetting the same error even when I use smooth(0)

    Not sure what's going on here. Are PGraphics, masks using smooth by default and overwriting the smooth setting in setup?


  • Function noSmooth() is a more compatible alternative for smooth(0);:

  • A simple sketch reproducing your problem would be interesting to see. I don't understand why you get a warning about using smooth() too often if you call it only once.

    edited June 2014

    Here are the errors I'm currently getting:

    Smooth level 2 is not available. Using 1 instead
    Smooth level 8 is not available. Using 1 instead
    ambiguous Java methods found, using background(int)
    OpenGL error 1281 at bot beginDraw(): invalid value
    ambiguous Java methods found, using fill(int)
    OpenGL error 1286 at top endDraw(): invalid framebuffer operation
    OpenGL error 1286 at bot endDraw(): invalid framebuffer operation

    A question, I can't seem to find an answer for: Can smooth run without a GPU? On a CPU only system?

    Thanks guys!

  • I see this error as well. For me, the inability to override automatic disabling of smooth() is a serious problem.

    My use case: I have a simulation of polymer chains (kind of like a bowl of spaghetti noodles floating around, only the noodles are single molecules) where the chains are made of complicated objects. I allow the user to select a renderer on the fly to view an ongoing simulation. The user is free to flick back and forth between simple/low-res/high-frame-rate renderers and detailed/high-res/low-frame-rate renderers as they like, kind of like switching between normal and x-ray vision. There are at present three renderers.

    Each renderer has its own smooth() setting. This is desired. Problem is, Processing decides that smooth() is being called too often if the user switches renderers too often for its taste, and disables the smooth function. This destroys control and information. My user should be able to switch as often as they like -- if they want to hold down the "Renderer switch" key because it looks cool, they should be able to do that.

    The present justification for disabling smooth() is to prevent flickering. Flickering is a problem if your renderer is constant, but it's a feature if you're jumping between views.

    The smooth() function should have an override to prevent the present intrusion on valuable and intentional decisions by programmers.

  • edited January 2015

    Class PGraphicsOpenGL overrides both PGraphics smooth() & noSmooth() in order to cap them:

    What we can do is hack that class by subclassing it like I did below:

    Here's my simpler adaption of it. It resets both lastSmoothCall & smoothCallCount to some lower value: :ar!


    import processing.core.PApplet;
    import processing.opengl.PGraphics3D;
    public class HackedP3D extends PGraphics3D {
      public HackedP3D() {
      public HackedP3D(int w, int h) {
        final PApplet p = getEnclosingPApplet();
        initialize(w, h, p, p.dataPath(""));
      public HackedP3D(int w, int h, PApplet p) {
        initialize(w, h, p, p.dataPath(""));
      public HackedP3D(int w, int h, PApplet p, String s) {
        initialize(w, h, p, s);
      public void initialize(int w, int h, PApplet p, String s) {
        setSize(w, h);
      public void ignite() {
      protected PApplet getEnclosingPApplet() {
        try {
          return (PApplet) getClass()
        catch (ReflectiveOperationException cause) {
          throw new RuntimeException(cause);
      @ Override public void smooth() {
        lastSmoothCall = smoothCallCount = -0100;
      @ Override public void noSmooth() {
        lastSmoothCall = smoothCallCount = -0100;
      @ Override public String toString() {
        return "Width: " + width + "\t Height: " + height
          + "\nPath:  " + path;


     * P3D Subclass (v1.03)
     * by GoToLoop (2014/Dec/04)
     * how-to-use-vertexfloat-v-
     * question-about-pgraphics
     * smooth-being-disabled-any-way-to-force-smooth
    MyP3D pg;
    int w, h;
    void setup() {
      size(800, 600, P2D);
      println( pg = new MyP3D(width*3 >> 2, height*3 >> 2) );
      w = pg.width; 
      h = pg.height;
    void draw() {
      final color c = (color) random(#000000);
      frame.setTitle("Frame: " + frameCount
        + "\t\tColor: #" + hex(c, 6));
      image(pg.script(c), width-w >> 1, height-h >> 1);
    final class MyP3D extends HackedP3D {
      MyP3D(int w, int h) {
        super(w, h);
      MyP3D(int w, int h, PApplet p) {
        super(w, h, p);
      MyP3D script(color c) {
        smooth(1 << (int)random(5));
        fill(~c | ALPHA_MASK);
        ellipse(width>>1, height>>1, random(width), random(height));
        vertex(0, 0, -50);
        vertex(100, 0, -50);
        vertex(0, 100, -50);
        return this;
  • Thanks for the reply. I confess I don't understand what's essential, here, and what's decoration/aimed at other issues. If my only objective is to override smooth() (a great suggestion), must I really subclass PGraphics3D twice, and include all this other business?

  • ... must I really subclass PGraphics3D twice...

    No! Class HackedP3D is enough! You can ignore the whole "P3D_Subclass.pde" test. :-B

  • Apologies, I'm still a bit confused. Simply including HackedP3D in my project is not enough (it appears). What else must I do? I'm hazy on how Processing sets up the graphics context for the user, obviously. Thanks for the assistance.

  • It's similar to createGraphics(), just pass width & height dimensions:

    Just like I did when instantiating MyP3D. Just replace it w/ HackedP3D:

    HackedP3D pg;
    pg = new HackedP3D(width*3 >> 2, height*3 >> 2);
Sign In or Register to comment.