source: trunk/src/debug/record.cpp @ 1046

Last change on this file since 1046 was 1046, checked in by sam, 12 years ago

core: split vector operations into linear and non-linear so that we can
reuse the linear operations in quaternions. Also mark some constructors
explicit to better spot coding errors.

  • 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 "loldebug.h"
23
24using namespace std;
25
26namespace lol
27{
28
29/*
30 * DebugRecord implementation class
31 */
32
33class DebugRecordData
34{
35    friend class DebugRecord;
36
37private:
38    char const *path;
39    ivec2 size;
40    int fps;
41#if defined USE_PIPI
42    pipi_sequence_t *sequence;
43#endif
44};
45
46/*
47 * Public DebugRecord class
48 */
49
50DebugRecord::DebugRecord(char const *path, float fps)
51  : data(new DebugRecordData())
52{
53    Ticker::StartRecording();
54
55    data->path = strdup(path);
56    data->size = ivec2(0);
57    data->fps = (int)(fps + 0.5f);
58#if defined USE_PIPI
59    data->sequence = NULL;
60#endif
61
62    drawgroup = DRAWGROUP_CAPTURE;
63}
64
65void DebugRecord::TickGame(float deltams)
66{
67    Entity::TickGame(deltams);
68}
69
70void DebugRecord::TickDraw(float deltams)
71{
72    Entity::TickDraw(deltams);
73
74    ivec2 size = Video::GetSize();
75
76    if (data->size != size)
77    {
78        data->size = size;
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, size.x, size.y,
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[size.x * size.y];
94        Video::Capture(buffer);
95        pipi_feed_sequence(data->sequence, (uint8_t *)buffer, size.x, size.y);
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.