I was working on a project in which the user can interact with GLSurfaceViewto draw shapes on the screen. All this works fine and dandy, but now I'm trying to do two things: 1) create a thumbnail of their picture and 2) save their picture. It is important to note that the user can draw an image that is larger than the screen.
As my research shows, this is best achieved by using Bitmap(which can be 1) passed in Canvasfor thumbnails, and 2) stored in a file system that reaches both of my goals).
At first I tried to read Rendererfrom GLSurfaceViewthrough glReadPixels, but it turned out that I could not get the data off the screen. Instead, I decided to make an off-screen buffer to create a rendering of the image that could be converted to Bitmap.
I found a great post that contains code for a class with the name PixelBufferthat I am currently using. (I made a few settings, but all the problems I encountered happen with or without the specified setting).
Now that the getBitmap()code is used (which I will post below in case the forum thread is PixelBuffernot readable), I get a bunch called unimplemented OpenGL ES API. At first it seemed strange to me, so I did some investigation. It turns out, for some reason, the class PixelBufferuses OpenGL ES 2.0, and GLSurfaceView uses OpenGL ES 1.1. The device I'm using (Galaxy Nexus) does not support 2.0. (And what's more, I would like to support the largest set of devices.)
So here is my question . How can I get my class to PixelBufferuse the OpenGL ES 1.1 API? I have already added the following in the manifest:
<uses-feature android:glEsVersion="0x00010001" />
In addition, I tried to install the version using int[] version = new int[] { 1, 1 };, but to no avail.
PixelBuffer, : . , Renderer, 91. 39- .
, PixelBuffer, GLSurfaceView:
setEGLConfigChooser(8, 8, 8, 8, 0, 0);
mRenderer = new MyRenderer(this);
setRenderer(mRenderer);
mPixelBuffer = new CPPixelBuffer(1440, 1280); // TODO Temporary hardcode for Galaxy Nexus wallpaper size
mPixelBuffer.setRenderer(mRenderer);
1.1 , GL Bitmap 1.1 ?
EDIT: , :
int[] version = new int[] {
1, 1
};
int[] attribList = new int[] {
EGL_WIDTH, mWidth,
EGL_HEIGHT, mHeight,
EGL_VERSION, 1,
EGL_NONE
};
06-11 15:41:52.316: E/libEGL(5618): eglMakeCurrent:674 error 3009 (EGL_BAD_MATCH)
06-11 15:41:52.316: E/libEGL(5618): call to OpenGL ES API with no current context (logged once per thread)
. PasteBin'd, , .