# FrameBuffer - draw directly to PImage or Texture

**URL:** <https://discourse.processing.org/t/framebuffer-draw-directly-to-pimage-or-texture/21864>\
**Category:** Coding Questions\
**Created:** [June 14, 2020, 1:13pm UTC](https://discourse.processing.org/t/framebuffer-draw-directly-to-pimage-or-texture/21864 "2020-06-14T13:13:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgood7123](https://avatars.discourse-cdn.com/v4/letter/m/54ee81/32.png) [@mgood7123](https://discourse.processing.org/u/mgood7123)\
**Post date:** [June 14, 2020, 1:13pm UTC](https://discourse.processing.org/t/framebuffer-draw-directly-to-pimage-or-texture/21864/1 "2020-06-14T13:13:25Z")

</div>

how would i set up a `FrameBuffer` such that, i can draw directly to some `Texture` or `PImage` and then immediatly image that to my screen

for example

```auto
PGraphics g2;

void settings() {
  size(400, 400, P3D);
}

void setup() {
  background(0);
  g2 = createGraphics(500,500, P3D);
  noLoop();
}

void exit() {
// g2.endDraw();
  super.exit();
}

void draw() {
  // setup g2 to draw to texture or PImage
  g2.beginDraw();
  g2.clip(0,0,50,50);
  g2.background(0, 128, 128);
  image(PImage_Or_Texture, 0, 0);
  g2.clip(0,0,25,25);
  g2.background(0);
  image(PImage_Or_Texture, 0, 0);
  g2.clip(35,35,65,65);
  g2.background(0, 228, 128);
  image(PImage_Or_Texture, 0, 0);
  g2.endDraw();
}

```
