Arm Community
Site
Search
User
Site
Search
User
Support forums
Mobile, Graphics, and Gaming forum
eglCreatePixmapSurface error 0x300a
Jump...
Cancel
Locked
Locked
Replies
8 replies
Subscribers
136 subscribers
Views
8610 views
Users
0 members are here
OpenGL ES
Mali-GPU
Options
Share
More actions
Cancel
Related
How was your experience today?
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
eglCreatePixmapSurface error 0x300a
jack li
over 11 years ago
Note: This was originally posted on 12th September 2012 at
http://forums.arm.com
When I try the SAMSUNG S3 run the above code, I failed.
void GLImageRenderBlux::initEGL(int width, int height, SkBitmap bitmap)
{
const EGLint attribList[] = { EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE };
EGLConfig config;
EGLint maj;
EGLint min;
m_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
checkEGLError("eglGetDisplay");
if(m_display == EGL_NO_DISPLAY) {
LOGE("getDisplay fail!");
return ;
}
if(eglInitialize(m_display, &maj, &min) == EGL_FALSE) {
LOGE("Initialize fail");
return ;
}
config = chooseConfig(m_display);
EGLint contextAttrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
m_context = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextAttrs);
checkEGLError("eglCreateContext");
if(m_context == EGL_NO_CONTEXT) {
LOGE("Create Context failure");
return ;
}
//
SkPixelRef* ref = bitmap.pixelRef();
SkSafeRef(ref);
ref->lockPixels();
egl_native_pixmap_t pixmap;
pixmap.version = sizeof(pixmap);
pixmap.width = width;
pixmap.height = height;
pixmap.stride = bitmap.rowBytes() / bitmap.bytesPerPixel();
pixmap.format = SkBitmap::kARGB_8888_Config;
pixmap.data = (uint8_t*)ref->pixels();
ref->unlockPixels();
m_surface = eglCreatePixmapSurface(m_display, config, &pixmap, attribList);
checkEGLError("eglCreatePixmapSurface");
if(m_surface == EGL_NO_SURFACE) {
LOGE("Create Surface failure");
return ;
}
if (!eglMakeCurrent(m_display, m_surface, m_surface, m_context)) {
LOGE("Make Current failure");
return ;
}
}
EGLConfig GLImageRenderBlux::chooseConfig(EGLDisplay display)
{
EGLConfig config;
EGLint numConfigs;
static const EGLint configAttribs[] = {
EGL_SURFACE_TYPE,
EGL_PIXMAP_BIT,
EGL_RENDERABLE_TYPE,
EGL_OPENGL_ES2_BIT,
EGL_NONE
};
eglChooseConfig(display, configAttribs, &config, 1, &numConfigs);
checkEGLError("eglPbufferConfig");
if (numConfigs != 1) {
LOGE("eglPbufferConfig failed (%d)\n", numConfigs);
}
return config;
}
Error information is as follows:
'eglCreatePixmapSurface error: EGL_BAD_NATIVE_PIXMAP (0x300a)'
'[color=#FF0000]Create Surface failure'[/color]
Does any know how to fix the problem?
Parents
jack li
over 11 years ago
Note: This was originally posted on 21st September 2012 at
http://forums.arm.com
We're sorry!I tried the following code, but it is still wrong. I think I'm really stupid, but this is a very important task, I must finish it.
new code:
void test2(int width, int height, SkBitmap bitmap)
{
LOGV("Enter test2 (%d x %d)", width, height);
LOGI("*************** 3. During egl initialization, get the addresses for the extensions (function pointers) ***************");
const char* const driver_absolute_path = "/system/lib/egl/libEGL_mali.so";
void* dso = dlopen(driver_absolute_path, RTLD_LAZY);
if (dso != 0)
{
LOGI("dlopen: SUCCEEDED");
_eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)dlsym(dso, "eglCreateImageKHR");
_eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) dlsym(dso, "eglDestroyImageKHR");
}
else
{
MLOGI("dlopen: FAILED! Loading functions in common way!");
_eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress("eglCreateImageKHR");
_eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) eglGetProcAddress("eglDestroyImageKHR");
}
if(_eglCreateImageKHR == NULL)
{
LOGE("Error: Failed to find eglCreateImageKHR at %s:%i\n", __FILE__, __LINE__);
exit(1);
}
if(_eglDestroyImageKHR == NULL)
{
LOGE("Error: Failed to find eglDestroyImageKHR at %s:%i\n", __FILE__, __LINE__);
exit(1);
}
_glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) eglGetProcAddress("glEGLImageTargetTexture2DOES");
if(_glEGLImageTargetTexture2DOES == NULL)
{
LOGE("Error: Failed to find glEGLImageTargetTexture2DOES at %s:%i\n", __FILE__, __LINE__);
exit(1);
}
LOGI("*************** 4. Create the Android Graphic Buffer ***************");
GraphicBuffer* buffer = new GraphicBuffer(width, height,
PIXEL_FORMAT_RGBA_8888,
GraphicBuffer::USAGE_HW_TEXTURE |
GraphicBuffer::USAGE_HW_2D |
GRALLOC_USAGE_SW_READ_OFTEN |
GRALLOC_USAGE_SW_WRITE_OFTEN);
// Init the buffer
status_t err = buffer->initCheck();
if (err != NO_ERROR)
{
LOGE("Error: %s\n", strerror(-err));
return ;
}
// Retrieve andorid native buffer
android_native_buffer_t* anb = buffer->getNativeBuffer();
MLOGI("*************** 5. Create the EGLImage ***************");
const EGLint attrs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE, EGL_NONE };
//EGLImageKHR pEGLImage = _eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, (EGLClientBuffer)anb, attrs);
EGLImageKHR pEGLImage = _eglCreateImageKHR(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, (EGLClientBuffer)anb, attrs);
if (pEGLImage == EGL_NO_IMAGE_KHR) {
EGLint error = eglGetError();
LOGE("Error (%#x): Creating EGLImageKHR at %s:%i\n", error, __FILE__, __LINE__);
}
LOGI("*************** 6. Set up the FBO with the EGLImage as target ***************");
GLuint iFBOTex, iFBO;
glViewport(0, 0, width, height);
checkGlError("glViewport");
/* Initialize FBO texture. */
glGenTextures(1, &iFBOTex);
glBindTexture(GL_TEXTURE_2D, iFBOTex);
/* Set filtering. */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
/* Initialize FBOs. */
glGenFramebuffers(1, &iFBO);
checkGlError("glGenFramebuffers");
/* Render to framebuffer object. */
/* Bind our framebuffer for rendering. */
glBindFramebuffer(GL_FRAMEBUFFER, iFBO);
checkGlError("glBindFramebuffer");
/* Attach texture to the framebuffer. */
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, iFBOTex, NULL);
checkFrameBufferStatus("glFramebufferTexture2D"); //checkGlError("glFramebufferTexture2D");
_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, pEGLImage);
/* Check FBO is OK. */
GLenum iResult = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if(iResult != GL_FRAMEBUFFER_COMPLETE)
{
LOGE("Error : Framebuffer incomplete at %s:%i\n", __FILE__, __LINE__);
}
/* Unbind framebuffer. */
glBindFramebuffer(GL_FRAMEBUFFER, 0);
LOGI("*************** 7. When rendering every frame, bind to the FBO and issue all glCommands, followed by unbind. ***************");
glBindFramebuffer(GL_FRAMEBUFFER, iFBO);
/* Set the viewport according to the FBO's texture. */
glViewport(0, 0, width , height);
/* Clear screen on FBO. */
glClearColor(0.5f, 0.5f, 0.5f, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/*********************************************
*******************************************/
glDrawArrays(GL_TRIANGLES, 0, 3);
checkGlError("glDrawArrays");
/* And unbind the FrameBuffer Object so subsequent drawing calls are to the EGL window surface. */
glBindFramebuffer(GL_FRAMEBUFFER,0);
LOGI("*************** 9. Finally use the following code for reading the buffer out from user space. Something like the following ***************");
// Just in case the buffer was not created yet
if (buffer == NULL){
LOGE("The Buffer is NULL!");
return;
}
void* vaddr;
// Lock the buffer and retrieve a pointer where we are going to write the data
buffer->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, &vaddr);
if (vaddr == NULL)
{
buffer->unlock();
return;
}
unsigned char* ucVaddr = (unsigned char*)vaddr;
bitmap.setPixels(ucVaddr);
LOGV("Exit test2");
}
Output log:
09-21 10:22:40.415: V/ BitmapRender(16378): Enter test2 (3264 x 2176)
09-21 10:22:40.415: I/BitmapRender (16378): *************** 3. During egl initialization, get the addresses for the extensions (function pointers) ***************
09-21 10:22:40.415: I/BitmapRender (16378): onPictureTake call back
09-21 10:22:40.415: I/BitmapRender (16378): dlopen: SUCCEEDED
09-21 10:22:40.415: I/BitmapRender (16378): *************** 4. Create the Android Graphic Buffer ***************
09-21 10:22:40.505: I/BitmapRender (16378): *************** 5. Create the EGLImage ***************
09-21 10:22:40.530: I/BitmapRender (16378): *************** 6. Set up the FBO with the EGLImage as target ***************
09-21 10:22:40.530: E/BitmapRender (16378): after glFramebufferTexture2D FLIPBOOM : failed to make complete FrameBuffer object 0
09-21 10:22:40.530: I/[color=#2E8B57]BitmapRender[/color] (16378): *************** 7. When rendering every frame, bind to the FBO and issue all glCommands, followed by unbind. ***************
09-21 10:22:40.530: I/[color=#2E8B57]BitmapRender[/color] (16378): *************** 9. Finally use the following code for reading the buffer out from user space. Something like the following ***************
09-21 10:22:40.530: V/BitmapRender (16378): Exit test2
Cancel
Vote up
0
Vote down
Cancel
Reply
jack li
over 11 years ago
Note: This was originally posted on 21st September 2012 at
http://forums.arm.com
We're sorry!I tried the following code, but it is still wrong. I think I'm really stupid, but this is a very important task, I must finish it.
new code:
void test2(int width, int height, SkBitmap bitmap)
{
LOGV("Enter test2 (%d x %d)", width, height);
LOGI("*************** 3. During egl initialization, get the addresses for the extensions (function pointers) ***************");
const char* const driver_absolute_path = "/system/lib/egl/libEGL_mali.so";
void* dso = dlopen(driver_absolute_path, RTLD_LAZY);
if (dso != 0)
{
LOGI("dlopen: SUCCEEDED");
_eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)dlsym(dso, "eglCreateImageKHR");
_eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) dlsym(dso, "eglDestroyImageKHR");
}
else
{
MLOGI("dlopen: FAILED! Loading functions in common way!");
_eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress("eglCreateImageKHR");
_eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) eglGetProcAddress("eglDestroyImageKHR");
}
if(_eglCreateImageKHR == NULL)
{
LOGE("Error: Failed to find eglCreateImageKHR at %s:%i\n", __FILE__, __LINE__);
exit(1);
}
if(_eglDestroyImageKHR == NULL)
{
LOGE("Error: Failed to find eglDestroyImageKHR at %s:%i\n", __FILE__, __LINE__);
exit(1);
}
_glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) eglGetProcAddress("glEGLImageTargetTexture2DOES");
if(_glEGLImageTargetTexture2DOES == NULL)
{
LOGE("Error: Failed to find glEGLImageTargetTexture2DOES at %s:%i\n", __FILE__, __LINE__);
exit(1);
}
LOGI("*************** 4. Create the Android Graphic Buffer ***************");
GraphicBuffer* buffer = new GraphicBuffer(width, height,
PIXEL_FORMAT_RGBA_8888,
GraphicBuffer::USAGE_HW_TEXTURE |
GraphicBuffer::USAGE_HW_2D |
GRALLOC_USAGE_SW_READ_OFTEN |
GRALLOC_USAGE_SW_WRITE_OFTEN);
// Init the buffer
status_t err = buffer->initCheck();
if (err != NO_ERROR)
{
LOGE("Error: %s\n", strerror(-err));
return ;
}
// Retrieve andorid native buffer
android_native_buffer_t* anb = buffer->getNativeBuffer();
MLOGI("*************** 5. Create the EGLImage ***************");
const EGLint attrs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE, EGL_NONE };
//EGLImageKHR pEGLImage = _eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, (EGLClientBuffer)anb, attrs);
EGLImageKHR pEGLImage = _eglCreateImageKHR(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, (EGLClientBuffer)anb, attrs);
if (pEGLImage == EGL_NO_IMAGE_KHR) {
EGLint error = eglGetError();
LOGE("Error (%#x): Creating EGLImageKHR at %s:%i\n", error, __FILE__, __LINE__);
}
LOGI("*************** 6. Set up the FBO with the EGLImage as target ***************");
GLuint iFBOTex, iFBO;
glViewport(0, 0, width, height);
checkGlError("glViewport");
/* Initialize FBO texture. */
glGenTextures(1, &iFBOTex);
glBindTexture(GL_TEXTURE_2D, iFBOTex);
/* Set filtering. */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
/* Initialize FBOs. */
glGenFramebuffers(1, &iFBO);
checkGlError("glGenFramebuffers");
/* Render to framebuffer object. */
/* Bind our framebuffer for rendering. */
glBindFramebuffer(GL_FRAMEBUFFER, iFBO);
checkGlError("glBindFramebuffer");
/* Attach texture to the framebuffer. */
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, iFBOTex, NULL);
checkFrameBufferStatus("glFramebufferTexture2D"); //checkGlError("glFramebufferTexture2D");
_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, pEGLImage);
/* Check FBO is OK. */
GLenum iResult = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if(iResult != GL_FRAMEBUFFER_COMPLETE)
{
LOGE("Error : Framebuffer incomplete at %s:%i\n", __FILE__, __LINE__);
}
/* Unbind framebuffer. */
glBindFramebuffer(GL_FRAMEBUFFER, 0);
LOGI("*************** 7. When rendering every frame, bind to the FBO and issue all glCommands, followed by unbind. ***************");
glBindFramebuffer(GL_FRAMEBUFFER, iFBO);
/* Set the viewport according to the FBO's texture. */
glViewport(0, 0, width , height);
/* Clear screen on FBO. */
glClearColor(0.5f, 0.5f, 0.5f, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/*********************************************
*******************************************/
glDrawArrays(GL_TRIANGLES, 0, 3);
checkGlError("glDrawArrays");
/* And unbind the FrameBuffer Object so subsequent drawing calls are to the EGL window surface. */
glBindFramebuffer(GL_FRAMEBUFFER,0);
LOGI("*************** 9. Finally use the following code for reading the buffer out from user space. Something like the following ***************");
// Just in case the buffer was not created yet
if (buffer == NULL){
LOGE("The Buffer is NULL!");
return;
}
void* vaddr;
// Lock the buffer and retrieve a pointer where we are going to write the data
buffer->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, &vaddr);
if (vaddr == NULL)
{
buffer->unlock();
return;
}
unsigned char* ucVaddr = (unsigned char*)vaddr;
bitmap.setPixels(ucVaddr);
LOGV("Exit test2");
}
Output log:
09-21 10:22:40.415: V/ BitmapRender(16378): Enter test2 (3264 x 2176)
09-21 10:22:40.415: I/BitmapRender (16378): *************** 3. During egl initialization, get the addresses for the extensions (function pointers) ***************
09-21 10:22:40.415: I/BitmapRender (16378): onPictureTake call back
09-21 10:22:40.415: I/BitmapRender (16378): dlopen: SUCCEEDED
09-21 10:22:40.415: I/BitmapRender (16378): *************** 4. Create the Android Graphic Buffer ***************
09-21 10:22:40.505: I/BitmapRender (16378): *************** 5. Create the EGLImage ***************
09-21 10:22:40.530: I/BitmapRender (16378): *************** 6. Set up the FBO with the EGLImage as target ***************
09-21 10:22:40.530: E/BitmapRender (16378): after glFramebufferTexture2D FLIPBOOM : failed to make complete FrameBuffer object 0
09-21 10:22:40.530: I/[color=#2E8B57]BitmapRender[/color] (16378): *************** 7. When rendering every frame, bind to the FBO and issue all glCommands, followed by unbind. ***************
09-21 10:22:40.530: I/[color=#2E8B57]BitmapRender[/color] (16378): *************** 9. Finally use the following code for reading the buffer out from user space. Something like the following ***************
09-21 10:22:40.530: V/BitmapRender (16378): Exit test2
Cancel
Vote up
0
Vote down
Cancel
Children
No data