mirror of
https://github.com/mpv-player/mpv
synced 2025-04-28 14:20:05 +00:00
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
This commit is contained in:
parent
4a1200b8ea
commit
0164758aa8
4
configure
vendored
4
configure
vendored
@ -3526,9 +3526,9 @@ if test "$_gl" = yes ; then
|
|||||||
_def_gl='#define HAVE_GL 1'
|
_def_gl='#define HAVE_GL 1'
|
||||||
if test "$_gl_win32" = yes ; then
|
if test "$_gl_win32" = yes ; then
|
||||||
_def_gl_win32='#define GL_WIN32 1'
|
_def_gl_win32='#define GL_WIN32 1'
|
||||||
_vosrc="$_vosrc vo_gl2.c w32_common.c"
|
_vosrc="$_vosrc vo_gl2.c w32_common.c gl_common.c"
|
||||||
else
|
else
|
||||||
_vosrc="$_vosrc vo_gl.c vo_gl2.c"
|
_vosrc="$_vosrc vo_gl.c vo_gl2.c gl_common.c"
|
||||||
fi
|
fi
|
||||||
_vomodules="opengl $_vomodules"
|
_vomodules="opengl $_vomodules"
|
||||||
else
|
else
|
||||||
|
19
libvo/gl_common.c
Normal file
19
libvo/gl_common.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "gl_common.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief adjusts the GL_UNPACK_ALGNMENT to fit the stride.
|
||||||
|
* \param stride number of bytes per line for which alignment should fit.
|
||||||
|
*/
|
||||||
|
void glAdjustAlignment(int stride) {
|
||||||
|
GLint gl_alignment;
|
||||||
|
if (stride % 8 == 0)
|
||||||
|
gl_alignment=8;
|
||||||
|
else if (stride % 4 == 0)
|
||||||
|
gl_alignment=4;
|
||||||
|
else if (stride % 2 == 0)
|
||||||
|
gl_alignment=2;
|
||||||
|
else
|
||||||
|
gl_alignment=1;
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, gl_alignment);
|
||||||
|
}
|
||||||
|
|
8
libvo/gl_common.h
Normal file
8
libvo/gl_common.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef __GL_COMMON_H__
|
||||||
|
#define __GL_COMMON_H__
|
||||||
|
|
||||||
|
#include <GL/gl.h>
|
||||||
|
|
||||||
|
void glAdjustAlignment(int stride);
|
||||||
|
|
||||||
|
#endif
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
|
||||||
|
#include "gl_common.h"
|
||||||
#include "x11_common.h"
|
#include "x11_common.h"
|
||||||
#include "aspect.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;
|
XSizeHints hint;
|
||||||
XVisualInfo *vinfo;
|
XVisualInfo *vinfo;
|
||||||
XEvent xev;
|
XEvent xev;
|
||||||
GLint gl_alignment;
|
|
||||||
|
|
||||||
// XGCValues xgcv;
|
// 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);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
// set alignment as default is 4 which will break some files
|
// set alignment as default is 4 which will break some files
|
||||||
if ((image_width * image_bytes) % 8 == 0)
|
glAdjustAlignment(image_width * image_bytes);
|
||||||
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);
|
|
||||||
|
|
||||||
mp_msg(MSGT_VO, MSGL_V, "[gl] Creating %dx%d texture...\n",texture_width,texture_height);
|
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,
|
unsigned char *src, unsigned char *srca,
|
||||||
int stride)
|
int stride)
|
||||||
{
|
{
|
||||||
int sx = 1, sy = 1;
|
// initialize to 8 to avoid special-casing on alignment
|
||||||
|
int sx = 8, sy = 8;
|
||||||
GLfloat xcov, ycov;
|
GLfloat xcov, ycov;
|
||||||
char *clearTexture;
|
char *clearTexture;
|
||||||
while (sx < w) sx *= 2;
|
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);
|
memset(clearTexture, 0, sx * sy);
|
||||||
|
|
||||||
// create Textures for OSD part
|
// create Textures for OSD part
|
||||||
|
glAdjustAlignment(stride);
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, stride);
|
||||||
glGenTextures(1, &osdtex[osdtexCnt]);
|
glGenTextures(1, &osdtex[osdtexCnt]);
|
||||||
glBindTexture(GL_TEXTURE_2D, osdtex[osdtexCnt]);
|
glBindTexture(GL_TEXTURE_2D, osdtex[osdtexCnt]);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, sx, sy, 0,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, sx, sy, 0,
|
||||||
GL_LUMINANCE, GL_UNSIGNED_BYTE, clearTexture);
|
GL_LUMINANCE, GL_UNSIGNED_BYTE, clearTexture);
|
||||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_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,
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_LUMINANCE,
|
||||||
GL_UNSIGNED_BYTE, src);
|
GL_UNSIGNED_BYTE, src);
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
|
||||||
|
|
||||||
#ifndef FAST_OSD
|
#ifndef FAST_OSD
|
||||||
glGenTextures(1, &osdatex[osdtexCnt]);
|
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);
|
GL_LUMINANCE, GL_UNSIGNED_BYTE, clearTexture);
|
||||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_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,
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_ALPHA,
|
||||||
GL_UNSIGNED_BYTE, srca);
|
GL_UNSIGNED_BYTE, srca);
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
|
||||||
#endif
|
#endif
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
glAdjustAlignment(image_width * image_bytes);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
free(clearTexture);
|
free(clearTexture);
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "gl_common.h"
|
||||||
#ifdef GL_WIN32
|
#ifdef GL_WIN32
|
||||||
#include "w32_common.h"
|
#include "w32_common.h"
|
||||||
#else
|
#else
|
||||||
@ -96,7 +97,6 @@ static GLint gl_bitmap_format;
|
|||||||
static char * gl_bitmap_format_s;
|
static char * gl_bitmap_format_s;
|
||||||
static GLint gl_bitmap_type;
|
static GLint gl_bitmap_type;
|
||||||
static char * gl_bitmap_type_s;
|
static char * gl_bitmap_type_s;
|
||||||
static int gl_alignment;
|
|
||||||
static int isGL12 = GL_FALSE;
|
static int isGL12 = GL_FALSE;
|
||||||
|
|
||||||
static int gl_bilinear=1;
|
static int gl_bilinear=1;
|
||||||
@ -821,16 +821,7 @@ static int initGl(uint32_t d_width, uint32_t d_height)
|
|||||||
* may give a little speed up for a kinda burst read ..
|
* may give a little speed up for a kinda burst read ..
|
||||||
* Also, the default of 4 will break some files.
|
* Also, the default of 4 will break some files.
|
||||||
*/
|
*/
|
||||||
if( (image_width*image_bytes)%8 == 0 )
|
glAdjustAlignment(image_width*image_bytes);
|
||||||
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);
|
|
||||||
|
|
||||||
glEnable (GL_TEXTURE_2D);
|
glEnable (GL_TEXTURE_2D);
|
||||||
|
|
||||||
@ -842,9 +833,9 @@ static int initGl(uint32_t d_width, uint32_t d_height)
|
|||||||
free (ImageData);
|
free (ImageData);
|
||||||
ImageData = NULL;
|
ImageData = NULL;
|
||||||
|
|
||||||
mp_msg(MSGT_VO, MSGL_V, "[gl2] Using image_bpp=%d, image_bytes=%d, isBGR=%d, \n\tgl_bitmap_format=%s, gl_bitmap_type=%s, \n\tgl_alignment=%d, rgb_size=%d (%d,%d,%d), a_sz=%d, \n\tgl_internal_format=%s\n",
|
mp_msg(MSGT_VO, MSGL_V, "[gl2] Using image_bpp=%d, image_bytes=%d, isBGR=%d, \n\tgl_bitmap_format=%s, gl_bitmap_type=%s, \n\trgb_size=%d (%d,%d,%d), a_sz=%d, \n\tgl_internal_format=%s\n",
|
||||||
image_bpp, image_bytes, image_mode==MODE_BGR,
|
image_bpp, image_bytes, image_mode==MODE_BGR,
|
||||||
gl_bitmap_format_s, gl_bitmap_type_s, gl_alignment,
|
gl_bitmap_format_s, gl_bitmap_type_s,
|
||||||
rgb_sz, r_sz, g_sz, b_sz, a_sz, gl_internal_format_s);
|
rgb_sz, r_sz, g_sz, b_sz, a_sz, gl_internal_format_s);
|
||||||
|
|
||||||
resize(&d_width, &d_height);
|
resize(&d_width, &d_height);
|
||||||
|
Loading…
Reference in New Issue
Block a user