Mercurial > mplayer.hg
diff libvo/vo_gl.c @ 13653:799f81d3cb19
added gl_common for code used by both vo_gl.c and vo_gl2.c.
author | reimar |
---|---|
date | Sun, 17 Oct 2004 13:28:22 +0000 |
parents | da85ac96600e |
children | b34c5aa5f798 |
line wrap: on
line diff
--- a/libvo/vo_gl.c Sat Oct 16 14:10:57 2004 +0000 +++ b/libvo/vo_gl.c Sun Oct 17 13:28:22 2004 +0000 @@ -21,6 +21,7 @@ #include <GL/gl.h> +#include "gl_common.h" #include "x11_common.h" #include "aspect.h" @@ -180,7 +181,6 @@ XSizeHints hint; XVisualInfo *vinfo; XEvent xev; - GLint gl_alignment; // XGCValues xgcv; @@ -280,15 +280,7 @@ glEnable(GL_TEXTURE_2D); // set alignment as default is 4 which will break some files - if ((image_width * image_bytes) % 8 == 0) - gl_alignment=8; - else if ((image_width * image_bytes) % 4 == 0) - gl_alignment=4; - else if ((image_width * image_bytes) % 2 == 0) - gl_alignment=2; - else - gl_alignment=1; - glPixelStorei (GL_UNPACK_ALIGNMENT, gl_alignment); + glAdjustAlignment(image_width * image_bytes); mp_msg(MSGT_VO, MSGL_V, "[gl] Creating %dx%d texture...\n",texture_width,texture_height); @@ -330,7 +322,8 @@ unsigned char *src, unsigned char *srca, int stride) { - int sx = 1, sy = 1; + // initialize to 8 to avoid special-casing on alignment + int sx = 8, sy = 8; GLfloat xcov, ycov; char *clearTexture; while (sx < w) sx *= 2; @@ -346,16 +339,16 @@ memset(clearTexture, 0, sx * sy); // create Textures for OSD part + glAdjustAlignment(stride); + glPixelStorei(GL_UNPACK_ROW_LENGTH, stride); glGenTextures(1, &osdtex[osdtexCnt]); glBindTexture(GL_TEXTURE_2D, osdtex[osdtexCnt]); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, sx, sy, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, clearTexture); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glPixelStorei(GL_UNPACK_ROW_LENGTH, stride); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_LUMINANCE, GL_UNSIGNED_BYTE, src); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); #ifndef FAST_OSD glGenTextures(1, &osdatex[osdtexCnt]); @@ -364,11 +357,11 @@ GL_LUMINANCE, GL_UNSIGNED_BYTE, clearTexture); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glPixelStorei(GL_UNPACK_ROW_LENGTH, stride); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_ALPHA, GL_UNSIGNED_BYTE, srca); +#endif glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); -#endif + glAdjustAlignment(image_width * image_bytes); glBindTexture(GL_TEXTURE_2D, 0); free(clearTexture);