eglMakeCurrent : error 3009 - EGL_BAD_MATCH

2,793 views
Skip to first unread message

Prahalad

unread,
Jul 1, 2011, 3:22:17 AM7/1/11
to android-ndk
Hello folks

My mobile application on Gingerbread device requires off-screen
rendering on native code.
Inorder to address my offscreen pixmap based requirement:

1. I first created a config attribute with settings as
EGLint surfaceAttribs[] = {
EGL_SURFACE_TYPE, EGL_PIXMAP_BIT,
EGL_BLUE_SIZE, 5,
EGL_GREEN_SIZE, 6,
EGL_RED_SIZE, 5,
EGL_NONE
};
2. Queried for supporting configuration settings using
eglChooseConfig. To confirm on the settings, I gave eglGetConfigAttrib
and verified whether my surface requirement could be met.
3. Created my raw pixel buffer /or color buffer as per the supported
configuration settings. The buffer size = width x height x bytes per
pixel as supported by configuration.
4. Since raw pixel buffer /or Color buffer cannot be passed onto
eglCreatePixmapSurface, I wrapped the raw pixel buffer around
ANativeWindow_Buffer structure for passing it as argument to
eglCreatePixmapSurface.
5. This ANativeWindow_Buffer structure is defined in native_window.h
as
typedef struct ANativeWindow_Buffer {
// The number of pixels that are show horizontally.
int32_t width;

// The number of pixels that are shown vertically.
int32_t height;

// The number of *pixels* that a line in the buffer
takes in
// memory. This may be >= width.
int32_t stride;

// The format of the buffer. One of WINDOW_FORMAT_*
int32_t format;

// The actual bits.
void* bits;

// Do not touch.
uint32_t reserved[6];
} ANativeWindow_Buffer;
6. The device initialization, config selection, context creation,
pixmap creation all go fine without any errors.
7. While executing eglMakeCurrent, the execution fails with error
code : 3009 - EGL_BAD_MATCH

My question is... Is rendering onto Pixmap supported in the EGL port
for Android Gingerbread 2.3 ? If the feature is supported, what could
have resulted in EGL_BAD_MATCH ( EGLDisplay, EGLContext and EGLConfig
are all valid in state ).

Note: I do understand that EGL implementations differ from one OEM to
the other, but as a standard, some agreed features must be available
for operating systems.

Thanks

Prahalad Narayanan

Smiyax

unread,
Jul 1, 2011, 6:29:18 PM7/1/11
to android-ndk
Hi,

Currently, I solved the 'off-screen rendering on Android' problem
using pbuffer.

1) Choose config which has bind texture support.
EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE

2) Create a pbuffer surface with a texture support attribute.
EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA

3) Draw to the pbuffer surface.

4) Use 'eglBindTexImage', when you draw the pbuffer to the main
window(GLSurfaceView).

This method works well on the devices with adredno 200,adreno 205,
SGX450(Galaxy S),Mali400(Galaxy S2).
it also works on multi threads and multi context.
but it not works tegra2...

I suggest that Android SHOULD support Share Context.
because if Android supports Share Context, we'll can use FBO for off-
screen rendering on multi threads and multi context,
and no need to care how the device supports EGL.

Reply all
Reply to author
Forward
0 new messages