title: Getting data back from compute shader
body: <p>I'm fairly new to opengl and I found myself in situation where I need to get data from compute shader but as I miss some critical knowledge I can't get it to work. So I came here, so that maybe you can give me some hints.</p>
  
  <p>Say I have a compute shader like this:</p>
  
  <pre><code>#version 430 core
  struct rmTriangle
  {
    vec4 probeCenter;
    vec4 triangles[3];
  };
  
  layout(std430, binding=9) buffer TriangleBuffer {
    rmTriangle triangles[];
  }trBuffer;
  
  //other uniforms, variables and stuff
  
  void main()
  {
    //here I make some computations and assign values to the
    //trBuffer's triangles array
  }
  </code></pre>
  
  <p>Now I would like to use the trBuffer's data in my application.
  I was told to make a shader storage buffer
  So this is what I did:</p>
  
  <pre><code>private int ssbo;
  gl.glGenBuffers(1, &amp;ssbo);
  gl.glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo);
  //just allocate enough amount of memory
  gl.glBufferData(GL_SHADER_STORAGE_BUFFER, MAX_TRIANGLES * SIZEOF_TRIANGLE, null, GL_DYNAMIC_READ);
  </code></pre>
  
  <p>Then this:</p>
  
  <pre><code>int blockIndex = gl.glGetProgramResourceIndex(program,GL_SHADER_STORAGE_BLOCK, name.getBytes(), 0);
  if (blockIndex != GL_INVALID_INDEX) {
      gl.glShaderStorageBlockBinding(program, blockIndex, index);
  } else {
      System.err.println("Warning: binding " + name + " not found");
  }
  </code></pre>
  
  <p>where name = "TriangleBuffer"
  and index = 9</p>
  
  <p>I know how to access the ssbo I created in my application. What I don't know is how to assign/transfer the TriangeBuffer data into my ssbo.</p>