test_bdf.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "si_test.h"
  2. #include "gy.h"
  3. #include <time.h>
  4. #define CLOSE_TIME 3
  5. TEST_FUNC(gynofont) {
  6. GyGame * game;
  7. GyScreen * screen;
  8. GyBdf * bdfe, *bdfj;
  9. time_t time_now = 0, time_start = time(NULL);
  10. game = gygame_make();
  11. TEST_NOTNULL(game);
  12. screen = gygame_openscreen(game, 640, 480, 0);
  13. bdfj = gybdf_load("../../data/font/18x18ja.bdf");
  14. bdfe = gybdf_load("../../data/font/10x20.bdf");
  15. TEST_NOTNULL(screen);
  16. TEST_NOTNULL(bdfj);
  17. TEST_NOTNULL(bdfe);
  18. TEST_NOTNULL(gybdf_find(bdfj, 'A'));
  19. TEST_NOTNULL(gybdf_find(bdfe, 'A'));
  20. do {
  21. GyEvent ev;
  22. while (gyevent_fetch(&ev)) {
  23. if(ev.kind == GY_EVENT_QUIT) goto all_done;
  24. time_start = time(NULL);
  25. }
  26. gybdf_putc(gyscreen_image(screen), 200, 200, 'B', bdfj, GyWhite, GyBlack);
  27. gybdf_putc(gyscreen_image(screen), 300, 300, 'B', bdfe, GyWhite, GyBlack);
  28. gygame_nextframe(game);
  29. gygame_update(game);
  30. time_now = time(NULL);
  31. } while (difftime(time_now, time_start) < CLOSE_TIME);
  32. all_done:
  33. /*Program * prog = program_new(640, 480, FALSE);
  34. TEST_NOTNULL(prog);
  35. program_free(prog);
  36. */
  37. gybdf_free(bdfj);
  38. gybdf_free(bdfe);
  39. gygame_free(game);
  40. TEST_DONE();
  41. }
  42. int main(void) {
  43. TEST_INIT();
  44. TEST_RUN(gynofont);
  45. TEST_REPORT();
  46. }