test/testoverlay2.c
changeset 753 b14fdadd8311
parent 673 63419da96d13
child 886 05c551e5bc64
equal deleted inserted replaced
752:4bb432a0f6e0 753:b14fdadd8311
   273     SDL_Overlay* overlay;
   273     SDL_Overlay* overlay;
   274     SDL_Rect overlayrect;
   274     SDL_Rect overlayrect;
   275     SDL_Event event;
   275     SDL_Event event;
   276     Uint32 lastftick;
   276     Uint32 lastftick;
   277     int paused=0;
   277     int paused=0;
       
   278     int resized=0;
   278     int i;
   279     int i;
   279     int fps=12;
   280     int fps=12;
   280     int fpsdelay;
   281     int fpsdelay;
   281     int overlay_format=SDL_YUY2_OVERLAY;
   282     int overlay_format=SDL_YUY2_OVERLAY;
   282     int scale=5;
   283     int scale=5;
   503             {
   504             {
   504                 case SDL_VIDEORESIZE:
   505                 case SDL_VIDEORESIZE:
   505                      screen=SDL_SetVideoMode(event.resize.w, event.resize.h, 0, SDL_RESIZABLE | SDL_SWSURFACE);
   506                      screen=SDL_SetVideoMode(event.resize.w, event.resize.h, 0, SDL_RESIZABLE | SDL_SWSURFACE);
   506                      overlayrect.w=event.resize.w;
   507                      overlayrect.w=event.resize.w;
   507                      overlayrect.h=event.resize.h;
   508                      overlayrect.h=event.resize.h;
       
   509                      if (paused)
       
   510                      {
       
   511                          resized=1;
       
   512                      }
   508                      break;
   513                      break;
   509                 case SDL_KEYDOWN:
   514                 case SDL_KEYDOWN:
   510                      if (event.key.keysym.sym == SDLK_SPACE)
   515                      if (event.key.keysym.sym == SDLK_SPACE)
   511                      {
   516                      {
   512                          paused=!paused;
   517                          paused=!paused;
   524                      }
   529                      }
   525                      return 0;
   530                      return 0;
   526             }
   531             }
   527         }
   532         }
   528 
   533 
   529         if (!paused)
   534         if ((!paused)||(resized))
   530         {
   535         {
   531             if ((SDL_GetTicks()-lastftick)>fpsdelay)
   536             if (((SDL_GetTicks()-lastftick)>fpsdelay)||(resized))
   532             {
   537             {
   533                 lastftick=SDL_GetTicks();
   538                 lastftick=SDL_GetTicks();
   534 
   539 
   535                 switch (overlay_format)
   540                 switch (overlay_format)
   536                 {
   541                 {
   550                          ConvertRGBtoIYUV(MooseFrame[i], overlay, 0, 100);
   555                          ConvertRGBtoIYUV(MooseFrame[i], overlay, 0, 100);
   551                          break;
   556                          break;
   552                 }
   557                 }
   553 
   558 
   554                 SDL_DisplayYUVOverlay(overlay, &overlayrect);
   559                 SDL_DisplayYUVOverlay(overlay, &overlayrect);
   555                 i++;
   560                 if (!resized)
   556                 if (i==10)
   561                 {
   557                 {
   562                     i++;
   558                     i=0;
   563                     if (i==10)
       
   564                     {
       
   565                         i=0;
       
   566                     }
       
   567                 }
       
   568                 else
       
   569                 {
       
   570                     resized=0;
   559                 }
   571                 }
   560             }
   572             }
   561         }
   573         }
   562         /* kind of timeslice to OS */
   574         /* kind of timeslice to OS */
   563         SDL_Delay(1);
   575         SDL_Delay(1);