The Khronos Group - a non-profit industry consortium to develop, publish and promote open standard, royalty-free media authoring and acceleration standards for desktop and handheld devices, combined with conformance qualification programs for platform and device interoperability.

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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);