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.

What graphics hardware does your PC have?

the graphic hardware is “Intel® G33/G31 Express Chipset Family”.

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!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.