Mercurial > sdl-ios-xcode
comparison test/testoverlay2.c @ 5269:7ace5f8f432f
Initial pass at shader YV12 support - doesn't quite work yet.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 12 Feb 2011 00:25:02 -0800 |
parents | ec30f9d4c2a8 |
children | 07559b6cb64f |
comparison
equal
deleted
inserted
replaced
5268:e1122f31fec5 | 5269:7ace5f8f432f |
---|---|
358 int paused = 0; | 358 int paused = 0; |
359 int i, j; | 359 int i, j; |
360 int fps = 12; | 360 int fps = 12; |
361 int fpsdelay; | 361 int fpsdelay; |
362 int nodelay = 0; | 362 int nodelay = 0; |
363 int overlay_format = SDL_YUY2_OVERLAY; | 363 Uint32 pixel_format = SDL_PIXELFORMAT_YV12; |
364 int scale = 5; | 364 int scale = 5; |
365 SDL_bool done = SDL_FALSE; | 365 SDL_bool done = SDL_FALSE; |
366 | 366 |
367 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) { | 367 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) { |
368 fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); | 368 fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); |
395 argv += 1; | 395 argv += 1; |
396 argc -= 1; | 396 argc -= 1; |
397 } else if (strcmp(argv[1], "-format") == 0) { | 397 } else if (strcmp(argv[1], "-format") == 0) { |
398 if (argv[2]) { | 398 if (argv[2]) { |
399 if (!strcmp(argv[2], "YV12")) | 399 if (!strcmp(argv[2], "YV12")) |
400 overlay_format = SDL_YV12_OVERLAY; | 400 pixel_format = SDL_PIXELFORMAT_YV12; |
401 else if (!strcmp(argv[2], "IYUV")) | 401 else if (!strcmp(argv[2], "IYUV")) |
402 overlay_format = SDL_IYUV_OVERLAY; | 402 pixel_format = SDL_PIXELFORMAT_IYUV; |
403 else if (!strcmp(argv[2], "YUY2")) | 403 else if (!strcmp(argv[2], "YUY2")) |
404 overlay_format = SDL_YUY2_OVERLAY; | 404 pixel_format = SDL_PIXELFORMAT_YUY2; |
405 else if (!strcmp(argv[2], "UYVY")) | 405 else if (!strcmp(argv[2], "UYVY")) |
406 overlay_format = SDL_UYVY_OVERLAY; | 406 pixel_format = SDL_PIXELFORMAT_UYVY; |
407 else if (!strcmp(argv[2], "YVYU")) | 407 else if (!strcmp(argv[2], "YVYU")) |
408 overlay_format = SDL_YVYU_OVERLAY; | 408 pixel_format = SDL_PIXELFORMAT_YVYU; |
409 else { | 409 else { |
410 fprintf(stderr, | 410 fprintf(stderr, |
411 "The -format option %s is not recognized, see help for info.\n", | 411 "The -format option %s is not recognized, see help for info.\n", |
412 argv[2]); | 412 argv[2]); |
413 quit(10); | 413 quit(10); |
488 fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError()); | 488 fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError()); |
489 free(RawMooseData); | 489 free(RawMooseData); |
490 quit(4); | 490 quit(4); |
491 } | 491 } |
492 | 492 |
493 MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); | 493 MooseTexture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); |
494 if (!MooseTexture) { | 494 if (!MooseTexture) { |
495 fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError()); | 495 fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError()); |
496 free(RawMooseData); | 496 free(RawMooseData); |
497 quit(5); | 497 quit(5); |
498 } | 498 } |
567 SDL_Delay(fpsdelay); | 567 SDL_Delay(fpsdelay); |
568 | 568 |
569 if (!paused) { | 569 if (!paused) { |
570 i = (i + 1) % MOOSEFRAMES_COUNT; | 570 i = (i + 1) % MOOSEFRAMES_COUNT; |
571 | 571 |
572 SDL_UpdateTexture(MooseTexture, NULL, MooseFrame[i], MOOSEPIC_W*2); | 572 SDL_UpdateTexture(MooseTexture, NULL, MooseFrame[i], MOOSEPIC_W*SDL_BYTESPERPIXEL(pixel_format)); |
573 } | 573 } |
574 SDL_RenderClear(renderer); | 574 SDL_RenderClear(renderer); |
575 SDL_RenderCopy(renderer, MooseTexture, NULL, &displayrect); | 575 SDL_RenderCopy(renderer, MooseTexture, NULL, &displayrect); |
576 SDL_RenderPresent(renderer); | 576 SDL_RenderPresent(renderer); |
577 } | 577 } |