Esempio n. 1
0
static VOID CALLBACK timer_handler(HWND, UINT, UINT, DWORD) {
    RECT rt;
    int width, height;
    char buf[MSG_CHANNEL_SIZE];
	if (g_sleep) return;

    // check for graphics-related message from core client
    //
    if (app_client_shm) {
        if (app_client_shm->shm->graphics_request.get_msg(buf)) {
            BOINCINFO("Received Graphics Message: %s", buf);
            app_client_shm->decode_graphics_msg(buf, graphics_msg);
            switch (graphics_msg.mode) {
            case MODE_REREAD_PREFS:
                // only reread graphics prefs if we have a window open
                //
                switch(current_graphics_mode) {
                case MODE_WINDOW:
                case MODE_FULLSCREEN:
                    app_graphics_reread_prefs();
                    break;
                }
                break;
            case MODE_HIDE_GRAPHICS:
            case MODE_WINDOW:
            case MODE_FULLSCREEN:
            case MODE_BLANKSCREEN:
                set_mode(graphics_msg.mode);
                break;
            }
        }
        // ack graphics mode
        //
        if (acked_graphics_mode != current_graphics_mode) {
            bool sent = app_client_shm->shm->graphics_reply.send_msg(
                xml_graphics_modes[current_graphics_mode]
            );
            if (sent) acked_graphics_mode = current_graphics_mode;
        }
    }
    if (!visible) return;
    if (current_graphics_mode == MODE_HIDE_GRAPHICS) return;
    if (!hWnd) return;

    // TODO: remove width, height from API
    //
    GetClientRect(hWnd, &rt);
    width = rt.right-rt.left;
    height = rt.bottom-rt.top;

    if (throttled_app_render(width, height, dtime())) {
        SwapBuffers(hDC);
    }
}
Esempio n. 2
0
static void timer_handler(int) {
    char buf[MSG_CHANNEL_SIZE];
    GRAPHICS_MSG m;
    BOINC_STATUS boinc_status;

    if (*g_bmsp->app_client_shmp) {
        if ((*g_bmsp->app_client_shmp)->shm->graphics_request.get_msg(buf)) {
            (*g_bmsp->app_client_shmp)->decode_graphics_msg(buf, m);
            switch (m.mode) {
            case MODE_REREAD_PREFS:
                //only reread graphics prefs if we have a window open
                //
                switch (current_graphics_mode){
                case MODE_WINDOW:
                case MODE_FULLSCREEN:
                    app_graphics_reread_prefs();
                    break;
                }
                break;
            case MODE_HIDE_GRAPHICS:
            case MODE_WINDOW:
            case MODE_FULLSCREEN:
            case MODE_BLANKSCREEN:
                if (strlen(m.display)) {
		    setenv("DISPLAY",m.display,1);
                }
                set_mode(m.mode);
                break;
            }
        }
        if (acked_graphics_mode != current_graphics_mode) {
            bool sent = (*g_bmsp->app_client_shmp)->shm->graphics_reply.send_msg(
                xml_graphics_modes[current_graphics_mode]
            );
            if (sent) acked_graphics_mode = current_graphics_mode;
        }
    }
    boinc_get_status(&boinc_status);
    if (! boinc_status.suspended)
        suspend_render = false;
    if (suspend_render) {
        glutTimerFunc(TIMER_INTERVAL_SUSPENDED_MSEC, timer_handler, 0);
    } else {
        maybe_render();
        glutTimerFunc(TIMER_INTERVAL_MSEC, timer_handler, 0);
    }

    return;
}