Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

98 righe
1.8 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://sam.zoy.org/projects/COPYING.WTFPL for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include <cstdio>
  14. #include <cstring>
  15. #if defined USE_PIPI
  16. # include <pipi.h>
  17. #endif
  18. #include "core.h"
  19. #include "debugrecord.h"
  20. /*
  21. * DebugRecord implementation class
  22. */
  23. class DebugRecordData
  24. {
  25. friend class DebugRecord;
  26. private:
  27. char const *path;
  28. int width, height;
  29. #if defined USE_PIPI
  30. pipi_sequence_t *sequence;
  31. #endif
  32. };
  33. /*
  34. * Public DebugRecord class
  35. */
  36. DebugRecord::DebugRecord(char const *path)
  37. : data(new DebugRecordData())
  38. {
  39. data->path = strdup(path);
  40. data->width = 0;
  41. data->height = 0;
  42. #if defined USE_PIPI
  43. data->sequence = NULL;
  44. #endif
  45. drawgroup = DRAWGROUP_CAPTURE;
  46. }
  47. void DebugRecord::TickGame(float deltams)
  48. {
  49. Entity::TickGame(deltams);
  50. }
  51. void DebugRecord::TickDraw(float deltams)
  52. {
  53. Entity::TickDraw(deltams);
  54. int width = Video::GetWidth();
  55. int height = Video::GetHeight();
  56. if (data->width != width || data->height != height)
  57. {
  58. data->width = width;
  59. data->height = height;
  60. #if defined USE_PIPI
  61. if (data->sequence)
  62. pipi_close_sequence(data->sequence);
  63. data->sequence = pipi_open_sequence(data->path, width, height, 30);
  64. #endif
  65. }
  66. #if defined USE_PIPI
  67. if (data->sequence)
  68. {
  69. uint32_t *buffer = new uint32_t[width * height];
  70. Video::Capture(buffer);
  71. pipi_feed_sequence(data->sequence, (uint8_t *)buffer, width, height);
  72. delete[] buffer;
  73. }
  74. #endif
  75. }
  76. DebugRecord::~DebugRecord()
  77. {
  78. delete data;
  79. }