# PGraphics in Eclipse not displaying shapes

**URL:** <https://discourse.processing.org/t/pgraphics-in-eclipse-not-displaying-shapes/41894>\
**Category:** Coding Questions\
**Created:** [May 3, 2023, 3:57am UTC](https://discourse.processing.org/t/pgraphics-in-eclipse-not-displaying-shapes/41894 "2023-05-03T03:57:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mattyjak](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mattyjak/32/16777_2.png) [@Mattyjak](https://discourse.processing.org/u/Mattyjak)\
**Post date:** [May 3, 2023, 3:57am UTC](https://discourse.processing.org/t/pgraphics-in-eclipse-not-displaying-shapes/41894/1 "2023-05-03T03:57:53Z")

</div>

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_

```auto
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.
    base.beginDraw();
    //Background works fine, so I'm not sure what the issue is.
    base.background(200, 200, 200);
    //Draw calls made here:

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

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

    //Pop back to normal and end the draw cycle.
    base.popMatrix();
    base.endDraw();

    //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.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [May 3, 2023, 9:20am UTC](https://discourse.processing.org/t/pgraphics-in-eclipse-not-displaying-shapes/41894/2 "2023-05-03T09:20:24Z")

</div>

Working for me on PDE v3.5.4. 👷‍♂️

---

<div class="post-metadata">

**Author:** ![Mattyjak](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mattyjak/32/16777_2.png) [@Mattyjak](https://discourse.processing.org/u/Mattyjak)\
**Post date:** [May 3, 2023, 2:08pm UTC](https://discourse.processing.org/t/pgraphics-in-eclipse-not-displaying-shapes/41894/3 "2023-05-03T14:08:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mattyjak](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mattyjak/32/16777_2.png) [@Mattyjak](https://discourse.processing.org/u/Mattyjak)\
**Post date:** [May 3, 2023, 2:26pm UTC](https://discourse.processing.org/t/pgraphics-in-eclipse-not-displaying-shapes/41894/4 "2023-05-03T14:26:30Z")

</div>

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?

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/1/417be6ba50cba3bf69b894610faf83ee8a01e7c3.png)

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.

---

<div class="post-metadata">

**Author:** ![Mattyjak](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mattyjak/32/16777_2.png) [@Mattyjak](https://discourse.processing.org/u/Mattyjak)\
**Post date:** [August 15, 2023, 5:00am UTC](https://discourse.processing.org/t/pgraphics-in-eclipse-not-displaying-shapes/41894/5 "2023-08-15T05:00:37Z")

</div>

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.

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