source: trunk/src/debugrecord.cpp @ 686

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

Put everything in the "lol" namespace. Better late than never.

  • 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 <cstdio>
16#include <cstring>
17
18#if defined USE_PIPI
19#   include <pipi.h>
20#endif
21
22#include "core.h"
23#include "debugrecord.h"
24
25namespace lol
26{
27
28/*
29 * DebugRecord implementation class
30 */
31
32class DebugRecordData
33{
34    friend class DebugRecord;
35
36private:
37    char const *path;
38    int width, height, 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->width = 0;
55    data->height = 0;
56    data->fps = (int)(fps + 0.5f);
57#if defined USE_PIPI
58    data->sequence = NULL;
59#endif
60
61    drawgroup = DRAWGROUP_CAPTURE;
62}
63
64void DebugRecord::TickGame(float deltams)
65{
66    Entity::TickGame(deltams);
67}
68
69void DebugRecord::TickDraw(float deltams)
70{
71    Entity::TickDraw(deltams);
72
73    int width = Video::GetWidth();
74    int height = Video::GetHeight();
75
76    if (data->width != width || data->height != height)
77    {
78        data->width = width;
79        data->height = height;
80
81#if defined USE_PIPI
82        if (data->sequence)
83            pipi_close_sequence(data->sequence);
84
85        data->sequence = pipi_open_sequence(data->path, width, height,
86                                            1 /* RGB */, data->fps,
87                                            1, 1, 60 * 1024 * 1024);
88#endif
89    }
90
91#if defined USE_PIPI
92    if (data->sequence)
93    {
94        uint32_t *buffer = new uint32_t[width * height];
95        Video::Capture(buffer);
96        pipi_feed_sequence(data->sequence, (uint8_t *)buffer, width, height);
97        delete[] buffer;
98    }
99#endif
100}
101
102DebugRecord::~DebugRecord()
103{
104    Ticker::StopRecording();
105
106    delete data;
107}
108
109} /* namespace lol */
110
Note: See TracBrowser for help on using the repository browser.