Code example for GL10

Methods: glReadPixels

0
 
    private static Bitmap getRawPixels(GL10 gl, int width, int height) {
        int size = width * height;
        ByteBuffer buf = ByteBuffer.allocateDirect(size * 4);
        buf.order(ByteOrder.nativeOrder());
        gl.glReadPixels(0, 0, width, height, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, buf);
        int data[] = new int[size];
        buf.asIntBuffer().get(data);
        buf = null;
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
        bitmap.setPixels(data, size - width, -width, 0, 0, width, height);
        return bitmap;
    } 
 
    @NotNull 
    private final Handler uiHandler = new Handler() {
        public void handleMessage(Message msg) { 
            switch (msg.what) { 
                case 1: 
                    glDraw(); 
                    break;