25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

96 lines
1.6 KiB

  1. //
  2. // Deus Hax (working title)
  3. // Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
  4. //
  5. #if defined HAVE_CONFIG_H
  6. # include "config.h"
  7. #endif
  8. #include <cstdio>
  9. #include <cstring>
  10. #if defined USE_PIPI
  11. # include <pipi.h>
  12. #endif
  13. #include "core.h"
  14. #include "debugrecord.h"
  15. /*
  16. * DebugRecord implementation class
  17. */
  18. class DebugRecordData
  19. {
  20. friend class DebugRecord;
  21. private:
  22. char const *path;
  23. int width, height;
  24. #if defined USE_PIPI
  25. pipi_sequence_t *sequence;
  26. #endif
  27. };
  28. /*
  29. * Public DebugRecord class
  30. */
  31. DebugRecord::DebugRecord(char const *path)
  32. {
  33. data = new DebugRecordData();
  34. data->path = strdup(path);
  35. data->width = 0;
  36. data->height = 0;
  37. #if defined USE_PIPI
  38. data->sequence = NULL;
  39. #endif
  40. }
  41. Entity::Group DebugRecord::GetGroup()
  42. {
  43. return GROUP_DRAW_CAPTURE;
  44. }
  45. void DebugRecord::TickGame(float deltams)
  46. {
  47. Entity::TickGame(deltams);
  48. }
  49. void DebugRecord::TickDraw(float deltams)
  50. {
  51. Entity::TickDraw(deltams);
  52. int width = Video::GetWidth();
  53. int height = Video::GetHeight();
  54. if (data->width != width || data->height != height)
  55. {
  56. data->width = width;
  57. data->height = height;
  58. #if defined USE_PIPI
  59. if (data->sequence)
  60. pipi_close_sequence(data->sequence);
  61. data->sequence = pipi_open_sequence(data->path, width, height, 30);
  62. #endif
  63. }
  64. #if defined USE_PIPI
  65. if (data->sequence)
  66. {
  67. uint32_t *buffer = new uint32_t[width * height];
  68. Video::Capture(buffer);
  69. pipi_feed_sequence(data->sequence, (uint8_t *)buffer, width, height);
  70. delete[] buffer;
  71. }
  72. #endif
  73. }
  74. DebugRecord::~DebugRecord()
  75. {
  76. delete data;
  77. }