source: trunk/src/debugrecord.cpp @ 154

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

Refactor stuff.

  • Property svn:keywords set to Id
File size: 1.5 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#include <pipi.h>
14
15#include "core.h"
16#include "debugrecord.h"
17
18/*
19 * DebugRecord implementation class
20 */
21
22class DebugRecordData
23{
24    friend class DebugRecord;
25
26private:
27    char const *path;
28    int width, height;
29    pipi_sequence_t *sequence;
30};
31
32/*
33 * Public DebugRecord class
34 */
35
36DebugRecord::DebugRecord(char const *path)
37{
38    data = new DebugRecordData();
39    data->path = strdup(path);
40    data->width = 0;
41    data->height = 0;
42    data->sequence = NULL;
43}
44
45Entity::Group DebugRecord::GetGroup()
46{
47    return GROUP_DRAW_CAPTURE;
48}
49
50void DebugRecord::TickGame(float deltams)
51{
52    Entity::TickGame(deltams);
53}
54
55void DebugRecord::TickDraw(float deltams)
56{
57    Entity::TickDraw(deltams);
58
59    int width = Video::GetWidth();
60    int height = Video::GetHeight();
61
62    if (data->width != width || data->height != height)
63    {
64        data->width = width;
65        data->height = height;
66
67        if (data->sequence)
68            pipi_close_sequence(data->sequence);
69
70        data->sequence = pipi_open_sequence(data->path, width, height, 30);
71    }
72
73    if (data->sequence)
74    {
75        uint32_t *buffer = new uint32_t[width * height];
76        Video::Capture(buffer);
77        pipi_feed_sequence(data->sequence, (uint8_t *)buffer, width, height);
78        delete[] buffer;
79    }
80}
81
82DebugRecord::~DebugRecord()
83{
84    delete data;
85}
86
Note: See TracBrowser for help on using the repository browser.