您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

106 行
2.0 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 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://www.wtfpl.net/ for more details.
  9. //
  10. #include <lol/engine-internal.h>
  11. #include <cstring>
  12. #if defined USE_PIPI
  13. # include <pipi.h>
  14. #endif
  15. #include "loldebug.h"
  16. namespace lol
  17. {
  18. /*
  19. * DebugRecord implementation class
  20. */
  21. class DebugRecordData
  22. {
  23. friend class DebugRecord;
  24. private:
  25. String m_path;
  26. ivec2 m_size;
  27. int m_fps;
  28. #if defined USE_PIPI
  29. pipi_sequence_t *m_sequence;
  30. #endif
  31. };
  32. /*
  33. * Public DebugRecord class
  34. */
  35. DebugRecord::DebugRecord(String const &path, float fps)
  36. : m_data(new DebugRecordData())
  37. {
  38. Ticker::StartRecording();
  39. m_data->m_path = path;
  40. m_data->m_size = ivec2::zero;
  41. m_data->m_fps = (int)(fps + 0.5f);
  42. #if defined USE_PIPI
  43. m_data->m_sequence = nullptr;
  44. #endif
  45. m_drawgroup = DRAWGROUP_CAPTURE;
  46. }
  47. void DebugRecord::TickGame(float seconds)
  48. {
  49. Entity::TickGame(seconds);
  50. }
  51. void DebugRecord::TickDraw(float seconds, Scene &scene)
  52. {
  53. Entity::TickDraw(seconds, scene);
  54. ivec2 size = Video::GetSize();
  55. if (m_data->m_size != size)
  56. {
  57. m_data->m_size = size;
  58. #if defined USE_PIPI
  59. if (m_data->m_sequence)
  60. pipi_close_sequence(m_data->m_sequence);
  61. m_data->m_sequence = pipi_open_sequence(m_data->m_path, size.x, size.y,
  62. 1 /* RGB */, m_data->m_fps,
  63. 1, 1, 60 * 1024 * 1024);
  64. #endif
  65. }
  66. #if defined USE_PIPI
  67. if (m_data->m_sequence)
  68. {
  69. uint32_t *buffer = new uint32_t[size.x * size.y];
  70. Video::Capture(buffer);
  71. pipi_feed_sequence(m_data->m_sequence, (uint8_t *)buffer,
  72. size.x, size.y);
  73. delete[] buffer;
  74. }
  75. #endif
  76. }
  77. DebugRecord::~DebugRecord()
  78. {
  79. Ticker::StopRecording();
  80. delete m_data;
  81. }
  82. } /* namespace lol */