예제 #1
0
EGLNativeWindowType getNativeWindowType() {
    if (!done_loading_symbols) {
        load_wrapped_gles_symbols();
    }

#ifdef ANDROID_NDK
#ifdef DALVIK_VM
#define ANDROID_LIB "libactivity.so"
#define GET_NATIVE_WINDOW "android_getNativeWindow"
#else
#define ANDROID_LIB "libglass_lens_android.so"    
#define GET_NATIVE_WINDOW "ANDROID_getNativeWindow"    
#endif
    //don't cache for Android!
    printf("Using %s\n", ANDROID_LIB);
    void *libglass_android = dlopen(ANDROID_LIB, RTLD_LAZY | RTLD_GLOBAL);
    if (!libglass_android) {
        fprintf(stderr, "Did not find %s %s\n", ANDROID_LIB, dlerror());
           return NULL;
    }
    _ANDROID_getNativeWindow = dlsym(libglass_android, GET_NATIVE_WINDOW);
    if (!_ANDROID_getNativeWindow) {
       fprintf(stderr, "Did not find symbol \"%s\" %s\n", GET_NATIVE_WINDOW, dlerror());
       return NULL;
    }
    return (*_ANDROID_getNativeWindow)();
#else
    return (EGLNativeWindowType) (*prismPort.getNativeWindowType)();
#endif
}
예제 #2
0
EGLNativeDisplayType util_getNativeDisplayType() {
    static EGLNativeDisplayType cachedNativeDisplayType;
    static int cached = 0;

    if (!done_loading_symbols) {
        load_wrapped_gles_symbols();
    }

    if (!cached) {
        if (useVivanteFB)  {
            if (wr_fbGetDisplayByIndex) {
                cachedNativeDisplayType = wr_fbGetDisplayByIndex(0);
            } else {
               cachedNativeDisplayType = (EGLNativeDisplayType)0xBAD;
            }
        } else {
            cachedNativeDisplayType = EGL_DEFAULT_DISPLAY;
        }

        cached ++;
    }


    return cachedNativeDisplayType;
}
예제 #3
0
EGLNativeDisplayType getNativeDisplayType() {
    if (!done_loading_symbols) {
        load_wrapped_gles_symbols();
    }
#ifdef ANDROID_NDK
    return (EGLNativeDisplayType) NULL;
#else
    return (EGLNativeDisplayType) (*prismPort.getNativeDisplayType)();
#endif

}
예제 #4
0
EGLNativeWindowType util_getNativeWindowType() {
    static NativeWindowType cachedWindowType;
    static int cached = 0;

    if (!cached) {

        if (!done_loading_symbols) {
            load_wrapped_gles_symbols();
        }

        if (useDispman) {
#ifdef USE_DISPMAN

            EGL_DISPMANX_WINDOW_T *dispmanWindow;
            DISPMANX_DISPLAY_HANDLE_T display = 0;
            DISPMANX_ELEMENT_HANDLE_T element;
            DISPMANX_UPDATE_HANDLE_T update;
            VC_RECT_T dst = { 0, 0, 0, 0 };
            VC_RECT_T src = { 0, 0, 0, 0 };

            (*wr_bcm_host_init)();

            dispmanWindow = (EGL_DISPMANX_WINDOW_T *)calloc(sizeof(EGL_DISPMANX_WINDOW_T), 1);

            display = (*wr_vc_dispmanx_display_open)(0 /* LCD */);
            if (display == 0) {
                fprintf(stderr, "Dispman: Cannot open display\n");
                return 0;
            }
            int fbFileHandle;
            struct fb_var_screeninfo screenInfo;
            fbFileHandle = open("/dev/fb0", O_RDONLY);
            if (fbFileHandle < 0) {
                fprintf(stderr, "Cannot open framebuffer\n");
                return 0;
            }
            if (ioctl(fbFileHandle, FBIOGET_VSCREENINFO, &screenInfo)) {
                fprintf(stderr, "Cannot get screen info\n");
                return 0;
            }
            close(fbFileHandle);

            dst.width = screenInfo.xres;
            dst.height = screenInfo.yres;
            src.width = screenInfo.xres << 16;
            src.height = screenInfo.yres << 16;

            VC_DISPMANX_ALPHA_T alpha;
            alpha.flags = DISPMANX_FLAGS_ALPHA_FROM_SOURCE;
            alpha.opacity = 0xff;
            alpha.mask = (DISPMANX_RESOURCE_HANDLE_T) 0;
            update = (*wr_vc_dispmanx_update_start)(0);
            element = (*wr_vc_dispmanx_element_add)(
                          update,
                          display,
                          1 /*layer*/,
                          &dst,
                          0 /*src*/,
                          &src,
                          DISPMANX_PROTECTION_NONE,
                          &alpha,
                          0 /*clamp*/,
                          0 /*transform*/);

            dispmanWindow->element = element;
            dispmanWindow->width = screenInfo.xres;
            dispmanWindow->height = screenInfo.yres;
            (*wr_vc_dispmanx_update_submit_sync)(update);

            cachedWindowType = (NativeWindowType)dispmanWindow;
#endif /* USE_DISPMAN */
        } else if (useVivanteFB)  {
            cachedWindowType = (*wr_fbCreateWindow)(util_getNativeDisplayType(), 0, 0, 0, 0);
        } else {
            cachedWindowType = NULL;      // hence the EGL NULL
        }
        cached ++;
    }

    return cachedWindowType;
}