source: trunk/src/debugrecord.cpp @ 210

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

Allow for different priorities in game and draw tick levels.

  • 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 USE_PIPI
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 USE_PIPI
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 USE_PIPI
47    data->sequence = NULL;
48#endif
49
50    drawgroup = DRAWGROUP_CAPTURE;
51}
52
53void DebugRecord::TickGame(float deltams)
54{
55    Entity::TickGame(deltams);
56}
57
58void DebugRecord::TickDraw(float deltams)
59{
60    Entity::TickDraw(deltams);
61
62    int width = Video::GetWidth();
63    int height = Video::GetHeight();
64
65    if (data->width != width || data->height != height)
66    {
67        data->width = width;
68        data->height = height;
69
70#if defined USE_PIPI
71        if (data->sequence)
72            pipi_close_sequence(data->sequence);
73
74        data->sequence = pipi_open_sequence(data->path, width, height, 30);
75#endif
76    }
77
78#if defined USE_PIPI
79    if (data->sequence)
80    {
81        uint32_t *buffer = new uint32_t[width * height];
82        Video::Capture(buffer);
83        pipi_feed_sequence(data->sequence, (uint8_t *)buffer, width, height);
84        delete[] buffer;
85    }
86#endif
87}
88
89DebugRecord::~DebugRecord()
90{
91    delete data;
92}
Note: See TracBrowser for help on using the repository browser.