EGLSurface createBCMPixmapSurface(EGLDisplay display, EGLConfig config) { EGLint pixel_format = EGL_PIXEL_FORMAT_ARGB_8888_BRCM; EGLint rt; eglGetConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &rt); if (rt & EGL_OPENGL_ES_BIT) { pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES_BRCM; pixel_format |= EGL_PIXEL_FORMAT_GLES_TEXTURE_BRCM; } if (rt & EGL_OPENGL_ES2_BIT) { pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES2_BRCM; pixel_format |= EGL_PIXEL_FORMAT_GLES2_TEXTURE_BRCM; } if (rt & EGL_OPENVG_BIT) { pixel_format |= EGL_PIXEL_FORMAT_RENDER_VG_BRCM; pixel_format |= EGL_PIXEL_FORMAT_VG_IMAGE_BRCM; } if (rt & EGL_OPENGL_BIT) { pixel_format |= EGL_PIXEL_FORMAT_RENDER_GL_BRCM; } EGLint pixmap[5]; pixmap[0] = 0; pixmap[1] = 0; pixmap[2] = 8; pixmap[3] = 8; pixmap[4] = pixel_format; eglCreateGlobalImageBRCM(8, 8, pixel_format, 0, 8*4, pixmap); EGLSurface surface = eglCreatePixmapSurface(display, config, pixmap, 0); if ( surface == EGL_NO_SURFACE ) { cerr << "Unable to create EGL surface (eglError: " << eglGetError() << ")" << endl; } return surface; }
EGLSurface eglCreateWindowSurface(EGLDisplay egldisplay, EGLConfig config, NativeWindowType native_window, EGLint const * attrib_list) { if (x11_enabled == 0) { return real_eglCreateWindowSurface(egldisplay,config,native_window,attrib_list); } window = (Window*) native_window; puts("Getting window information..."); XWindowAttributes window_attributes; XGetWindowAttributes(display,window,&window_attributes); printf("Window Location: %i,%i \n Window Dimensions %i x %i \n Bit depth : %i \n",window_attributes.x,window_attributes.y,window_attributes.width,window_attributes.height,window_attributes.depth); width=window_attributes.width ; height=window_attributes.height; depth=window_attributes.depth; EGLint attr[] = { // some attributes to set up our egl-interface EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_SURFACE_TYPE, EGL_PIXMAP_BIT | EGL_OPENGL_ES2_BIT, EGL_NONE }; EGLConfig ecfg; EGLint num_config; if (!eglChooseConfig(edisplay, attr, &ecfg, 1, &num_config)) { fprintf(stderr, "Failed to choose config (eglError: %s)\n"); return EGL_NO_SURFACE; } EGLint pixel_format = EGL_PIXEL_FORMAT_ARGB_8888_BRCM; EGLint rt; eglGetConfigAttrib(edisplay, ecfg, EGL_RENDERABLE_TYPE, &rt); if (rt & EGL_OPENGL_ES_BIT) { pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES_BRCM; pixel_format |= EGL_PIXEL_FORMAT_GLES_TEXTURE_BRCM; } if (rt & EGL_OPENGL_ES2_BIT) { pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES2_BRCM; pixel_format |= EGL_PIXEL_FORMAT_GLES2_TEXTURE_BRCM; } if (rt & EGL_OPENVG_BIT) { pixel_format |= EGL_PIXEL_FORMAT_RENDER_VG_BRCM; pixel_format |= EGL_PIXEL_FORMAT_VG_IMAGE_BRCM; } if (rt & EGL_OPENGL_BIT) { pixel_format |= EGL_PIXEL_FORMAT_RENDER_GL_BRCM; } EGLint pixmap[5]; pixmap[0] = 0; pixmap[1] = 0; pixmap[2] = width; pixmap[3] = height; pixmap[4] = pixel_format; eglCreateGlobalImageBRCM(width, height, pixmap[4], 0, width*4, pixmap); egl_surface = eglCreatePixmapSurface(edisplay, ecfg, pixmap, 0); puts("EGL Surface Created"); EGLint ctxattr[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; EGLContext context = eglCreateContext ( edisplay, ecfg, EGL_NO_CONTEXT, ctxattr ); real_eglMakeCurrent(edisplay, egl_surface, egl_surface, context); return egl_surface; }