title: How to create offscreen Texture and use it on Android with OpenGL ES 2
body: <p>I am very new in OpenGL.</p>
  
  <p>How can I create an offscreen texture, so that I can get some Informations of it (e.g. PixelColor by clicking on view texture) ?</p>
  
  <p>I tried many many things for example FBO, but it did't work. I have no imagination how to load the Bitmap to a offscreen texture and get information of it. I am very frustated :/</p>
  
  <p><img src="https://i.stack.imgur.com/T6ucD.png" alt="Task"></p>
  
  <p><strong>Edit:</strong>
  Took <a href="http://opengles2learning.blogspot.de/2014/02/render-to-texture-rtt.html" rel="nofollow noreferrer">this</a> Tutorial as Example, don't know if it fits to my problem. <code>createFramebuffer</code></p>
  
  <pre><code>public void createFramebuffer(GL10 gl) {
  
      FloatBuffer uvBuffer2;
      int texture[] = new int[1];
      GLES20.glGenTextures(1, texture, 0);
      GLES20.glBindTexture(GLES20.GL_TEXTURE0, texture[0]);
  
      float uvs2[] = {
                 0.0f, 0.0f,
                 0.0f, 1.0f,
                 1.0f, 1.0f,
                 1.0f, 0.0f
         };
  
      ByteBuffer bb = ByteBuffer.allocateDirect(uvs2.length * 4);
      bb.order(ByteOrder.nativeOrder());
      uvBuffer2 = bb.asFloatBuffer();
      uvBuffer2.put(uvs2);
      uvBuffer2.position(0);
  
      gl.glTexCoordPointer(2, GLES20.GL_BYTE, 0, uvBuffer2);
  
      //load image
      int idTest = mContext.getResources().getIdentifier("drawable/testgroesse", null, mContext.getPackageName());
      Bitmap wood = BitmapFactory.decodeResource(mContext.getResources(), idTest);
  
      GLES20.glTexParameterf(GLES20.GL_TEXTURE0, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
      GLES20.glTexParameterf(GLES20.GL_TEXTURE0, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
  
      GLUtils.texImage2D(GLES20.GL_TEXTURE0, 0, wood, 0); 
  
      GLES20.glEnable(GLES20.GL_TEXTURE0);
      gl.glEnableClientState(GLES20.GL_TEXTURE0);
  
      //color picking background start
      ByteBuffer bytePickedColor = ByteBuffer.allocate(4);
      bytePickedColor.order(ByteOrder.nativeOrder());
      GLES20.glFlush();
  
      GLES20.glReadPixels(touchXint, touchYint, 1, 1, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, bytePickedColor);
  
      byte b[] = new byte[4];
      bytePickedColor.get(b);
      String key = "" + b[0] + " " + b[1] + " " + b[2] + " " + b[3];
      Log.d("Color_Farbe: ", key);
      bytePickedColor.rewind();
      //color picking background end
  }
  </code></pre>