Hmmmm, I've been really careful that the width, height and bit depth are all the same heres that code that creates the X window and pixmap:
Code: Select all
gXDisplay = XOpenDisplay(NULL);
if (gXDisplay)
{
printf("X found\n");
gContext.flags |= PI_DISPLAY_XWINDOWS;
x_attrib.event_mask = ExposureMask | PointerMotionMask | KeyPressMask;
gWindow = XCreateWindow(gXDisplay, DefaultRootWindow(gXDisplay), 0, 0, width, height, 0, CopyFromParent,
InputOutput, CopyFromParent, CWEventMask, &x_attrib);
XMapWindow(gXDisplay, gWindow);
XStoreName(gXDisplay, gWindow, windowName);
gGC = DefaultGC(gXDisplay, 0);
XGetWindowAttributes(gXDisplay, gWindow, &wa);
gPixmap = XCreatePixmap(gXDisplay, gWindow, wa.width, wa.height, wa.depth);
printf("attr = %i, %i, %i\n", wa.width, wa.height, wa.depth);
gContext.width = width;
gContext.height = height;
}
and here's the code that creates the surface:
Code: Select all
pixmap[0] = 0;
pixmap[1] = 0;
pixmap[2] = width;
pixmap[3] = height;
eglGetConfigAttrib(gEGLDisplay, config, EGL_RED_SIZE, &val);
pixmap[4] = EGL_PIXEL_FORMAT_RGB_565_BRCM;
stride = width << 1;
if (val == 8)
{
pixmap[4] = EGL_PIXEL_FORMAT_XRGB_8888_BRCM;
stride <<= 1;
}
eglGetConfigAttrib(gEGLDisplay, config, EGL_ALPHA_SIZE, &val);
if (val == 8)
{
pixmap[4] = EGL_PIXEL_FORMAT_ARGB_8888_BRCM;
}
eglGetConfigAttrib(gEGLDisplay, config, EGL_RENDERABLE_TYPE, &val);
if (val & EGL_OPENGL_ES_BIT)
{
pixmap[4] |= EGL_PIXEL_FORMAT_RENDER_GLES_BRCM | EGL_PIXEL_FORMAT_GLES_TEXTURE_BRCM;
}
if (val & EGL_OPENGL_ES2_BIT)
{
pixmap[4] |= EGL_PIXEL_FORMAT_RENDER_GLES2_BRCM | EGL_PIXEL_FORMAT_GLES2_TEXTURE_BRCM;
}
if (val & EGL_OPENVG_BIT)
{
pixmap[4] |= EGL_PIXEL_FORMAT_RENDER_VG_BRCM | EGL_PIXEL_FORMAT_VG_IMAGE_BRCM;
}
if (val & EGL_OPENGL_BIT)
{
pixmap[4] |= EGL_PIXEL_FORMAT_RENDER_GL_BRCM;
}
eglCreateGlobalImageBRCM(width, height, pixmap[4], 0, stride, pixmap);
printf("id = %i, %i, %i, %i, %x\n", pixmap[0], pixmap[1], pixmap[2], pixmap[3], pixmap[4]);
gEGLSurface = eglCreatePixmapSurface(gEGLDisplay, config, pixmap, NULL);
gImageID = pixmap[0];
if (gEGLSurface == EGL_NO_SURFACE)
{
printf("Failed to create EGL surface\n");
return NULL;
}
and finally the code at the end of the render loop:
Code: Select all
if (eglCopyBuffers(gEGLDisplay, gEGLSurface, &gPixmap) == EGL_FALSE)
{
if (!temp_flag)
{
EGLint e = eglGetError();
printf("copyBuffers failed: %i (0x%.8x)\n", e, e);
}
}
XCopyArea(gXDisplay, gPixmap, gWindow, gGC, 0, 0, gContext.width, gContext.height, 0, 0);
As you can see there are some printfs in the code and the output looks like this:
Code: Select all
X found
attr = 640, 480, 16
id = 1, 0, 640, 480, 3f1
copyBuffers failed: 12297 (0x00003009)
So I'm not sure what's going on.