title: Android NDK gl using Java nio bytebuffer for texture image
body: <p>I am using Java side direct nio buffer which is  holding pixel data from a bitmap and use it in the NDK side as a gl texture. Basically I am not able to read the Java nio buffer pixels correctly in the c/c++ gl draw call.</p>
  
  <p>It appears that the Java.ByteBuffer that is filled with pixels on Java side is not directly compatible with NDK side gl which requires unsigned bytes ( java byte is apparently 32 bit)</p>
  
  <p>so a single white pixel on Java side :</p>
  
  <pre><code>int size = 1;
  ByteBuffer vv = ByteBuffer.allocateDirect(size_t*4);
  vv.order(ByteOrder.nativeOrder());
  vv.put((byte)255); // R
  vv.put((byte)255); // G
  vv.put((byte)255); // B
  vv.put((byte)255); // A
  vv.position(0);
  ... //code to send the buffer address to JNI/NDK gl side
  ... //
  </code></pre>
  
  <p>will be drawn on NDK side as a  black pixel;</p>
  
  <p>I realize that the actual unsigned byte value of this buffer maybe be negative - how do I correct for this.
  Also - I will need to convert byte[] that is an image data derived from a Bitmap on Java side to be used in the NDK side texture once I solve this issue.</p>
  
  <p>Thanks in advance!</p>