# Writing out to PImage or PGraphics in shader

**URL:** <https://discourse.processing.org/t/writing-out-to-pimage-or-pgraphics-in-shader/31893>\
**Category:** Processing for Android\
**Created:** [August 24, 2021, 5:26pm UTC](https://discourse.processing.org/t/writing-out-to-pimage-or-pgraphics-in-shader/31893 "2021-08-24T17:26:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [August 24, 2021, 5:26pm UTC](https://discourse.processing.org/t/writing-out-to-pimage-or-pgraphics-in-shader/31893/1 "2021-08-24T17:26:27Z")

</div>

I’m not sure this is doable, or at least I know this is doable but perhaps not the way I want.

I understand that there is a `layout variable` we can use to write out to a buffer.

```auto
layout(location = 0) out vec4 out_color;
layout(location = 1) out vec4 out_color1;

```

and that providing it has been instanciated correctly we should be able to write to it. using

```auto
out_color = vec4(1-e*mult, 1.0);

```

however the example I’m dissecting

> [@Compute Shader Particle System in Processing](https://discourse.processing.org/t/compute-shader-particle-system-in-processing/26611):
>
> I managed to implement a very simple particle system using compute shader. This example renders 1 million particles on an Intel Iris 640 integrated graphics card, which is pretty amazing. Since compute shader requires OpenGL 4.x, so I am not sure if the original drawing mode will work anymore. Github repo: [ComputeShader01] [ComputeShaderColor]

needs an instance of `gl4` to be able to run, this in turn require `jogamp.opengl` and `jogamp.common` which are unavailable on android.

```auto
import com.jogamp.opengl.*;
import com.jogamp.common.nio.Buffers;
import java.nio.FloatBuffer;

ParticleSystem ps;
GL4 gl;

void setup() {

  size(720, 600, P3D);
  surface.setLocation(1440/2-20, 0);
  PGL pgl = ((PGraphicsOpenGL)g).pgl;
  gl = ((PJOGL)pgl).gl.getGL4();

  ps = new ParticleSystem(500000);
}

void draw() {
  background(0);
  ps.update();
  ps.render();
  //fill(255);
  //text(frameRate,100,100);
  if(mousePressed)println(frameRate);
}

void dispose() {
  ps.release();
}

```

I do understand that what I may be asking for is really complicated, but I just wanted to knw if this was in fact possible on android as from my understanding only gl2 is available on android and because of that it changes the way that things are instanced and bound in the buffer.

So I guess my question am i asking for the impossible here as this would require a rework of how opengl is handled in android processing or is it technically possible just not that way it is done in windows.
