static int control(uint32_t request, void *data) { switch (request) { case VOCTRL_PAUSE: case VOCTRL_RESUME: int_pause = (request == VOCTRL_PAUSE); return VO_TRUE; case VOCTRL_QUERY_FORMAT: return query_format(*(uint32_t*)data); case VOCTRL_ONTOP: glctx.ontop(); return VO_TRUE; case VOCTRL_FULLSCREEN: glctx.fullscreen(); matrixview_reshape(vo_dwidth, vo_dheight); return VO_TRUE; case VOCTRL_BORDER: glctx.border(); return VO_TRUE; case VOCTRL_GET_EQUALIZER: { vf_equalizer_t *eq=data; if (strcasecmp(eq->item, "contrast") == 0) { eq->value = eq_contrast; } else if (strcasecmp(eq->item, "brightness") == 0) { eq->value = eq_brightness; } } return VO_TRUE; case VOCTRL_SET_EQUALIZER: { vf_equalizer_t *eq=data; if (strcasecmp(eq->item, "contrast") == 0) { contrast_set(eq->value); } else if (strcasecmp(eq->item, "brightness") == 0) { brightness_set(eq->value); } } return VO_TRUE; case VOCTRL_UPDATE_SCREENINFO: glctx.update_xinerama_info(); return VO_TRUE; case VOCTRL_GUI_RESIZE: matrixview_reshape(vo_dwidth, vo_dheight); return VO_TRUE; } return VO_NOTIMPL; }
/* connect to server, create and map window, * allocate colors and (shared) memory */ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { int xs, ys; image_height = height; image_width = width; image_format = format; is_yuv = mp_get_chroma_shift(image_format, &xs, &ys) > 0; is_yuv |= (xs << 8) | (ys << 16); glFindFormat(format, NULL, &gl_texfmt, &gl_format, &gl_type); int_pause = 0; vo_flipped = !!(flags & VOFLAG_FLIPPING); if (create_window(d_width, d_height, flags, title) < 0) return -1; if (vo_config_count) uninitGl(); if (glctx.setGlWindow(&glctx) == SET_WINDOW_FAILED) return -1; if (mesa_buffer && !mpglAllocateMemoryMESA) { mp_msg(MSGT_VO, MSGL_ERR, "Can not enable mesa-buffer because AllocateMemoryMESA was not found\n"); mesa_buffer = 0; } initGl(vo_dwidth, vo_dheight); return 0; }
static void check_events(void) { int e = glctx.check_events(); if (e & VO_EVENT_RESIZE) { matrixview_reshape(vo_dwidth, vo_dheight); } if (e & VO_EVENT_EXPOSE && int_pause) flip_page(); }
static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { image_height = height; image_width = width; image_format = format; int_pause = 0; #ifdef CONFIG_GL_WIN32 if (glctx.type == GLTYPE_W32 && !vo_w32_config(d_width, d_height, flags)) return -1; #endif #ifdef CONFIG_GL_X11 if (glctx.type == GLTYPE_X11) { XVisualInfo *vinfo=glXChooseVisual( mDisplay,mScreen,wsGLXAttrib ); if (vinfo == NULL) { mp_msg(MSGT_VO, MSGL_ERR, "[matrixview] no GLX support present\n"); return -1; } mp_msg(MSGT_VO, MSGL_V, "[matrixview] GLX chose visual with ID 0x%x\n", (int)vinfo->visualid); vo_x11_create_vo_window(vinfo, vo_dx, vo_dy, d_width, d_height, flags, XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone), "matrixview", title); } #endif /* CONFIG_GL_WIN32 */ if (glctx.setGlWindow(&glctx) == SET_WINDOW_FAILED) return -1; if (sws) sws_freeContext(sws); sws = sws_getContextFromCmdLine(image_width, image_height, image_format, matrix_cols, matrix_rows, IMGFMT_Y8); if (!sws) { mp_msg(MSGT_VO, MSGL_ERR, "[matrixview] Cannot create SwsContext context\n"); return -1; } if (!map_image[0]) map_image[0] = calloc(matrix_cols, matrix_rows); map_stride[0] = matrix_cols; matrixview_init(vo_dwidth, vo_dheight); matrixview_matrix_resize(matrix_cols, matrix_rows); contrast_set(eq_contrast); brightness_set(eq_brightness); matrixview_reshape(vo_dwidth, vo_dheight); return 0; }
static void check_events(void) { int e=glctx.check_events(); if(e&VO_EVENT_REINIT) { uninitGl(); initGl(vo_dwidth, vo_dheight); } if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight); if(e&VO_EVENT_EXPOSE && int_pause) redraw(); }
static void flip_page(void) { matrixview_draw(vo_dwidth, vo_dheight, GetTimer(), 0.0, map_image[0]); glctx.swapGlBuffers(&glctx); }