source: trunk/src/debugrecord.cpp @ 615

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

Allow to specify FPS in the DebugRecord object.

  • 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 <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
25/*
26 * DebugRecord implementation class
27 */
28
29class DebugRecordData
30{
31    friend class DebugRecord;
32
33private:
34    char const *path;
35    int width, height, fps;
36#if defined USE_PIPI
37    pipi_sequence_t *sequence;
38#endif
39};
40
41/*
42 * Public DebugRecord class
43 */
44
45DebugRecord::DebugRecord(char const *path, float fps)
46  : data(new DebugRecordData())
47{
48    data->path = strdup(path);
49    data->width = 0;
50    data->height = 0;
51    data->fps = (int)(fps + 0.5f);
52#if defined USE_PIPI
53    data->sequence = NULL;
54#endif
55
56    drawgroup = DRAWGROUP_CAPTURE;
57}
58
59void DebugRecord::TickGame(float deltams)
60{
61    Entity::TickGame(deltams);
62}
63
64void DebugRecord::TickDraw(float deltams)
65{
66    Entity::TickDraw(deltams);
67
68    int width = Video::GetWidth();
69    int height = Video::GetHeight();
70
71    if (data->width != width || data->height != height)
72    {
73        data->width = width;
74        data->height = height;
75
76#if defined USE_PIPI
77        if (data->sequence)
78            pipi_close_sequence(data->sequence);
79
80        data->sequence = pipi_open_sequence(data->path, width, height,
81                                            1 /* RGB */, data->fps,
82                                            1, 1, 60 * 1024 * 1024);
83#endif
84    }
85
86#if defined USE_PIPI
87    if (data->sequence)
88    {
89        uint32_t *buffer = new uint32_t[width * height];
90        Video::Capture(buffer);
91        pipi_feed_sequence(data->sequence, (uint8_t *)buffer, width, height);
92        delete[] buffer;
93    }
94#endif
95}
96
97DebugRecord::~DebugRecord()
98{
99    delete data;
100}
Note: See TracBrowser for help on using the repository browser.