source: trunk/src/debugrecord.cpp @ 735

Last change on this file since 735 was 735, checked in by sam, 11 years ago

core: get rid of now useless <cstdio> includes.

  • Property svn:keywords set to Id
File size: 2.1 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    int width, height, fps;
38#if defined USE_PIPI
39    pipi_sequence_t *sequence;
40#endif
41};
42
43/*
44 * Public DebugRecord class
45 */
46
47DebugRecord::DebugRecord(char const *path, float fps)
48  : data(new DebugRecordData())
49{
50    Ticker::StartRecording();
51
52    data->path = strdup(path);
53    data->width = 0;
54    data->height = 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    int width = Video::GetWidth();
73    int height = Video::GetHeight();
74
75    if (data->width != width || data->height != height)
76    {
77        data->width = width;
78        data->height = height;
79
80#if defined USE_PIPI
81        if (data->sequence)
82            pipi_close_sequence(data->sequence);
83
84        data->sequence = pipi_open_sequence(data->path, width, height,
85                                            1 /* RGB */, data->fps,
86                                            1, 1, 60 * 1024 * 1024);
87#endif
88    }
89
90#if defined USE_PIPI
91    if (data->sequence)
92    {
93        uint32_t *buffer = new uint32_t[width * height];
94        Video::Capture(buffer);
95        pipi_feed_sequence(data->sequence, (uint8_t *)buffer, width, height);
96        delete[] buffer;
97    }
98#endif
99}
100
101DebugRecord::~DebugRecord()
102{
103    Ticker::StopRecording();
104
105    delete data;
106}
107
108} /* namespace lol */
109
Note: See TracBrowser for help on using the repository browser.