Results 1 to 4 of 4

Thread: eglCreateContext in the trainingcourse returns EGL_BAD_ALLOC

  1. #1
    Junior Member
    Join Date
    Mar 2009
    Posts
    3

    eglCreateContext in the trainingcourse returns EGL_BAD_ALLOC

    Hi:
    I run the code in the PowerVR training course in my Visual Studio 2008.

    After successfully eglChooseConfig and eglCreateWindowSurface, I bind the API using EGL_OPENGL_ES_API.
    then eglCreateContext is called. It return 0x0. I check the eglGetError (), which returns 0x3003 or EGL_BAD_ALLOC.

    Can any body help? Thx.

    /*
    Step 1 - Get the default display.
    EGL uses the concept of a "display" which in most environments
    corresponds to a single physical screen. Since we usually want
    to draw to the main screen or only have a single screen to begin
    with, we let EGL pick the default display.
    Querying other displays is platform specific.
    */
    eglDisplay = eglGetDisplay(hDC);

    if(eglDisplay == EGL_NO_DISPLAY)
    eglDisplay = eglGetDisplay((EGLNativeDisplayType) EGL_DEFAULT_DISPLAY);
    /*
    Step 2 - Initialize EGL.
    EGL has to be initialized with the display obtained in the
    previous step. We cannot use other EGL functions except
    eglGetDisplay and eglGetError before eglInitialize has been
    called.
    If we're not interested in the EGL version number we can just
    pass NULL for the second and third parameters.
    */
    EGLint iMajorVersion, iMinorVersion;
    if (!eglInitialize(eglDisplay, &iMajorVersion, &iMinorVersion))
    {
    MessageBox(0, _T("eglInitialize() failed."), _T("Error"), MB_OK|MB_ICONEXCLAMATION);
    goto cleanup;
    }

    /*
    Step 3 - Specify the required configuration attributes.
    An EGL "configuration" describes the pixel format and type of
    surfaces that can be used for drawing.
    For now we just want to use the default Windows surface,
    i.e. it will be visible on screen. The list
    has to contain key/value pairs, terminated with EGL_NONE.
    */
    const EGLint pi32ConfigAttribs[] =
    {
    EGL_LEVEL, 0,
    EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
    EGL_NATIVE_RENDERABLE, EGL_FALSE,
    EGL_DEPTH_SIZE, EGL_DONT_CARE,
    EGL_NONE
    };

    /*
    Step 4 - Find a config that matches all requirements.
    eglChooseConfig provides a list of all available configurations
    that meet or exceed the requirements given as the second
    argument. In most cases we just want the first config that meets
    all criteria, so we can limit the number of configs returned to 1.
    */
    int iConfigs;
    if (!eglChooseConfig(eglDisplay, pi32ConfigAttribs, &eglConfig, 1, &iConfigs) || (iConfigs != 1))
    {
    MessageBox(0, _T("eglChooseConfig() failed."), _T("Error"), MB_OK|MB_ICONEXCLAMATION);
    goto cleanup;
    }

    /*
    Step 5 - Create a surface to draw to.
    Use the config picked in the previous step and the native window
    handle when available to create a window surface. A window surface
    is one that will be visible on screen inside the native display (or
    fullscreen if there is no windowing system).
    Pixmaps and pbuffers are surfaces which only exist in off-screen
    memory.
    */
    eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, eglWindow, NULL);

    if(eglSurface == EGL_NO_SURFACE)
    {
    eglGetError(); // Clear error
    eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, NULL, NULL);
    }

    if (!TestEGLError(hWnd, "eglCreateWindowSurface"))
    {
    goto cleanup;
    }

    /*
    Step 6 - Create a context.
    EGL has to create a context for OpenGL ES. Our OpenGL ES resources
    like textures will only be valid inside this context
    (or shared contexts)
    */

    // Bind the API (It could be OpenGLES or OpenVG)
    eglBindAPI(EGL_OPENGL_ES_API);
    EGLint e = eglGetError ();
    EGLint ai32ContextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
    //eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, ai32ContextAttribs);
    eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, NULL);
    e = eglGetError (); //here returns 0x3003.

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: eglCreateContext in the trainingcourse returns EGL_BAD_ALLOC

    What graphics hardware does your PC have?
    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
    Junior Member
    Join Date
    Mar 2009
    Posts
    3

    Re: eglCreateContext in the trainingcourse returns EGL_BAD_ALLOC

    the graphic hardware is "Intel(R) G33/G31 Express Chipset Family".

  4. #4
    Junior Member
    Join Date
    Mar 2009
    Posts
    3

    Re: eglCreateContext in the trainingcourse returns EGL_BAD_ALLOC

    Oh, Sorry, the PowerVR's 2.0 edition seems not support the Intel integrated graphics chipsets.
    I may need to find another emulator in windows.

    Thank you!

Similar Threads

  1. EGL_BAD_ALLOC with eGLMakeCurrent on antoher window.
    By RungeKutta in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 12-08-2008, 03:47 AM
  2. TrainingCourse projects build but do not run - missing mod?
    By glutz78 in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 01-23-2008, 02:07 PM
  3. EGL_BAD_ALLOC error in Windows Vista
    By danielkim in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 04-05-2007, 02:23 AM

Posting Permissions

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