Esempio n. 1
0
static void resize(int x,int y){
  // simple orthogonal projection for 0-image_width;0-image_height
  float matrix[16] = {
    2.0/image_width,   0, 0, 0,
    0, -2.0/image_height, 0, 0,
    0, 0, 0, 0,
    -1, 1, 0, 1
  };
  mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y);
  if (WinID >= 0) {
    int left = 0, top = 0, w = x, h = y;
    geometry(&left, &top, &w, &h, vo_dwidth, vo_dheight);
    top = y - h - top;
    mpglViewport(left, top, w, h);
  } else
    mpglViewport( 0, 0, x, y );

  mpglMatrixMode(GL_PROJECTION);
  ass_border_x = ass_border_y = 0;
  if (aspect_scaling() && use_aspect) {
    int new_w, new_h;
    GLdouble scale_x, scale_y;
    aspect(&new_w, &new_h, A_WINZOOM);
    panscan_calc_windowed();
    new_w += vo_panscan_x;
    new_h += vo_panscan_y;
    scale_x = (GLdouble)new_w / (GLdouble)x;
    scale_y = (GLdouble)new_h / (GLdouble)y;
    matrix[0]  *= scale_x;
    matrix[12] *= scale_x;
    matrix[5]  *= scale_y;
    matrix[13] *= scale_y;
    ass_border_x = (vo_dwidth - new_w) / 2;
    ass_border_y = (vo_dheight - new_h) / 2;
  }
  mpglLoadMatrixf(matrix);

  mpglMatrixMode(GL_MODELVIEW);
  mpglLoadIdentity();

  if (!scaled_osd) {
#ifdef CONFIG_FREETYPE
    // adjust font size to display size
    force_load_font = 1;
#endif
    vo_osd_changed(OSDTYPE_OSD);
  }
  mpglClear(GL_COLOR_BUFFER_BIT);
  redraw();
}
Esempio n. 2
0
/**
 * \param type bit 0: render OSD, bit 1: render EOSD
 */
static void do_render_osd(int type) {
  int draw_osd  = (type & RENDER_OSD)  && osdtexCnt > 0;
  int draw_eosd = (type & RENDER_EOSD) && eosdDispList;
  if (!draw_osd && !draw_eosd)
    return;
  // set special rendering parameters
  if (!scaled_osd) {
    mpglMatrixMode(GL_PROJECTION);
    mpglPushMatrix();
    mpglLoadIdentity();
    mpglOrtho(0, vo_dwidth, vo_dheight, 0, -1, 1);
  }
  mpglEnable(GL_BLEND);
  if (draw_eosd) {
    mpglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    mpglCallList(eosdDispList);
  }
  if (draw_osd) {
    mpglColor4ub((osd_color >> 16) & 0xff, (osd_color >> 8) & 0xff, osd_color & 0xff, 0xff - (osd_color >> 24));
    // draw OSD
#ifndef FAST_OSD
    mpglBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);
    mpglCallLists(osdtexCnt, GL_UNSIGNED_INT, osdaDispList);
#endif
    mpglBlendFunc(GL_SRC_ALPHA, GL_ONE);
    mpglCallLists(osdtexCnt, GL_UNSIGNED_INT, osdDispList);
  }
  // set rendering parameters back to defaults
  mpglDisable(GL_BLEND);
  if (!scaled_osd)
    mpglPopMatrix();
  mpglBindTexture(gl_target, 0);
}