PGraphics in Eclipse not displaying shapes

I’m working on a project that’s using a PGraphics buffer to display to the screen.

Whenever I attempt to draw a shape, PGraphics.ellipse(5, 5, 25 ,25);, or some other shape call, it won’t display at all.
I’ve tried to see if it’s just incorrectly being displayed in one of the XYZ dimensions, but it appears as if that is not the case.

PGraphics.background() works just fine, but none of the shape calls.

Code: Slightly simplified

public void settings(){
    size(1200, 800, PApplet.P3D);

PGraphics base;

public void setup(){
   base = createGraphics(width, height, PApplet.P3D);

public void draw(){
    background(255, 255, 255);

    //Start drawing to the PGraphics object.
    //Background works fine, so I'm not sure what the issue is.
    base.background(200, 200, 200);
    //Draw calls made here:

    //Translate to the user's mouse.
    base.translate(mouseX, mouseY, 0);

    //Draw a circle.
    base.ellipse(0, 0, 25, 25);

    //Pop back to normal and end the draw cycle.

    //Finally display to the screen.
    image(base, 0, 0);

I’m using eclipse as the IDE instead of processing’s IDE. The class extends out PApplet, with a couple other custom methods for random things.

I’m not sure if this is a normal bug or something I’m just doing wrong (as I typically only use the generic CPU renderer instead).

I do get the performance boost from using the OpenGL renderers but I’m not sure why nothing is being drawn.

1 Like

Working for me on PDE v3.5.4. :construction_worker_man:

1 Like

It works in PDE for me, but not in the Eclipse IDE where my program is being run.
I’m not sure why or if I’m just doing something wrong inside of it.

I’ll get back to you if I figure it out.

Okay so I found something interesting. Calling PGraphic.endDraw(); in a seperate method (even if it’s run DIRECTLY after a method that begins the draw call) causes it to not work properly.

They have to be called in the same method it appears?

I’m unsure as to what causes this since it works fine in the default renderer (non P2D/P3D). I’ll keep messing around to see what causes it.

The solution is that if any PGraphics.endDraw() calls are made during some other PGraphics object’s .beginDraw() call is happening, it will cause everything to explode.

Call beginDraw() for one PGraphics object, then endDraw() for the same object before starting another call.

1 Like