Page 1 of 4 1234 LastLast
Results 1 to 10 of 37

Thread: eglCreatePBufferSurface

  1. #1

    eglCreatePBufferSurface

    Hi , when i try creating a pBuffer Surface i get an error EGL_BAD_CONTEXT.And the PBuffer is NULL always..below is the code :


    int h = 400, w =200;
    EGLint attr[]={
    EGL_WIDTH, w,
    EGL_HEIGHT,h,
    EGL_TEXTURE_FORMAT,EGL_TEXTURE_RGB,
    EGL_TEXTURE_TARGET<EGL_TEXTURE_2D,
    EGL_NONE
    };
    EGLSurface pBuffer = eglCreatePbufferSurface(eglDisplay,eglConfig,attr) ;
    ......................



    Plesae tell what could be the possible raeson.Both egldisplay and eglConfig have proper values.

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    353
    Could you please keep related problems in one thread instead of starting new threads?

    The '<' should be a comma, otherwise you'll get all kinds of undefined behaviour because the attribute list is not properly terminated. In case that's just a copy&paste error, did you make sure the error is raised by eglCreatePbufferSurface and not some previous EGL call?
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  3. #3
    Hi,

    Sorry < was a typo for ,comma.
    Do we need to call eglChooseConfig () beforeeglCreatepBufferSurface() ?

    When i did eglChooseConfig() with the attrib list listed in previous post , i got it as NULL.

    While when i used the attrib list as below, i was able to get config.

    static const int attrib_list[]={

    EGL_RED_SIZE, 5,
    EGL_GREEN_SIZE,6,
    EGL_BLUE_SIZE,5,
    EGL_ALPHA_SIZE,0,
    EGL_SURFACE_TYPE,EGL_WINDOW_BIT,
    EGL_NONE
    };

    But when i used this config in eglCreatepBufferSurface, it again gave me the same error(EGL_BAD_MATCH);

    I have read that we get this error when we dont use proper color space values. Should i try with different attrib_list values or is there some other problem ?

    By the way what all attributes should the attrib_list have ideally ?

  4. #4
    Senior Member
    Join Date
    May 2006
    Posts
    353
    Of course you need to select a valid configuration first. And the attribute list for the config needs to contain EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, otherwise you may get a config that doesn't support pbuffers.

    Additionally, the width and height attributes passed to eglCreatePbufferSurface must be powers of two, just like for any other texture.

    For all possible attributes, see the EGL specification:
    http://www.khronos.org/registry/egl/
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  5. #5
    If I were doing a normal texture upload, my initialisation was (this is on a windows sample. there is no opengl related code prior to this):

    Code :
    eglDisplay = eglGetDisplay(hDC);
    eglInitialize(eglDisplay, NULL, NULL); //major -1 minor -1
    eglGetConfigs(eglDisplay, NULL, 0, &iConfigs);
     
    i = 0;
    pConfigAttributes[i++] = EGL_RED_SIZE;
    pConfigAttributes[i++] = 5;
    pConfigAttributes[i++] = EGL_GREEN_SIZE;
    pConfigAttributes[i++] = 6;
    pConfigAttributes[i++] = EGL_BLUE_SIZE;
    pConfigAttributes[i++] = 5;
    pConfigAttributes[i++] = EGL_ALPHA_SIZE;
    pConfigAttributes[i++] = 0;
    pConfigAttributes[i++] = EGL_SURFACE_TYPE;
    pConfigAttributes[i++] = EGL_WINDOW_BIT;
    pConfigAttributes[i++] = EGL_NONE;
     
    eglChooseConfig(eglDisplay, pConfigAttributes, &eglConfig, 1, &iConfigs);
     
    eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, eglWindow, NULL);
     
    eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, NULL);
     
    eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);

    Now for pBuffers I make the following change:
    Code :
    ....
    pConfigAttributes[i++] = EGL_WINDOW_BIT|EGL_PBUFFER_BIT;
    ....
    int err = eglGetError(); //RETURNS SUCESS
    EGLSurface pBuffer = eglCreatePBuffer(eglDisplay, eglConfig, pConfigAttributes);
    err = eglGetError(); //RETURNS EGL_BAD_MATCH

    if I add:
    Code :
    pConfigAttributes[i++] = EGL_TEXTURE_FORMAT;
    pConfigAttributes[i++] = EGL_TEXTURE_RGB;
    pConfigAttributes[i++] = EGL_TEXTURE_TARGET;
    pConfigAttributes[i++] = EGL_TEXTURE_2D;

    before EGL_NONE, eglChooseConfig fails.

    What modifications do I make to the initialization to get eglCreatePBuffer working? Whats wrong in my config attributes?

    Thanks for your help.

  6. #6
    Senior Member
    Join Date
    May 2006
    Posts
    353
    You're passing the wrong attributes to eglCreatePbufferSurface. You need two different attribute lists, one for the config and one for the pbuffer.

    eglCreatePbufferSurface accepts the following attributes: EGL WIDTH, EGL HEIGHT, EGL LARGEST PBUFFER,
    EGL TEXTURE FORMAT, EGL TEXTURE TARGET, EGL MIPMAP TEXTURE,
    EGL COLORSPACE, and EGL ALPHA FORMAT.
    They're all explained in the spec.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  7. #7
    Hmm... whatever I try I seem to be getting an EGL_BAD_MATCH.....

    Here's the updated code:

    Code :
    eglDisplay(..);
    eglIinitialize(...);
    eglGetConfigs(..);
    eglChooseConfig(...,&eglConfig,..);
    eglSurface = eglCreatewindowSurface(...);
    eglContext = eglCreateContext(..,eglConfig,..);
    eglMakecurrent(....); 
     
    static const int pBufferAttribs[] = {
    .....
    };
    pbuffer = eglCreatePbufferSurface(eglDisplay, eglConfig, pBufferAttribs);
    int err = eglGetError(); //every time returns 3009 - EGL_BAD_MATCH

    Here are the different combinations of pBufferAttribs I used:
    (1)
    Code :
    {
    EGL_WIDTH, 2, 
    EGL_HEIGHT, 2, 
    EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, 
    EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB, 
    EGL_LARGEST_BUFFER, EGL_FALSE, 
    EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, 
    EGL_MIPMAP_TEXTURE, EGL_FALSE, 
    EGL_NONE
    }
    (2)
    Code :
    {
    EGL_WIDTH, 2, 
    EGL_HEIGHT, 2, 
    EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, 
    EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB, 
    EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, 
    EGL_MIPMAP_TEXTURE, EGL_FALSE, 
    EGL_NONE
    }
    (3)
    Code :
    {
    EGL_WIDTH, 2, 
    EGL_HEIGHT, 2, 
    EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, 
    EGL_NONE
    }
    (4)
    Code :
    {
    EGL_WIDTH, 2, 
    EGL_HEIGHT, 2, 
    EGL_NONE
    }

    (5)
    Code :
    {
    EGL_NONE
    }
    (6)
    Code :
    NULL

    Every time, the same error right after eglCreatePbufferSurface.

    I normally use a 16 bit 5_6_5 RGB texture, w-1024 h-512.
    Am I missing something?

  8. #8
    Senior Member
    Join Date
    May 2006
    Posts
    353
    EGL_SURFACE_TYPE is not a pbuffer attribute.

    Try to find a config with the following attributes
    Code :
    EGL_RED_SIZE, 5,
    EGL_GREEN_SIZE, 6,
    EGL_BLUE_SIZE, 5,
    EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE,
    EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
    EGL_NONE

    Then try to create a pbuffer with these attributes:
    Code :
    EGL_WIDTH, 128,
    EGL_HEIGHT, 128,
    EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
    EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
    EGL_NONE
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  9. #9
    even though i try any attrib , i get the same error.

    code :

    eglDisplay = eglGetDisplay(hDc);
    eglInitialize(egldisplay,NULL,NULL); // eglDisplay = 1577130056

    EGLint configAttrib[] = {
    EGL_RED_SIZE, 5,
    EGL_GREEN_SIZE , 6,
    EGL_BLUE_SIZE, 5,
    EGL_BIND_TO_TEXTURE_RGB, EGL_PBUFFER_BIT,
    EGL_NONE
    };


    eglChooseConfig(eglDisplay,configAttrib,&eglConfig ,1,&iConfigs);
    // eglConfig = 0
    eglSurface = eglCreateWindowSurface(eglDisplay,eglConfig,eglWin dow,NULL); //eglSurface = 009929878

    eglContext = eglCreateContext(eglDisplay,eglConfig,NULL,NULL);
    eglMakeCurrent(eglDisplay,eglSurface,eglcontext);

    static const int pBuffer_attrib[]={
    EGL_WIDTH, 128,
    EGL_HEIGHT, 128,
    EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
    EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
    EGL_NONE
    };

    EGLSurface pBuffer = eglcreatePBuffer(eglDisplay,eglconfig,pBuffer_attr ib); //pBuffer = NULL
    int err = eglGetError(); // err = 3009



    Tell me If I m still missing something .

  10. #10
    Senior Member
    Join Date
    May 2006
    Posts
    353
    Quote Originally Posted by akhil
    EGL_BIND_TO_TEXTURE_RGB, EGL_PBUFFER_BIT,
    That's not what I wrote. Did you even check whether eglChooseConfig raised an error?
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

Page 1 of 4 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •