# createGraphics (width, height, renderer)

**URL:** https://discourse.processing.org/t/creategraphics-width-height-renderer/29048
**Category:** Processing for Android
**Created:** [April 1, 2021, 1:31pm UTC](https://discourse.processing.org/t/creategraphics-width-height-renderer/29048 "2021-04-01T13:31:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![JoseMY](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josemy/32/2016_2.png) [@JoseMY](https://discourse.processing.org/u/JoseMY)
#### Post date: [April 1, 2021, 1:31pm UTC](https://discourse.processing.org/t/creategraphics-width-height-renderer/29048/1 "2021-04-01T13:31:02Z")

</div>

I’m compiling in my android phone with APDE.  
APDE 0.5.1  
Android 9 (Pie).

It seems you should explicitly set a renderer in size() if you are going to set a renderer in createGraphics.

It should be documented, since using createGraphics with a renderer is useful when your sketch mixes 2D and 3D graphics (chart with a title, game with score panel and so on).

This code works:

```auto
PGraphics l;
void setup(){
  float s=10.0;
  size(600,600);
  l=createGraphics(100,100);
  l.beginDraw();
  l.rect(s,s,s,s);
  l.endDraw();
  
}
void draw(){
  image(l,0,0);
}
```

This code does **not** work:

```auto
PGraphics l;
void setup(){
  float s=10.0;
  size(600,600);
/*this line changed: */
  l=createGraphics(100,100,P2D);
  l.beginDraw();
  l.rect(s,s,s,s);
  l.endDraw();
  
}
void draw(){
  image(l,0,0);
}

```

This code works:

```auto
PGraphics l;
void setup(){
  float s=10.0;
/* this line changed:*/
  size(600,600,P2D);
/*this line changed: */
  l=createGraphics(100,100,P2D); /* or P3D*/
  l.beginDraw();
  l.rect(s,s,s,s);
  l.endDraw();
  
}
void draw(){
  image(l,0,0);
}
```

---

<div class="post-metadata">

### Author: ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)
#### Post date: [April 1, 2021, 2:20pm UTC](https://discourse.processing.org/t/creategraphics-width-height-renderer/29048/2 "2021-04-01T14:20:09Z")

</div>

> [@JoseMY](#):
>
> It should be documented

It is [createGraphics() / Reference / Processing.org](https://processing.org/reference/createGraphics_.html)

---

<div class="post-metadata">

### Author: ![JoseMY](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josemy/32/2016_2.png) [@JoseMY](https://discourse.processing.org/u/JoseMY)
#### Post date: [April 1, 2021, 3:11pm UTC](https://discourse.processing.org/t/creategraphics-width-height-renderer/29048/3 "2021-04-01T15:11:06Z")

</div>

You’re right. Sorry!
