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(); }
/** * \brief Initialize a (new or reused) OpenGL context. * set global gl-related variables to their default values */ static int initGl(uint32_t d_width, uint32_t d_height) { GLint scale_type = get_scale_type(0); autodetectGlExtensions(); gl_target = use_rectangle == 1 ? GL_TEXTURE_RECTANGLE : GL_TEXTURE_2D; yuvconvtype = SET_YUV_CONVERSION(use_yuv) | SET_YUV_LUM_SCALER(lscale) | SET_YUV_CHROM_SCALER(cscale); texSize(image_width, image_height, &texture_width, &texture_height); mpglDisable(GL_BLEND); mpglDisable(GL_DEPTH_TEST); mpglDepthMask(GL_FALSE); mpglDisable(GL_CULL_FACE); mpglEnable(gl_target); mpglDrawBuffer(vo_doublebuffering?GL_BACK:GL_FRONT); mpglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); mp_msg(MSGT_VO, MSGL_V, "[gl] Creating %dx%d texture...\n", texture_width, texture_height); glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, scale_type, texture_width, texture_height, 0); if (mipmap_gen) mpglTexParameteri(gl_target, GL_GENERATE_MIPMAP, GL_TRUE); if (is_yuv) { int i; int xs, ys; scale_type = get_scale_type(1); mp_get_chroma_shift(image_format, &xs, &ys); mpglGenTextures(21, default_texs); default_texs[21] = 0; for (i = 0; i < 7; i++) { mpglActiveTexture(GL_TEXTURE1 + i); mpglBindTexture(GL_TEXTURE_2D, default_texs[i]); mpglBindTexture(GL_TEXTURE_RECTANGLE, default_texs[i + 7]); mpglBindTexture(GL_TEXTURE_3D, default_texs[i + 14]); } mpglActiveTexture(GL_TEXTURE1); glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, scale_type, texture_width >> xs, texture_height >> ys, 128); if (mipmap_gen) mpglTexParameteri(gl_target, GL_GENERATE_MIPMAP, GL_TRUE); mpglActiveTexture(GL_TEXTURE2); glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, scale_type, texture_width >> xs, texture_height >> ys, 128); if (mipmap_gen) mpglTexParameteri(gl_target, GL_GENERATE_MIPMAP, GL_TRUE); mpglActiveTexture(GL_TEXTURE0); mpglBindTexture(gl_target, 0); } if (is_yuv || custom_prog) { if ((MASK_NOT_COMBINERS & (1 << use_yuv)) || custom_prog) { if (!mpglGenPrograms || !mpglBindProgram) { mp_msg(MSGT_VO, MSGL_ERR, "[gl] fragment program functions missing!\n"); } else { mpglGenPrograms(1, &fragprog); mpglBindProgram(GL_FRAGMENT_PROGRAM, fragprog); } } update_yuvconv(); } resize(d_width, d_height); mpglClearColor( 0.0f,0.0f,0.0f,0.0f ); mpglClear( GL_COLOR_BUFFER_BIT ); if (mpglSwapInterval && swap_interval >= 0) mpglSwapInterval(swap_interval); return 1; }