source: trunk/src/debugrecord.cpp @ 221

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

Complete Lol Engine / Deus Hax / Monsterz split.

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