1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 09:02:38 +00:00

Lots of cosmetics for gl2

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23671 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2007-06-26 16:33:43 +00:00
parent 15d418e19b
commit 85f88efe84

View File

@ -170,8 +170,7 @@ static int initTextures(void)
gl_internal_format = getInternalFormat();
/* Test the max texture size */
do
{
do {
glTexImage2D (GL_PROXY_TEXTURE_2D, 0,
gl_internal_format,
texture_width, texture_height,
@ -192,8 +191,7 @@ static int initTextures(void)
mp_msg (MSGT_VO, MSGL_V, "[%dx%d] !\n", texture_height, texture_width);
if(texture_width < 64 || texture_height < 64)
{
if(texture_width < 64 || texture_height < 64) {
mp_msg (MSGT_VO, MSGL_FATAL, "[gl2] Give up .. usable texture size not avaiable, or texture config error !\n");
return -1;
}
@ -234,11 +232,8 @@ static int initTextures(void)
(int) texture_height);
tsq = texgrid;
for (y = 0; y < texnumy; y++)
{
for (x = 0; x < texnumx; x++)
{
for (y = 0; y < texnumy; y++) {
for (x = 0; x < texnumx; x++) {
tsq->fx = x * texpercx;
tsq->fy = y * texpercy;
tsq->fw = texpercx;
@ -288,11 +283,9 @@ static void resetTexturePointers(unsigned char *imageSource)
line_start = (unsigned char *) imageSource;
for (y = 0; y < texnumy; y++)
{
for (y = 0; y < texnumy; y++) {
texdata_start = line_start;
for (x = 0; x < texnumx; x++)
{
for (x = 0; x < texnumx; x++) {
tsq->texture = texdata_start;
texdata_start += texture_width * image_bytes;
tsq++;
@ -313,40 +306,29 @@ static void gl_set_bilinear (int val)
gl_bilinear=gl_bilinear%2;
/* no mipmap yet .. */
for (y = 0; y < texnumy; y++)
{
for (x = 0; x < texnumx; x++)
{
for (y = 0; y < texnumy; y++) {
for (x = 0; x < texnumx; x++) {
glBindTexture (GL_TEXTURE_2D, texgrid[y * texnumx + x].texobj);
switch (gl_bilinear)
{
switch (gl_bilinear) {
case 0:
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_MIN_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
mp_msg(MSGT_VO, MSGL_INFO, "[gl2] bilinear off\n");
break;
case 1:
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
mp_msg(MSGT_VO, MSGL_INFO, "[gl2] bilinear linear\n");
break;
case 2:
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
mp_msg(MSGT_VO, MSGL_INFO, "[gl2] bilinear mipmap nearest\n");
break;
case 3:
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
mp_msg(MSGT_VO, MSGL_INFO, "[gl2] bilinear mipmap linear\n");
break;
}
@ -358,16 +340,13 @@ static void gl_set_antialias (int val)
{
gl_antialias=val;
if (gl_antialias)
{
if (gl_antialias) {
glShadeModel (GL_SMOOTH);
glEnable (GL_POLYGON_SMOOTH);
glEnable (GL_LINE_SMOOTH);
glEnable (GL_POINT_SMOOTH);
mp_msg(MSGT_VO, MSGL_INFO, "[gl2] antialiasing on\n");
}
else
{
} else {
glShadeModel (GL_FLAT);
glDisable (GL_POLYGON_SMOOTH);
glDisable (GL_LINE_SMOOTH);
@ -386,13 +365,11 @@ static void drawTextureDisplay (void)
if (image_format == IMGFMT_YV12)
glEnableYUVConversion(GL_TEXTURE_2D, use_yuv);
for (y = 0; y < texnumy; y++)
{
for (y = 0; y < texnumy; y++) {
int thish = texture_height;
if (y == texnumy - 1 && image_height % texture_height)
thish = image_height % texture_height;
for (x = 0; x < texnumx; x++)
{
for (x = 0; x < texnumx; x++) {
int thisw = texture_width;
if (x == texnumx - 1 && image_width % texture_width)
thisw = image_width % texture_width;
@ -408,9 +385,7 @@ static void drawTextureDisplay (void)
if (texdirty) {
glUploadTex(GL_TEXTURE_2D, gl_bitmap_format, gl_bitmap_type,
square->texture, image_width * image_bytes,
0, 0,
thisw, thish,
0);
0, 0, thisw, thish, 0);
}
glDrawTex(square->fx, square->fy, square->fw, square->fh,
@ -428,8 +403,7 @@ static void drawTextureDisplay (void)
static void resize(int *x,int *y){
mp_msg(MSGT_VO,MSGL_V,"[gl2] Resize: %dx%d\n",*x,*y);
if( vo_fs )
{
if( vo_fs ) {
glClear(GL_COLOR_BUFFER_BIT);
aspect(x, y, A_ZOOM);
panscan_calc();
@ -551,8 +525,7 @@ static int config_glx(uint32_t width, uint32_t height, uint32_t d_width, uint32_
ButtonPressMask | ButtonReleaseMask | ExposureMask);
return 0;
}
if ( vo_window == None )
{
if ( vo_window == None ) {
XSizeHints hint;
XVisualInfo *vinfo, vinfo_buf;
XEvent xev;
@ -565,8 +538,7 @@ static int config_glx(uint32_t width, uint32_t height, uint32_t d_width, uint32_
/* Make the window */
vinfo = choose_glx_visual(mDisplay,mScreen,&vinfo_buf) < 0 ? NULL : &vinfo_buf;
if (vinfo == NULL)
{
if (vinfo == NULL) {
mp_msg(MSGT_VO, MSGL_FATAL, "[gl2] no GLX support present\n");
return -1;
}
@ -590,18 +562,15 @@ static int config_glx(uint32_t width, uint32_t height, uint32_t d_width, uint32_
XClearWindow(mDisplay,vo_window);
/* Wait for map. */
do
{
do {
XNextEvent(mDisplay, &xev);
}
while (xev.type != MapNotify || xev.xmap.event != vo_window);
} while (xev.type != MapNotify || xev.xmap.event != vo_window);
XSync(mDisplay, False);
//XSelectInput(mDisplay, vo_window, StructureNotifyMask); // !!!!
vo_x11_selectinput_witherr(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask
| ButtonPressMask | ButtonReleaseMask | ExposureMask
);
vo_x11_selectinput_witherr(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | ExposureMask);
}
vo_x11_nofs_sizepos(vo_dx, vo_dy, d_width, d_height);
if (vo_fs ^ (flags & VOFLAG_FULLSCREEN))
@ -705,18 +674,14 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
mp_msg(MSGT_VO, MSGL_V, "[gl2] OpenGL Driver Information:\n");
mp_msg(MSGT_VO, MSGL_V, "\tvendor: %s,\n\trenderer %s,\n\tversion %s\n",
glGetString(GL_VENDOR),
glGetString(GL_RENDERER),
glVersion);
glGetString(GL_VENDOR), glGetString(GL_RENDERER), glVersion);
if(glVersion[0]>'1' ||
(glVersion[0]=='1' && glVersion[2]>='2') )
if(glVersion[0]>'1' || (glVersion[0]=='1' && glVersion[2]>='2') )
isGL12 = GL_TRUE;
else
isGL12 = GL_FALSE;
if(isGL12)
{
if(isGL12) {
mp_msg(MSGT_VO, MSGL_INFO, "[gl2] You have OpenGL >= 1.2 capable drivers, GOOD (16bpp and BGR is ok!)\n");
} else {
mp_msg(MSGT_VO, MSGL_INFO, "[gl2] You have OpenGL < 1.2 drivers, BAD (16bpp and BGR may be damaged!)\n");
@ -728,14 +693,11 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
draw_alpha_fnc=draw_alpha_null;
switch(image_bpp)
{
switch(image_bpp) {
case 15:
draw_alpha_fnc=draw_alpha_15;
break;
draw_alpha_fnc=draw_alpha_15; break;
case 16:
draw_alpha_fnc=draw_alpha_16;
break;
draw_alpha_fnc=draw_alpha_16; break;
case 24:
draw_alpha_fnc=draw_alpha_24; break;
case 32:
@ -753,13 +715,10 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
static int gl_handlekey(int key)
{
if(key=='a'||key=='A')
{
if(key=='a'||key=='A') {
gl_set_antialias(!gl_antialias);
return 0;
}
else if(key=='b'||key=='B')
{
} else if(key=='b'||key=='B') {
gl_set_bilinear(-1);
return 0;
}
@ -776,15 +735,11 @@ static void check_events(void)
int key;
static XComposeStatus stat;
while ( XPending( mDisplay ) )
{
while ( XPending( mDisplay ) ) {
XNextEvent( mDisplay,&Event );
if( Event.type == KeyPress )
{
if( Event.type == KeyPress ) {
XLookupString( &Event.xkey,buf,sizeof(buf),&keySym,&stat );
key = (keySym&0xff00) != 0? ( (keySym&0x00ff) + 256 )
: ( keySym ) ;
key = (keySym&0xff00) != 0 ? (keySym&0x00ff) + 256 : keySym;
if(gl_handlekey(key))
XPutBackEvent(mDisplay, &Event);
break;
@ -808,7 +763,6 @@ static void draw_osd(void)
static void
flip_page(void)
{
drawTextureDisplay();
// glFlush();
@ -887,7 +841,7 @@ draw_frame(uint8_t *src[])
static int
query_format(uint32_t format)
{
switch(format){
switch(format) {
case IMGFMT_YV12:
if (use_yuv)
return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD |