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

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
  • Note: This was originally posted on 17th September 2012 at http://forums.arm.com

    Hi Karthik,thanks a lot for answering me.
    I have read that page, and try, but I failed.

    Here are some of my code:



    void initEGL(int width, int height, SkBitmap bitmap)
    {
    //step 1.
    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 {
      LOGI("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);
    }

    //step 2. Create the Android Graphic Buffer
       GraphicBuffer* buffer = new GraphicBuffer(width, height, HAL_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){
    [indent]LOGE("Error: %s\n", strerror(-err));
    return ;
    [/indent]
    }

    // Retrieve andorid native buffer
    android_native_buffer_t* anb = buffer->getNativeBuffer();

    //step 3. Create the EGLImage
    const EGLint attrs[] = {
    [indent]EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
    EGL_NONE, EGL_NONE
    [/indent]
    };

    EGLImageKHR pEGLImage = _eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, (EGLClientBuffer)anb, attrs);

    if (pEGLImage == EGL_NO_IMAGE_KHR) {
    [indent]EGLint error = eglGetError();
    LOGE("Error (%#x): Creating EGLImageKHR at %s:%i\n", error, __FILE__, __LINE__);
    [/indent]
    }
    //setp 4. Set up the FBO with the EGLImage as target
    GLuint iFBOTex;
    GLuint iFBO;
    glViewport(0, 0, width, height);
    checkGlError("glViewport");

    glGenFramebuffers(1, &iFBO);
    checkGlError("glGenFramebuffers");

    /* Initialize FBO texture. */
    glGenTextures(1, &iFBOTex);
    checkGlError("glGenTextures");
    glBindTexture(GL_TEXTURE_2D, iFBOTex);

    /* 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, 0);
    checkGlError("glFramebufferTexture2D");

    /* Check FBO is OK. */
    GLenum iResult = glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if(iResult != GL_FRAMEBUFFER_COMPLETE) {
    [indent]LOGE("Error (%#x): Framebuffer incomplete at %s:%i\n", iResult, __FILE__, __LINE__);
    [/indent]
    }
    _glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, pEGLImage);
    checkEGLError("glEGLImageTargetTexture2DOES");

    /* Render to framebuffer object. */
    /* Unbind framebuffer. */
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    checkGlError("glBindFramebuffer");

    //step 5. 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);
    /* And unbind the FrameBuffer Object so subsequent drawing calls are to the EGL window surface. */
    glBindFramebuffer(GL_FRAMEBUFFER,0);

    //setp 6. 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)
    [indent]return;
    [/indent]
    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){
    [indent]buffer->unlock();
    return;
    [/indent]
    }

    unsigned char* ucVaddr = (unsigned char*)vaddr;
    }


    occur error when execute the follow code fragement.
    /* Attach texture to the framebuffer. */
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, iFBOTex, 0);
    checkGlError("glFramebufferTexture2D");
    /* Check FBO is OK. */
    GLenum iResult = glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if(iResult != GL_FRAMEBUFFER_COMPLETE) {
    LOGE("Error (%#x): Framebuffer incomplete at %s:%i\n", iResult, __FILE__, __LINE__);
    }

    When the code is executed to glCheckFramebufferStatus will prompt an error, the error is: "Error (0x3008): Creating EGLImageKHR at..." and "Error (0): Framebuffer incomplete at ...."

    Not to create a context, how to use the texture?Give me a complete sample,Appreciate it.

    Thanks for your help.
Reply
  • Note: This was originally posted on 17th September 2012 at http://forums.arm.com

    Hi Karthik,thanks a lot for answering me.
    I have read that page, and try, but I failed.

    Here are some of my code:



    void initEGL(int width, int height, SkBitmap bitmap)
    {
    //step 1.
    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 {
      LOGI("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);
    }

    //step 2. Create the Android Graphic Buffer
       GraphicBuffer* buffer = new GraphicBuffer(width, height, HAL_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){
    [indent]LOGE("Error: %s\n", strerror(-err));
    return ;
    [/indent]
    }

    // Retrieve andorid native buffer
    android_native_buffer_t* anb = buffer->getNativeBuffer();

    //step 3. Create the EGLImage
    const EGLint attrs[] = {
    [indent]EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
    EGL_NONE, EGL_NONE
    [/indent]
    };

    EGLImageKHR pEGLImage = _eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, (EGLClientBuffer)anb, attrs);

    if (pEGLImage == EGL_NO_IMAGE_KHR) {
    [indent]EGLint error = eglGetError();
    LOGE("Error (%#x): Creating EGLImageKHR at %s:%i\n", error, __FILE__, __LINE__);
    [/indent]
    }
    //setp 4. Set up the FBO with the EGLImage as target
    GLuint iFBOTex;
    GLuint iFBO;
    glViewport(0, 0, width, height);
    checkGlError("glViewport");

    glGenFramebuffers(1, &iFBO);
    checkGlError("glGenFramebuffers");

    /* Initialize FBO texture. */
    glGenTextures(1, &iFBOTex);
    checkGlError("glGenTextures");
    glBindTexture(GL_TEXTURE_2D, iFBOTex);

    /* 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, 0);
    checkGlError("glFramebufferTexture2D");

    /* Check FBO is OK. */
    GLenum iResult = glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if(iResult != GL_FRAMEBUFFER_COMPLETE) {
    [indent]LOGE("Error (%#x): Framebuffer incomplete at %s:%i\n", iResult, __FILE__, __LINE__);
    [/indent]
    }
    _glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, pEGLImage);
    checkEGLError("glEGLImageTargetTexture2DOES");

    /* Render to framebuffer object. */
    /* Unbind framebuffer. */
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    checkGlError("glBindFramebuffer");

    //step 5. 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);
    /* And unbind the FrameBuffer Object so subsequent drawing calls are to the EGL window surface. */
    glBindFramebuffer(GL_FRAMEBUFFER,0);

    //setp 6. 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)
    [indent]return;
    [/indent]
    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){
    [indent]buffer->unlock();
    return;
    [/indent]
    }

    unsigned char* ucVaddr = (unsigned char*)vaddr;
    }


    occur error when execute the follow code fragement.
    /* Attach texture to the framebuffer. */
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, iFBOTex, 0);
    checkGlError("glFramebufferTexture2D");
    /* Check FBO is OK. */
    GLenum iResult = glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if(iResult != GL_FRAMEBUFFER_COMPLETE) {
    LOGE("Error (%#x): Framebuffer incomplete at %s:%i\n", iResult, __FILE__, __LINE__);
    }

    When the code is executed to glCheckFramebufferStatus will prompt an error, the error is: "Error (0x3008): Creating EGLImageKHR at..." and "Error (0): Framebuffer incomplete at ...."

    Not to create a context, how to use the texture?Give me a complete sample,Appreciate it.

    Thanks for your help.
Children
No data