Awesome that you worked that out - but man... that sure isn't
lightweight!  I bet you could get substantial performance gains doing
that conversion natively and passing the processed array up to java.

On May 2, 4:34 pm, Streets Of Boston <[email protected]> wrote:
> Below is a snippet of code that turns a buffer from GL into a buffer
> that can be used by a Bitmap.
> I'm not sure if you can get a buffer from GL without been having
> showing it before or if this is what you're exactly looking for.
> But here goes anyway :-)
>
> ====================
>
> public void savePixels(int x, int y, int w, int h, GL10 gl) {
>         if (gl == null)
>                 return;
>
>         // synchronized (this) {
>         // if (mSavedBM != null) {
>         // mSavedBM.recycle();
>         // mSavedBM = null;
>         // }
>         // }
>
>         int b[] = new int[w * (y + h)];
>         int bt[] = new int[w * h];
>         IntBuffer ib = IntBuffer.wrap(b);
>         ib.position(0);
>         gl.glReadPixels(x, 0, w, y + h, GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,
> ib);
>
>         for (int i = 0, k = 0; i < h; i++, k++) {// remember, that OpenGL
> bitmap
>                                         // is incompatible with
>                                         // Android bitmap
>                                            // and so, some correction need.
>                 for (int j = 0; j < w; j++) {
>                         int pix = b[i * w + j];
>                         int pb = (pix >> 16) & 0xff;
>                         int pr = (pix << 16) & 0x00ff0000;
>                         int pix1 = (pix & 0xff00ff00) | pr | pb;
>                         bt[(h - k - 1) * w + j] = pix1;
>                 }
>         }
>
>         Bitmap sb = Bitmap.createBitmap(bt, w, h, Bitmap.Config.ARGB_8888);
>         synchronized (this) {
>                 mSavedBM = sb;
>         }}
>
> ====================
>
> On May 2, 2:45 pm, SChaser <[email protected]> wrote:
>
>
>
>
>
> > I would like to be able to use OpenGL in the Android to render into a
> > bitmap (or any other sort of buffer I can turn into one), without
> > actually displaying a GLSurfaceView.
>
> > The purpose is to dynamically create very complex images using OpenGL,
> > and then drawing those images on the canvas of a MapView.
>
> > I have tried overlaying a translucent GLSurfaceView over a MapView, my
> > preferred approach, but it has some problems:
>
> > 1) I have complex menus I need to display from either the MapView or
> > the GLSurfaceView. I have been doing this using a ListView with its
> > own activity. Unfortunately, that activity pushes the MapView down the
> > stack. The result is a bit of flickering when the ListView activity
> > finishes, popping the MapView back to the top. Even worse, if I use
> > the ListView to overlay the GLSurfaceView (giving it the same complex
> > menu capabilities), when it finishes, the GLSurfaceView reappears but
> > the MapView doesn't display.
>
> > 2)As soon as the GLSurfaceView is created, the MapView stops fetching
> > and rendering tiles. There seems to be no way to know when the MapView
> > is complete, so I have to delay an arbitrary interval before creating
> > the surfaceview.
>
> > 3) When the GLSurfaceView is present, the MapView's built-in user
> > interface functions are obscured.
>
> > Anyone know if there is a way around any of these problems?
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group 
> > athttp://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group 
> athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to