View Full Version : OpenGL ES draw image from buffer Android JNI

03-30-2017, 04:22 PM

I'm new openGL developer. I want to make my own mirroring protocol.
A client sends his desktop screen as a buffer of pixels : Red (One Byte), Green (One Byte), Blue (One Byte).
I get this buffers on Android and I want to display it on my phone screen.
I just started my project with a google sample Hello GL2 : https://github.com/googlesamples/android-ndk/tree/master/hello-gl2

I don't understand very well how does OpenGL works with Java Code.

For my purpose, I just retrieve the pixels buffer from socket as a byte array on a C code like this : recv(sock, buffer, BUFF_SIZE, MSG_WAITALL); BUFF_SIZE = 4096.
I'm getting 1280*720 pixels = 921600 pixels.

How can I take them and display them on a GL2View ?
Which configuration should I do ? Should I keep the configuration shown in sample for my purpose or should I change ?
I saw this function that might help but I don't know how to use it : glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices);

Thank you very much for your help ! :)