source: trunk/src/debugrecord.cpp @ 755

Last change on this file since 755 was 755, checked in by sam, 10 years ago

video: get rid of Video::GetWidth() and Video::GetHeight().

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
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
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <cstring>
16
17#if defined USE_PIPI
18#   include <pipi.h>
19#endif
20
21#include "core.h"
22#include "debugrecord.h"
23
24namespace lol
25{
26
27/*
28 * DebugRecord implementation class
29 */
30
31class DebugRecordData
32{
33    friend class DebugRecord;
34
35private:
36    char const *path;
37    vec2i size;
38    int fps;
39#if defined USE_PIPI
40    pipi_sequence_t *sequence;
41#endif
42};
43
44/*
45 * Public DebugRecord class
46 */
47
48DebugRecord::DebugRecord(char const *path, float fps)
49  : data(new DebugRecordData())
50{
51    Ticker::StartRecording();
52
53    data->path = strdup(path);
54    data->size = 0;
55    data->fps = (int)(fps + 0.5f);
56#if defined USE_PIPI
57    data->sequence = NULL;
58#endif
59
60    drawgroup = DRAWGROUP_CAPTURE;
61}
62
63void DebugRecord::TickGame(float deltams)
64{
65    Entity::TickGame(deltams);
66}
67
68void DebugRecord::TickDraw(float deltams)
69{
70    Entity::TickDraw(deltams);
71
72    vec2i size = Video::GetSize();
73
74    if (data->size != size)
75    {
76        data->size = size;
77
78#if defined USE_PIPI
79        if (data->sequence)
80            pipi_close_sequence(data->sequence);
81
82        data->sequence = pipi_open_sequence(data->path, size.x, size.y,
83                                            1 /* RGB */, data->fps,
84                                            1, 1, 60 * 1024 * 1024);
85#endif
86    }
87
88#if defined USE_PIPI
89    if (data->sequence)
90    {
91        uint32_t *buffer = new uint32_t[size.x * size.y];
92        Video::Capture(buffer);
93        pipi_feed_sequence(data->sequence, (uint8_t *)buffer, size.x, size.y);
94        delete[] buffer;
95    }
96#endif
97}
98
99DebugRecord::~DebugRecord()
100{
101    Ticker::StopRecording();
102
103    delete data;
104}
105
106} /* namespace lol */
107
Note: See TracBrowser for help on using the repository browser.