Mercurial > mplayer.hg
comparison libvo/vo_gl.c @ 31022:d31b184c7c3a
SDL support with related crash-resilience fixes.
author | reimar |
---|---|
date | Sat, 24 Apr 2010 16:52:06 +0000 |
parents | 38a0aa0ac675 |
children | 769929c96d44 |
comparison
equal
deleted
inserted
replaced
31021:b25ae678c778 | 31022:d31b184c7c3a |
---|---|
34 #ifdef CONFIG_GUI | 34 #ifdef CONFIG_GUI |
35 #include "gui/interface.h" | 35 #include "gui/interface.h" |
36 #endif | 36 #endif |
37 #include "fastmemcpy.h" | 37 #include "fastmemcpy.h" |
38 #include "libass/ass_mp.h" | 38 #include "libass/ass_mp.h" |
39 | |
40 #ifdef CONFIG_GL_SDL | |
41 #ifdef CONFIG_SDL_SDL_H | |
42 #include <SDL/SDL.h> | |
43 #else | |
44 #include <SDL.h> | |
45 #endif | |
46 #endif | |
39 | 47 |
40 static const vo_info_t info = | 48 static const vo_info_t info = |
41 { | 49 { |
42 "OpenGL", | 50 "OpenGL", |
43 "gl", | 51 "gl", |
467 | 475 |
468 static void autodetectGlExtensions(void) { | 476 static void autodetectGlExtensions(void) { |
469 const char *extensions = mpglGetString(GL_EXTENSIONS); | 477 const char *extensions = mpglGetString(GL_EXTENSIONS); |
470 const char *vendor = mpglGetString(GL_VENDOR); | 478 const char *vendor = mpglGetString(GL_VENDOR); |
471 const char *version = mpglGetString(GL_VERSION); | 479 const char *version = mpglGetString(GL_VERSION); |
472 int is_ati = strstr(vendor, "ATI") != NULL; | 480 int is_ati = vendor && strstr(vendor, "ATI") != NULL; |
473 int ati_broken_pbo = 0; | 481 int ati_broken_pbo = 0; |
474 mp_msg(MSGT_VO, MSGL_V, "[gl] Running on OpenGL by '%s', versions '%s'\n", vendor, version); | 482 mp_msg(MSGT_VO, MSGL_V, "[gl] Running on OpenGL by '%s', versions '%s'\n", vendor, version); |
475 if (is_ati && strncmp(version, "2.1.", 4) == 0) { | 483 if (is_ati && strncmp(version, "2.1.", 4) == 0) { |
476 int ver = atoi(version + 4); | 484 int ver = atoi(version + 4); |
477 mp_msg(MSGT_VO, MSGL_V, "[gl] Detected ATI driver version: %i\n", ver); | 485 mp_msg(MSGT_VO, MSGL_V, "[gl] Detected ATI driver version: %i\n", ver); |
478 ati_broken_pbo = ver && ver < 8395; | 486 ati_broken_pbo = ver && ver < 8395; |
479 } | 487 } |
480 if (ati_hack == -1) ati_hack = ati_broken_pbo; | 488 if (ati_hack == -1) ati_hack = ati_broken_pbo; |
481 if (force_pbo == -1) force_pbo = strstr(extensions, "_pixel_buffer_object") ? is_ati : 0; | 489 if (extensions && force_pbo == -1) |
482 if (use_rectangle == -1) use_rectangle = strstr(extensions, "_texture_non_power_of_two") ? 0 : 0; | 490 force_pbo = strstr(extensions, "_pixel_buffer_object") ? is_ati : 0; |
491 if (extensions && use_rectangle == -1) | |
492 use_rectangle = strstr(extensions, "_texture_non_power_of_two") ? 0 : 0; | |
483 if (use_yuv == -1) | 493 if (use_yuv == -1) |
484 use_yuv = glAutodetectYUVConversion(); | 494 use_yuv = glAutodetectYUVConversion(); |
485 if (is_ati && (lscale == 1 || lscale == 2 || cscale == 1 || cscale == 2)) | 495 if (is_ati && (lscale == 1 || lscale == 2 || cscale == 1 || cscale == 2)) |
486 mp_msg(MSGT_VO, MSGL_WARN, "[gl] Selected scaling mode may be broken on ATI cards.\n" | 496 mp_msg(MSGT_VO, MSGL_WARN, "[gl] Selected scaling mode may be broken on ATI cards.\n" |
487 "Tell _them_ to fix GL_REPEAT if you have issues.\n"); | 497 "Tell _them_ to fix GL_REPEAT if you have issues.\n"); |
580 mp_msg(MSGT_VO, MSGL_V, "[gl] GLX chose visual with ID 0x%x\n", (int)vinfo->visualid); | 590 mp_msg(MSGT_VO, MSGL_V, "[gl] GLX chose visual with ID 0x%x\n", (int)vinfo->visualid); |
581 | 591 |
582 vo_x11_create_vo_window(vinfo, vo_dx, vo_dy, d_width, d_height, flags, | 592 vo_x11_create_vo_window(vinfo, vo_dx, vo_dy, d_width, d_height, flags, |
583 XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone), | 593 XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone), |
584 "gl", title); | 594 "gl", title); |
595 } | |
596 #endif | |
597 #ifdef CONFIG_GL_SDL | |
598 if (glctx.type == GLTYPE_SDL) { | |
599 SDL_Surface *s = SDL_SetVideoMode(d_width, d_height, 0, SDL_OPENGL | SDL_RESIZABLE); | |
600 if (!s) { | |
601 mp_msg(MSGT_VO, MSGL_FATAL, "SDL SetVideoMode failed: %s\n", SDL_GetError()); | |
602 return -1; | |
603 } | |
604 vo_dwidth = s->w; | |
605 vo_dheight = s->h; | |
585 } | 606 } |
586 #endif | 607 #endif |
587 return 0; | 608 return 0; |
588 } | 609 } |
589 | 610 |
1074 {NULL} | 1095 {NULL} |
1075 }; | 1096 }; |
1076 | 1097 |
1077 static int preinit_internal(const char *arg, int allow_sw) | 1098 static int preinit_internal(const char *arg, int allow_sw) |
1078 { | 1099 { |
1079 enum MPGLType gltype = GLTYPE_X11; | 1100 enum MPGLType gltype = GLTYPE_SDL; |
1080 // set defaults | 1101 // set defaults |
1102 #ifdef CONFIG_GL_X11 | |
1103 gltype = GLTYPE_X11; | |
1104 #endif | |
1081 #ifdef CONFIG_GL_WIN32 | 1105 #ifdef CONFIG_GL_WIN32 |
1082 gltype = GLTYPE_W32; | 1106 gltype = GLTYPE_W32; |
1083 #endif | 1107 #endif |
1084 many_fmts = 1; | 1108 many_fmts = 1; |
1085 use_osd = 1; | 1109 use_osd = 1; |
1315 update_yuvconv(); | 1339 update_yuvconv(); |
1316 return VO_TRUE; | 1340 return VO_TRUE; |
1317 } | 1341 } |
1318 break; | 1342 break; |
1319 case VOCTRL_UPDATE_SCREENINFO: | 1343 case VOCTRL_UPDATE_SCREENINFO: |
1344 if (!glctx.update_xinerama_info) | |
1345 break; | |
1320 glctx.update_xinerama_info(); | 1346 glctx.update_xinerama_info(); |
1321 return VO_TRUE; | 1347 return VO_TRUE; |
1322 } | 1348 } |
1323 return VO_NOTIMPL; | 1349 return VO_NOTIMPL; |
1324 } | 1350 } |