test/common.c
changeset 1965 a788656ca29a
parent 1957 c7803e4c21d3
child 1967 01e29c3e9a29
equal deleted inserted replaced
1964:071b6598d48f 1965:a788656ca29a
   168         }
   168         }
   169         state->refresh_rate = SDL_atoi(argv[index]);
   169         state->refresh_rate = SDL_atoi(argv[index]);
   170         return 2;
   170         return 2;
   171     }
   171     }
   172     if (SDL_strcasecmp(argv[index], "--vsync") == 0) {
   172     if (SDL_strcasecmp(argv[index], "--vsync") == 0) {
   173         state->render_flags |= SDL_Renderer_PresentVSync;
   173         state->render_flags |= SDL_RENDERER_PRESENTVSYNC;
   174         return 1;
   174         return 1;
   175     }
   175     }
   176     if (SDL_strcasecmp(argv[index], "--noframe") == 0) {
   176     if (SDL_strcasecmp(argv[index], "--noframe") == 0) {
   177         state->window_flags |= SDL_WINDOW_BORDERLESS;
   177         state->window_flags |= SDL_WINDOW_BORDERLESS;
   178         return 1;
   178         return 1;
   281 
   281 
   282 static void
   282 static void
   283 PrintRendererFlag(Uint32 flag)
   283 PrintRendererFlag(Uint32 flag)
   284 {
   284 {
   285     switch (flag) {
   285     switch (flag) {
   286     case SDL_Renderer_SingleBuffer:
   286     case SDL_RENDERER_SINGLEBUFFER:
   287         fprintf(stderr, "SingleBuffer");
   287         fprintf(stderr, "SingleBuffer");
   288         break;
   288         break;
   289     case SDL_Renderer_PresentCopy:
   289     case SDL_RENDERER_PRESENTCOPY:
   290         fprintf(stderr, "PresentCopy");
   290         fprintf(stderr, "PresentCopy");
   291         break;
   291         break;
   292     case SDL_Renderer_PresentFlip2:
   292     case SDL_RENDERER_PRESENTFLIP2:
   293         fprintf(stderr, "PresentFlip2");
   293         fprintf(stderr, "PresentFlip2");
   294         break;
   294         break;
   295     case SDL_Renderer_PresentFlip3:
   295     case SDL_RENDERER_PRESENTFLIP3:
   296         fprintf(stderr, "PresentFlip3");
   296         fprintf(stderr, "PresentFlip3");
   297         break;
   297         break;
   298     case SDL_Renderer_PresentDiscard:
   298     case SDL_RENDERER_PRESENTDISCARD:
   299         fprintf(stderr, "PresentDiscard");
   299         fprintf(stderr, "PresentDiscard");
   300         break;
   300         break;
   301     case SDL_Renderer_PresentVSync:
   301     case SDL_RENDERER_PRESENTVSYNC:
   302         fprintf(stderr, "PresentVSync");
   302         fprintf(stderr, "PresentVSync");
   303         break;
   303         break;
   304     case SDL_Renderer_Accelerated:
   304     case SDL_RENDERER_ACCELERATED:
   305         fprintf(stderr, "Accelerated");
   305         fprintf(stderr, "Accelerated");
   306         break;
   306         break;
   307     default:
   307     default:
   308         fprintf(stderr, "0x%8.8x", flag);
   308         fprintf(stderr, "0x%8.8x", flag);
   309         break;
   309         break;
   312 
   312 
   313 static void
   313 static void
   314 PrintBlendMode(Uint32 flag)
   314 PrintBlendMode(Uint32 flag)
   315 {
   315 {
   316     switch (flag) {
   316     switch (flag) {
   317     case SDL_TextureBlendMode_None:
   317     case SDL_TEXTUREBLENDMODE_NONE:
   318         fprintf(stderr, "None");
   318         fprintf(stderr, "None");
   319         break;
   319         break;
   320     case SDL_TextureBlendMode_Mask:
   320     case SDL_TEXTUREBLENDMODE_MASK:
   321         fprintf(stderr, "Mask");
   321         fprintf(stderr, "Mask");
   322         break;
   322         break;
   323     case SDL_TextureBlendMode_Blend:
   323     case SDL_TEXTUREBLENDMODE_BLEND:
   324         fprintf(stderr, "Blend");
   324         fprintf(stderr, "Blend");
   325         break;
   325         break;
   326     case SDL_TextureBlendMode_Add:
   326     case SDL_TEXTUREBLENDMODE_ADD:
   327         fprintf(stderr, "Add");
   327         fprintf(stderr, "Add");
   328         break;
   328         break;
   329     case SDL_TextureBlendMode_Mod:
   329     case SDL_TEXTUREBLENDMODE_MOD:
   330         fprintf(stderr, "Mod");
   330         fprintf(stderr, "Mod");
   331         break;
   331         break;
   332     default:
   332     default:
   333         fprintf(stderr, "0x%8.8x", flag);
   333         fprintf(stderr, "0x%8.8x", flag);
   334         break;
   334         break;
   337 
   337 
   338 static void
   338 static void
   339 PrintScaleMode(Uint32 flag)
   339 PrintScaleMode(Uint32 flag)
   340 {
   340 {
   341     switch (flag) {
   341     switch (flag) {
   342     case SDL_TextureScaleMode_None:
   342     case SDL_TEXTURESCALEMODE_NONE:
   343         fprintf(stderr, "None");
   343         fprintf(stderr, "None");
   344         break;
   344         break;
   345     case SDL_TextureScaleMode_Fast:
   345     case SDL_TEXTURESCALEMODE_FAST:
   346         fprintf(stderr, "Fast");
   346         fprintf(stderr, "Fast");
   347         break;
   347         break;
   348     case SDL_TextureScaleMode_Slow:
   348     case SDL_TEXTURESCALEMODE_SLOW:
   349         fprintf(stderr, "Slow");
   349         fprintf(stderr, "Slow");
   350         break;
   350         break;
   351     case SDL_TextureScaleMode_Best:
   351     case SDL_TEXTURESCALEMODE_BEST:
   352         fprintf(stderr, "Best");
   352         fprintf(stderr, "Best");
   353         break;
   353         break;
   354     default:
   354     default:
   355         fprintf(stderr, "0x%8.8x", flag);
   355         fprintf(stderr, "0x%8.8x", flag);
   356         break;
   356         break;
   359 
   359 
   360 static void
   360 static void
   361 PrintPixelFormat(Uint32 format)
   361 PrintPixelFormat(Uint32 format)
   362 {
   362 {
   363     switch (format) {
   363     switch (format) {
   364     case SDL_PixelFormat_Unknown:
   364     case SDL_PIXELFORMAT_UNKNOWN:
   365         fprintf(stderr, "Unknwon");
   365         fprintf(stderr, "Unknwon");
   366         break;
   366         break;
   367     case SDL_PixelFormat_Index1LSB:
   367     case SDL_PIXELFORMAT_INDEX1LSB:
   368         fprintf(stderr, "Index1LSB");
   368         fprintf(stderr, "Index1LSB");
   369         break;
   369         break;
   370     case SDL_PixelFormat_Index1MSB:
   370     case SDL_PIXELFORMAT_INDEX1MSB:
   371         fprintf(stderr, "Index1MSB");
   371         fprintf(stderr, "Index1MSB");
   372         break;
   372         break;
   373     case SDL_PixelFormat_Index4LSB:
   373     case SDL_PIXELFORMAT_INDEX4LSB:
   374         fprintf(stderr, "Index4LSB");
   374         fprintf(stderr, "Index4LSB");
   375         break;
   375         break;
   376     case SDL_PixelFormat_Index4MSB:
   376     case SDL_PIXELFORMAT_INDEX4MSB:
   377         fprintf(stderr, "Index4MSB");
   377         fprintf(stderr, "Index4MSB");
   378         break;
   378         break;
   379     case SDL_PixelFormat_Index8:
   379     case SDL_PIXELFORMAT_INDEX8:
   380         fprintf(stderr, "Index8");
   380         fprintf(stderr, "Index8");
   381         break;
   381         break;
   382     case SDL_PixelFormat_RGB332:
   382     case SDL_PIXELFORMAT_RGB332:
   383         fprintf(stderr, "RGB332");
   383         fprintf(stderr, "RGB332");
   384         break;
   384         break;
   385     case SDL_PixelFormat_RGB444:
   385     case SDL_PIXELFORMAT_RGB444:
   386         fprintf(stderr, "RGB444");
   386         fprintf(stderr, "RGB444");
   387         break;
   387         break;
   388     case SDL_PixelFormat_RGB555:
   388     case SDL_PIXELFORMAT_RGB555:
   389         fprintf(stderr, "RGB555");
   389         fprintf(stderr, "RGB555");
   390         break;
   390         break;
   391     case SDL_PixelFormat_ARGB4444:
   391     case SDL_PIXELFORMAT_ARGB4444:
   392         fprintf(stderr, "ARGB4444");
   392         fprintf(stderr, "ARGB4444");
   393         break;
   393         break;
   394     case SDL_PixelFormat_ARGB1555:
   394     case SDL_PIXELFORMAT_ARGB1555:
   395         fprintf(stderr, "ARGB1555");
   395         fprintf(stderr, "ARGB1555");
   396         break;
   396         break;
   397     case SDL_PixelFormat_RGB565:
   397     case SDL_PIXELFORMAT_RGB565:
   398         fprintf(stderr, "RGB565");
   398         fprintf(stderr, "RGB565");
   399         break;
   399         break;
   400     case SDL_PixelFormat_RGB24:
   400     case SDL_PIXELFORMAT_RGB24:
   401         fprintf(stderr, "RGB24");
   401         fprintf(stderr, "RGB24");
   402         break;
   402         break;
   403     case SDL_PixelFormat_BGR24:
   403     case SDL_PIXELFORMAT_BGR24:
   404         fprintf(stderr, "BGR24");
   404         fprintf(stderr, "BGR24");
   405         break;
   405         break;
   406     case SDL_PixelFormat_RGB888:
   406     case SDL_PIXELFORMAT_RGB888:
   407         fprintf(stderr, "RGB888");
   407         fprintf(stderr, "RGB888");
   408         break;
   408         break;
   409     case SDL_PixelFormat_BGR888:
   409     case SDL_PIXELFORMAT_BGR888:
   410         fprintf(stderr, "BGR888");
   410         fprintf(stderr, "BGR888");
   411         break;
   411         break;
   412     case SDL_PixelFormat_ARGB8888:
   412     case SDL_PIXELFORMAT_ARGB8888:
   413         fprintf(stderr, "ARGB8888");
   413         fprintf(stderr, "ARGB8888");
   414         break;
   414         break;
   415     case SDL_PixelFormat_RGBA8888:
   415     case SDL_PIXELFORMAT_RGBA8888:
   416         fprintf(stderr, "RGBA8888");
   416         fprintf(stderr, "RGBA8888");
   417         break;
   417         break;
   418     case SDL_PixelFormat_ABGR8888:
   418     case SDL_PIXELFORMAT_ABGR8888:
   419         fprintf(stderr, "ABGR8888");
   419         fprintf(stderr, "ABGR8888");
   420         break;
   420         break;
   421     case SDL_PixelFormat_BGRA8888:
   421     case SDL_PIXELFORMAT_BGRA8888:
   422         fprintf(stderr, "BGRA8888");
   422         fprintf(stderr, "BGRA8888");
   423         break;
   423         break;
   424     case SDL_PixelFormat_ARGB2101010:
   424     case SDL_PIXELFORMAT_ARGB2101010:
   425         fprintf(stderr, "ARGB2101010");
   425         fprintf(stderr, "ARGB2101010");
   426         break;
   426         break;
   427     case SDL_PixelFormat_YV12:
   427     case SDL_PIXELFORMAT_YV12:
   428         fprintf(stderr, "YV12");
   428         fprintf(stderr, "YV12");
   429         break;
   429         break;
   430     case SDL_PixelFormat_IYUV:
   430     case SDL_PIXELFORMAT_IYUV:
   431         fprintf(stderr, "IYUV");
   431         fprintf(stderr, "IYUV");
   432         break;
   432         break;
   433     case SDL_PixelFormat_YUY2:
   433     case SDL_PIXELFORMAT_YUY2:
   434         fprintf(stderr, "YUY2");
   434         fprintf(stderr, "YUY2");
   435         break;
   435         break;
   436     case SDL_PixelFormat_UYVY:
   436     case SDL_PIXELFORMAT_UYVY:
   437         fprintf(stderr, "UYVY");
   437         fprintf(stderr, "UYVY");
   438         break;
   438         break;
   439     case SDL_PixelFormat_YVYU:
   439     case SDL_PIXELFORMAT_YVYU:
   440         fprintf(stderr, "YVYU");
   440         fprintf(stderr, "YVYU");
   441         break;
   441         break;
   442     default:
   442     default:
   443         fprintf(stderr, "0x%8.8x", format);
   443         fprintf(stderr, "0x%8.8x", format);
   444         break;
   444         break;
   615             }
   615             }
   616         }
   616         }
   617 
   617 
   618         switch (state->depth) {
   618         switch (state->depth) {
   619         case 8:
   619         case 8:
   620             fullscreen_mode.format = SDL_PixelFormat_Index8;
   620             fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8;
   621             break;
   621             break;
   622         case 15:
   622         case 15:
   623             fullscreen_mode.format = SDL_PixelFormat_RGB555;
   623             fullscreen_mode.format = SDL_PIXELFORMAT_RGB555;
   624             break;
   624             break;
   625         case 16:
   625         case 16:
   626             fullscreen_mode.format = SDL_PixelFormat_RGB565;
   626             fullscreen_mode.format = SDL_PIXELFORMAT_RGB565;
   627             break;
   627             break;
   628         default:
   628         default:
   629             fullscreen_mode.format = SDL_PixelFormat_RGB888;
   629             fullscreen_mode.format = SDL_PIXELFORMAT_RGB888;
   630             break;
   630             break;
   631         }
   631         }
   632         fullscreen_mode.w = state->window_w;
   632         fullscreen_mode.w = state->window_w;
   633         fullscreen_mode.h = state->window_h;
   633         fullscreen_mode.h = state->window_h;
   634         fullscreen_mode.refresh_rate = state->refresh_rate;
   634         fullscreen_mode.refresh_rate = state->refresh_rate;
   907         }
   907         }
   908         break;
   908         break;
   909     case SDL_KEYDOWN:
   909     case SDL_KEYDOWN:
   910         switch (event->key.keysym.sym) {
   910         switch (event->key.keysym.sym) {
   911             /* Add hotkeys here */
   911             /* Add hotkeys here */
       
   912         case SDLK_g:
       
   913             if (event->key.keysym.mod & KMOD_CTRL) {
       
   914                 /* Ctrl-G toggle grab */
       
   915             }
       
   916             break;
   912         case SDLK_ESCAPE:
   917         case SDLK_ESCAPE:
   913             *done = 1;
   918             *done = 1;
   914             break;
   919             break;
   915         default:
   920         default:
   916             break;
   921             break;