typedef void * NativeDisplayType; typedef int NativePixmapType; typedef int NativeWindowType; #include "wsegl.h" #include #include #include #include #include #include #include "omapfb.h" #define WSEGL_PATH "/usr/lib/libpvrX11WSEGL.so" static WSEGL_FunctionTable *get_real_ft() { static WSEGL_FunctionTable *singleton = NULL; /* dlopen another WSEGL and grab their ft in here */ WSEGL_FunctionTable *(*_GetFunctionTablePointer)(void); if (singleton == NULL) { void *lib = dlopen(WSEGL_PATH, RTLD_GLOBAL|RTLD_NOW); if (lib == NULL) { abort(); } _GetFunctionTablePointer = dlsym(lib, "WSEGL_GetFunctionTablePointer"); singleton = (*_GetFunctionTablePointer)(); } return singleton; } static WSEGLError wseglIsDisplayValid(NativeDisplayType nativeDisplay) { fprintf(stderr, "wseglIsDisplayValid\n"); return (*(get_real_ft()->pfnWSEGL_IsDisplayValid))(nativeDisplay); } /* Initialize a native display for use with WSEGL */ static WSEGLError wseglInitializeDisplay (NativeDisplayType nativeDisplay, WSEGLDisplayHandle *display, const WSEGLCaps **caps, WSEGLConfig **configs) { fprintf(stderr, "wseglInitializeDisplay\n"); return (*(get_real_ft()->pfnWSEGL_InitialiseDisplay))(nativeDisplay, display, caps, configs); } /* Close the WSEGL display */ static WSEGLError wseglCloseDisplay(WSEGLDisplayHandle display) { fprintf(stderr, "wseglCloseDisplay\n"); return (*(get_real_ft()->pfnWSEGL_CloseDisplay))(display); } /* Create the WSEGL drawable version of a native window */ static WSEGLError wseglCreateWindowDrawable (WSEGLDisplayHandle display, WSEGLConfig *config, WSEGLDrawableHandle *drawable, NativeWindowType nativeWindow, WSEGLRotationAngle *rotationAngle) { fprintf(stderr, "wseglCloseDisplay\n"); return (*(get_real_ft()->pfnWSEGL_CreateWindowDrawable))(display, config, drawable, nativeWindow, rotationAngle); } /* Create the WSEGL drawable version of a native pixmap */ static WSEGLError wseglCreatePixmapDrawable (WSEGLDisplayHandle display, WSEGLConfig *config, WSEGLDrawableHandle *drawable, NativePixmapType nativePixmap, WSEGLRotationAngle *rotationAngle) { fprintf(stderr, "wseglCreatePixmapDrawable\n"); return (*(get_real_ft()->pfnWSEGL_CreatePixmapDrawable))(display, config, drawable, nativePixmap, rotationAngle); } /* Delete a specific drawable */ static WSEGLError wseglDeleteDrawable(WSEGLDrawableHandle _drawable) { fprintf(stderr, "wseglDeleteDrawable\n"); return (*(get_real_ft()->pfnWSEGL_DeleteDrawable))(_drawable); } /* Swap the contents of a drawable to the screen */ static WSEGLError wseglSwapDrawable (WSEGLDrawableHandle _drawable, unsigned long data) { static int fd = -1; WSEGLError ret; struct omapfb_update_window update; fprintf(stderr, "wseglSwapDrawable\n"); ret = (*(get_real_ft()->pfnWSEGL_SwapDrawable))(_drawable, data); if (fd == -1) { fd = open("/dev/fb0", O_RDWR); } update.x = 0; update.y = 0; update.width = 800; update.height = 480; /* TODO: there ain't OMAPFB_COLOR_RGB888 for 24-bit color */ update.format = OMAPFB_COLOR_RGB565; update.out_x = 0; update.out_y = 0; update.out_width = 800; update.out_height = 480; if (ioctl(fd, OMAPFB_UPDATE_WINDOW, &update) < 0) { perror("Could not ioctl(OMAPFB_UPDATE_WINDOW)"); } return ret; } /* Set the swap interval of a window drawable */ static WSEGLError wseglSwapControlInterval (WSEGLDrawableHandle drawable, unsigned long interval) { fprintf(stderr, "wseglSwapControlInterval\n"); return (*(get_real_ft()->pfnWSEGL_SwapControlInterval))(drawable, interval); } /* Flush native rendering requests on a drawable */ static WSEGLError wseglWaitNative (WSEGLDrawableHandle drawable, unsigned long engine) { fprintf(stderr, "wseglWaitNative\n"); return (*(get_real_ft()->pfnWSEGL_WaitNative))(drawable, engine); } /* Copy color data from a drawable to a native pixmap */ static WSEGLError wseglCopyFromDrawable (WSEGLDrawableHandle _drawable, NativePixmapType nativePixmap) { fprintf(stderr, "wseglCopyFromDrawable\n"); return (*(get_real_ft()->pfnWSEGL_CopyFromDrawable))(_drawable, nativePixmap); } /* Copy color data from a PBuffer to a native pixmap */ static WSEGLError wseglCopyFromPBuffer (void *address, unsigned long width, unsigned long height, unsigned long stride, WSEGLPixelFormat format, NativePixmapType nativePixmap) { fprintf(stderr, "wseglCopyFromPBuffer\n"); return (*(get_real_ft()->pfnWSEGL_CopyFromPBuffer))(address,width,height,stride,format,nativePixmap); } /* Return the parameters of a drawable that are needed by the EGL layer */ static WSEGLError wseglGetDrawableParameters (WSEGLDrawableHandle _drawable, WSEGLDrawableParams *sourceParams, WSEGLDrawableParams *renderParams) { fprintf(stderr, "wseglGetDrawableParameters\n"); return (*(get_real_ft()->pfnWSEGL_GetDrawableParameters))(_drawable, sourceParams, renderParams); } static WSEGL_FunctionTable const wseglFunctions = { WSEGL_VERSION, wseglIsDisplayValid, wseglInitializeDisplay, wseglCloseDisplay, wseglCreateWindowDrawable, wseglCreatePixmapDrawable, wseglDeleteDrawable, wseglSwapDrawable, wseglSwapControlInterval, wseglWaitNative, wseglCopyFromDrawable, wseglCopyFromPBuffer, wseglGetDrawableParameters }; /* Return the table of WSEGL functions to the EGL implementation */ const WSEGL_FunctionTable *WSEGL_GetFunctionTablePointer(void) { return &wseglFunctions; } #if 0 int main(int argc, char **argv) { printf("%x", get_real_ft()); } #endif