comparison libvo/vo_sdl.c @ 2249:48f0ac1e9d13

Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
author atmos4
date Thu, 18 Oct 2001 02:42:20 +0000
parents a7e539b11ba0
children c9876f5f4ac5
comparison
equal deleted inserted replaced
2248:13bbd8326efd 2249:48f0ac1e9d13
553 #endif 553 #endif
554 554
555 static void set_fullmode (int mode) { 555 static void set_fullmode (int mode) {
556 struct sdl_priv_s *priv = &sdl_priv; 556 struct sdl_priv_s *priv = &sdl_priv;
557 SDL_Surface *newsurface = NULL; 557 SDL_Surface *newsurface = NULL;
558 int newwidth = priv->dstwidth,
559 newheight= priv->dstheight;
560 558
561 /* if we haven't set a fullmode yet, default to the lowest res fullmode first */ 559 /* if we haven't set a fullmode yet, default to the lowest res fullmode first */
562 if(mode < 0) 560 if(mode < 0)
563 mode = priv->fullmode = findArrayEnd(priv->fullmodes) - 1; 561 mode = priv->fullmode = findArrayEnd(priv->fullmodes) - 1;
564 562
563 aspect_save_screenres(priv->fullmodes[mode]->w, priv->fullmodes[mode]->h);
564
565 /* calculate new video size/aspect */ 565 /* calculate new video size/aspect */
566 if(!priv->mode) { 566 if(!priv->mode) {
567 if(priv->fulltype&FS) { 567 if(priv->fulltype&FS) {
568 #ifdef HAVE_X11 568 #ifdef HAVE_X11
569 aspect(&newwidth, &newheight, priv->XWidth ? priv->XWidth : priv->dstwidth, priv->XHeight ? priv->XHeight : priv->dstheight); 569 aspect_save_screenres(priv->XWidth, priv->XHeight);
570 #else
571 aspect(&newwidth, &newheight, priv->dstwidth, priv->dstheight);
572 #endif 570 #endif
573 } else 571 }
574 if(priv->fulltype&VM) { 572 aspect(&priv->dstwidth, &priv->dstheight, A_ZOOM);
575 #ifdef HAVE_X11 573
576 aspect(&newwidth, &newheight, priv->dstwidth, (int)((float)priv->dstwidth*((float)priv->XHeight / (float)priv->XWidth)));
577 #else
578 aspect(&newwidth, &newheight, priv->dstwidth, priv->dstheight);
579 #endif
580 } else {
581 aspect(&newwidth, &newheight, priv->fullmodes[mode]->w, priv->fullmodes[mode]->h);
582 }
583 } 574 }
584 575
585 /* try to change to given fullscreenmode */ 576 /* try to change to given fullscreenmode */
586 newsurface = SDL_SetVideoMode(newwidth, newheight, priv->bpp, priv->sdlfullflags); 577 newsurface = SDL_SetVideoMode(priv->dstwidth, priv->dstheight, priv->bpp, priv->sdlfullflags);
587 578
588 /* if creation of new surface was successfull, save it and hide mouse cursor */ 579 /* if creation of new surface was successfull, save it and hide mouse cursor */
589 if(newsurface) { 580 if(newsurface) {
590 if (priv->surface) 581 if (priv->surface)
591 SDL_FreeSurface(priv->surface); 582 SDL_FreeSurface(priv->surface);
613 unsigned int sdl_format; 604 unsigned int sdl_format;
614 #ifdef HAVE_X11 605 #ifdef HAVE_X11
615 static Display *XDisplay; 606 static Display *XDisplay;
616 static int XScreen; 607 static int XScreen;
617 #endif 608 #endif
618 int newwidth, newheight; 609 aspect_save_orig(width,height);
610 aspect_save_prescale(d_width,d_height);
619 611
620 sdl_format = format; 612 sdl_format = format;
621 switch(format){ 613 switch(format){
622 case IMGFMT_YV12: 614 case IMGFMT_YV12:
623 if(verbose) printf("SDL: Using 0x%X (YV12) image format\n", format); break; 615 if(verbose) printf("SDL: Using 0x%X (YV12) image format\n", format); break;
699 691
700 priv->width = width; 692 priv->width = width;
701 priv->height = height; 693 priv->height = height;
702 priv->dstwidth = d_width ? d_width : width; 694 priv->dstwidth = d_width ? d_width : width;
703 priv->dstheight = d_height ? d_height : height; 695 priv->dstheight = d_height ? d_height : height;
704 newwidth = priv->dstwidth;
705 newheight = priv->dstheight;
706 696
707 /*priv->width = res.w; 697 /*priv->width = res.w;
708 priv->height = res.h;*/ 698 priv->height = res.h;*/
709 priv->format = format; 699 priv->format = format;
710 #ifdef HAVE_X11 700 #ifdef HAVE_X11
711 aspect(&newwidth, &newheight, priv->dstwidth, (int)((float)priv->dstwidth*((float)priv->XHeight / (float)priv->XWidth))); 701 aspect_save_screenres(priv->XWidth,priv->XHeight);
702 aspect(&priv->dstwidth,&priv->dstheight,A_NOZOOM);
712 #endif 703 #endif
713 priv->windowsize.w = newwidth; 704 priv->windowsize.w = priv->dstwidth;
714 priv->windowsize.h = newheight; 705 priv->windowsize.h = priv->dstheight;
715 706
716 /* bit 0 (0x01) means fullscreen (-fs) 707 /* bit 0 (0x01) means fullscreen (-fs)
717 * bit 1 (0x02) means mode switching (-vm) 708 * bit 1 (0x02) means mode switching (-vm)
718 * bit 2 (0x04) enables software scaling (-zoom) 709 * bit 2 (0x04) enables software scaling (-zoom)
719 * bit 3 (0x08) enables flipping (-flip) 710 * bit 3 (0x08) enables flipping (-flip)
724 if(verbose) printf("SDL: using flipped video (only with RGB/BGR/packed YUV)\n"); 715 if(verbose) printf("SDL: using flipped video (only with RGB/BGR/packed YUV)\n");
725 priv->flip = 1; 716 priv->flip = 1;
726 } 717 }
727 if(flags&FS) { 718 if(flags&FS) {
728 if(verbose) printf("SDL: setting zoomed fullscreen without modeswitching\n"); 719 if(verbose) printf("SDL: setting zoomed fullscreen without modeswitching\n");
729 printf("SDL: Info - please use -vm (unscaled) or -zoom (scaled) for best fullscreen experience\n"); 720 printf("SDL: Info - please use -vm or -zoom to switch to best resolution.\n");
730 priv->fulltype = FS; 721 priv->fulltype = FS;
731 set_fullmode(priv->fullmode); 722 set_fullmode(priv->fullmode);
732 /*if((priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlfullflags))) 723 /*if((priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlfullflags)))
733 SDL_ShowCursor(0);*/ 724 SDL_ShowCursor(0);*/
734 } else 725 } else
735 if(flags&VM) { 726 if(flags&VM) {
736 if(verbose) printf("SDL: setting nonzoomed fullscreen with modeswitching\n"); 727 if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n");
737 printf("SDL: Info - please use -zoom switch to scale video\n");
738 priv->fulltype = VM; 728 priv->fulltype = VM;
739 set_fullmode(priv->fullmode); 729 set_fullmode(priv->fullmode);
740 /*if((priv->surface = SDL_SetVideoMode (d_width ? d_width : width, d_height ? d_height : height, priv->bpp, priv->sdlfullflags))) 730 /*if((priv->surface = SDL_SetVideoMode (d_width ? d_width : width, d_height ? d_height : height, priv->bpp, priv->sdlfullflags)))
741 SDL_ShowCursor(0);*/ 731 SDL_ShowCursor(0);*/
742 } else 732 } else
743 if(flags&ZOOM) { 733 if(flags&ZOOM) {
744 if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n"); 734 if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n");
745 printf("SDL: Info - please use -vm switch instead if you don't want scaled video\n");
746 priv->fulltype = ZOOM; 735 priv->fulltype = ZOOM;
747 set_fullmode(priv->fullmode); 736 set_fullmode(priv->fullmode);
748 } 737 }
749 else { 738 else {
750 if((strcmp(priv->driver, "x11") == 0) || ((strcmp(priv->driver, "aalib") == 0) && priv->X)) { 739 if((strcmp(priv->driver, "x11") == 0) || ((strcmp(priv->driver, "aalib") == 0) && priv->X)) {
751 if(verbose) printf("SDL: setting windowed mode\n"); 740 if(verbose) printf("SDL: setting windowed mode\n");
752 priv->surface = SDL_SetVideoMode (newwidth, newheight, priv->bpp, priv->sdlflags); 741 priv->surface = SDL_SetVideoMode (priv->dstwidth, priv->dstheight, priv->bpp, priv->sdlflags);
753 } 742 }
754 else { 743 else {
755 if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n"); 744 if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n");
756 printf("SDL: Info - please use -vm switch instead if you don't want scaled video\n");
757 priv->fulltype = ZOOM; 745 priv->fulltype = ZOOM;
758 set_fullmode(priv->fullmode); 746 set_fullmode(priv->fullmode);
759 } 747 }
760 } 748 }
761 749
1090 if(verbose > 1) printf("SDL: Set fullscreen mode\n"); 1078 if(verbose > 1) printf("SDL: Set fullscreen mode\n");
1091 } 1079 }
1092 } 1080 }
1093 1081
1094 else if ( keypressed == SDLK_n ) { 1082 else if ( keypressed == SDLK_n ) {
1095 int newwidth = priv->dstwidth, newheight = priv->dstheight;
1096 #ifdef HAVE_X11 1083 #ifdef HAVE_X11
1097 aspect(&newwidth, &newheight, priv->dstwidth, (int)((float)priv->dstwidth*((float)priv->XHeight / (float)priv->XWidth))); 1084 aspect(&priv->dstwidth, &priv->dstheight,A_NOZOOM);
1098 #else
1099 aspect(&newwidth, &newheight, priv->dstwidth, priv->dstheight);
1100 #endif 1085 #endif
1101 if (priv->surface->w != newwidth || priv->surface->h != newheight) { 1086 if (priv->surface->w != priv->dstwidth || priv->surface->h != priv->dstheight) {
1102 priv->surface = SDL_SetVideoMode(newwidth, newheight, priv->bpp, priv->sdlflags); 1087 priv->surface = SDL_SetVideoMode(priv->dstwidth, priv->dstheight, priv->bpp, priv->sdlflags);
1103 priv->windowsize.w = priv->surface->w; 1088 priv->windowsize.w = priv->surface->w;
1104 priv->windowsize.h = priv->surface->h; 1089 priv->windowsize.h = priv->surface->h;
1105 if(verbose > 1) printf("SDL: Normal size\n"); 1090 if(verbose > 1) printf("SDL: Normal size\n");
1106 } else 1091 } else
1107 if (priv->surface->w != newwidth * 2 || priv->surface->h != newheight * 2) { 1092 if (priv->surface->w != priv->dstwidth * 2 || priv->surface->h != priv->dstheight * 2) {
1108 priv->surface = SDL_SetVideoMode(newwidth * 2, newheight * 2, priv->bpp, priv->sdlflags); 1093 priv->surface = SDL_SetVideoMode(priv->dstwidth * 2, priv->dstheight * 2, priv->bpp, priv->sdlflags);
1109 priv->windowsize.w = priv->surface->w; 1094 priv->windowsize.w = priv->surface->w;
1110 priv->windowsize.h = priv->surface->h; 1095 priv->windowsize.h = priv->surface->h;
1111 if(verbose > 1) printf("SDL: Double size\n"); 1096 if(verbose > 1) printf("SDL: Double size\n");
1112 } 1097 }
1113 } 1098 }