diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-10-17 13:28:22 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-10-17 13:28:22 +0000 |
commit | 0164758aa8879c8344d7191a9258f3aa32eb64d7 (patch) | |
tree | d8385a73af20cc68d9f5e8e3e4a3152f7bbb2f20 /libvo/vo_gl.c | |
parent | 4a1200b8ea558aaafcd368b62b8b3f74c825d25c (diff) | |
download | mpv-0164758aa8879c8344d7191a9258f3aa32eb64d7.tar.bz2 mpv-0164758aa8879c8344d7191a9258f3aa32eb64d7.tar.xz |
added gl_common for code used by both vo_gl.c and vo_gl2.c.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13654 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/vo_gl.c')
-rw-r--r-- | libvo/vo_gl.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index 666c3f7ba7..82376e65d3 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -21,6 +21,7 @@ #include <GL/gl.h> +#include "gl_common.h" #include "x11_common.h" #include "aspect.h" @@ -180,7 +181,6 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin XSizeHints hint; XVisualInfo *vinfo; XEvent xev; - GLint gl_alignment; // XGCValues xgcv; @@ -280,15 +280,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin 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 @@ static void create_osd_texture(int x0, int y0, int w, int h, 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 @@ static void create_osd_texture(int x0, int y0, int w, int h, 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 @@ static void create_osd_texture(int x0, int y0, int w, int h, 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); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); #endif + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glAdjustAlignment(image_width * image_bytes); glBindTexture(GL_TEXTURE_2D, 0); free(clearTexture); |