source: trunk/src/debugrecord.cpp @ 171

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

Allow to build without libpipi.

  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#include <cstdio>
11#include <cstring>
12
13#if defined HAVE_PIPI_H
14#   include <pipi.h>
15#endif
16
17#include "core.h"
18#include "debugrecord.h"
19
20/*
21 * DebugRecord implementation class
22 */
23
24class DebugRecordData
25{
26    friend class DebugRecord;
27
28private:
29    char const *path;
30    int width, height;
31#if defined HAVE_PIPI_H
32    pipi_sequence_t *sequence;
33#endif
34};
35
36/*
37 * Public DebugRecord class
38 */
39
40DebugRecord::DebugRecord(char const *path)
41{
42    data = new DebugRecordData();
43    data->path = strdup(path);
44    data->width = 0;
45    data->height = 0;
46#if defined HAVE_PIPI_H
47    data->sequence = NULL;
48#endif
49}
50
51Entity::Group DebugRecord::GetGroup()
52{
53    return GROUP_DRAW_CAPTURE;
54}
55
56void DebugRecord::TickGame(float deltams)
57{
58    Entity::TickGame(deltams);
59}
60
61void DebugRecord::TickDraw(float deltams)
62{
63    Entity::TickDraw(deltams);
64
65    int width = Video::GetWidth();
66    int height = Video::GetHeight();
67
68    if (data->width != width || data->height != height)
69    {
70        data->width = width;
71        data->height = height;
72
73#if defined HAVE_PIPI_H
74        if (data->sequence)
75            pipi_close_sequence(data->sequence);
76
77        data->sequence = pipi_open_sequence(data->path, width, height, 30);
78#endif
79    }
80
81#if defined HAVE_PIPI_H
82    if (data->sequence)
83    {
84        uint32_t *buffer = new uint32_t[width * height];
85        Video::Capture(buffer);
86        pipi_feed_sequence(data->sequence, (uint8_t *)buffer, width, height);
87        delete[] buffer;
88    }
89#endif
90}
91
92DebugRecord::~DebugRecord()
93{
94    delete data;
95}
Note: See TracBrowser for help on using the repository browser.