Always get EGL_BAD_MATCH when using eglCreatePixmapSurface

Recently, I was trying to attach a 3D module to an exiting picture and then show it on the window, but when I try to use eglCreatePixmapSurface, always get the EGL_BAD_MATCH error, here is the code, OS is WINCE5.0 with opengles 1.3:

BOOL CModelWnd2::CreateViewGLContext(HDC hDC)

m_dpy = eglGetDisplay( (NativeDisplayType) m_hDC);
if ( ! m_dpy )
return false;

if ( eglInitialize(m_dpy, NULL, NULL) == EGL_FALSE )
    return false;

// choose config
EGLint cfg_attr_list[] = { EGL_SURFACE_TYPE, EGL_PIXMAP_BIT, 
    EGL_RED_SIZE, 4, 
    EGL_BLUE_SIZE, 4, 
    EGL_DEPTH_SIZE, 16, 

__int32 num = 0;
if ( eglChooseConfig(m_dpy, cfg_attr_list, &m_config, 1, &num) == EGL_FALSE || num == 0 )
    return false;

// create surface
m_surface = eglCreatePixmapSurface(m_dpy, m_config, m_hDib, 0);//m_hDib has been created in advance
if (m_surface == EGL_NO_SURFACE )
    int nResult = eglGetError();//always get EGL_BAD_MATCH
      return false;

// create context
m_hGLContext = eglCreateContext(m_dpy, m_config, NULL, NULL);
// active context (make current)   
  return FALSE;
 if(eglMakeCurrent(m_dpy, m_surface, m_surface, m_hGLContext)==FALSE)
  return FALSE;
 return TRUE;


any answer or clue will be highly appreciated. :smiley:

I’ve found the sourcecode of eglCreatePixmapSurface yesterday, it turned out that I can’t use it on WINCE platform:

GLAPI EGLSurface APIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list) {
// Cannot support rendering to arbitrary native surfaces; use pbuffer surface and eglCopySurfaces instead

So, I decided to use pbuffer surface and eglCopySurfaces instead, if I get any further progress, I’ll update this thread.

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