Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

101 řádky
2.0 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, fps;
  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, float fps)
  37. : data(new DebugRecordData())
  38. {
  39. data->path = strdup(path);
  40. data->width = 0;
  41. data->height = 0;
  42. data->fps = (int)(fps + 0.5f);
  43. #if defined USE_PIPI
  44. data->sequence = NULL;
  45. #endif
  46. drawgroup = DRAWGROUP_CAPTURE;
  47. }
  48. void DebugRecord::TickGame(float deltams)
  49. {
  50. Entity::TickGame(deltams);
  51. }
  52. void DebugRecord::TickDraw(float deltams)
  53. {
  54. Entity::TickDraw(deltams);
  55. int width = Video::GetWidth();
  56. int height = Video::GetHeight();
  57. if (data->width != width || data->height != height)
  58. {
  59. data->width = width;
  60. data->height = height;
  61. #if defined USE_PIPI
  62. if (data->sequence)
  63. pipi_close_sequence(data->sequence);
  64. data->sequence = pipi_open_sequence(data->path, width, height,
  65. 1 /* RGB */, data->fps,
  66. 1, 1, 60 * 1024 * 1024);
  67. #endif
  68. }
  69. #if defined USE_PIPI
  70. if (data->sequence)
  71. {
  72. uint32_t *buffer = new uint32_t[width * height];
  73. Video::Capture(buffer);
  74. pipi_feed_sequence(data->sequence, (uint8_t *)buffer, width, height);
  75. delete[] buffer;
  76. }
  77. #endif
  78. }
  79. DebugRecord::~DebugRecord()
  80. {
  81. delete data;
  82. }