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

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