author | unc0rr |
Sat, 15 Sep 2018 20:42:02 +0200 | |
branch | 0.9.24 |
changeset 13813 | c384117f90eb |
parent 13590 | 62a5eea4ae7a |
child 13499 | b5f8864a38d3 |
permissions | -rw-r--r-- |
7180 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
7180 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
7180 | 17 |
*) |
18 |
||
7286 | 19 |
|
7180 | 20 |
{$INCLUDE "options.inc"} |
21 |
||
22 |
unit uVideoRec; |
|
23 |
||
7286 | 24 |
{$IFNDEF USE_VIDEO_RECORDING} |
25 |
interface |
|
26 |
implementation |
|
27 |
end. |
|
28 |
{$ELSE} |
|
29 |
||
7538 | 30 |
{$IFNDEF WIN32} |
8697 | 31 |
{$linklib avwrapper} |
7180 | 32 |
{$ENDIF} |
33 |
||
34 |
interface |
|
35 |
||
36 |
var flagPrerecording: boolean = false; |
|
37 |
||
38 |
function BeginVideoRecording: Boolean; |
|
7671 | 39 |
function LoadNextCameraPosition(out newRealTicks, newGameTicks: LongInt): Boolean; |
7180 | 40 |
procedure EncodeFrame; |
41 |
procedure StopVideoRecording; |
|
42 |
||
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
43 |
procedure BeginPreRecording; |
7180 | 44 |
procedure StopPreRecording; |
45 |
procedure SaveCameraPosition; |
|
46 |
||
7850 | 47 |
procedure initModule; |
7180 | 48 |
procedure freeModule; |
49 |
||
50 |
implementation |
|
11821 | 51 |
uses uVariables, GLunit, SDLh, SysUtils, uUtils, uIO, uMisc, uTypes, uDebug; |
7180 | 52 |
|
53 |
type TAddFileLogRaw = procedure (s: pchar); cdecl; |
|
8666
1652c1d9adc8
rework ffmpeg/libav/videorec linking and their cmake discovery
koda
parents:
8370
diff
changeset
|
54 |
const AvwrapperLibName = 'libavwrapper'; |
7180 | 55 |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9545
diff
changeset
|
56 |
function AVWrapper_Init( |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
57 |
AddLog: TAddFileLogRaw; |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
58 |
filename, desc, soundFile, format, vcodec, acodec: PChar; |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9545
diff
changeset
|
59 |
width, height, framerateNum, framerateDen, vquality: LongInt): LongInt; cdecl; external AvwrapperLibName; |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9545
diff
changeset
|
60 |
function AVWrapper_Close: LongInt; cdecl; external AvwrapperLibName; |
11612
b7d5d75469ee
Move pixel format conversion from uVideoRec to AVWrapper
koda
parents:
11532
diff
changeset
|
61 |
function AVWrapper_WriteFrame(rgb: PByte): LongInt; cdecl; external AvwrapperLibName; |
7180 | 62 |
|
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
63 |
type TFrame = record |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
64 |
realTicks: LongWord; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
65 |
gameTicks: LongWord; |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
66 |
CamX, CamY: LongInt; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
67 |
zoom: single; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
68 |
end; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
69 |
|
12621 | 70 |
var RGB_Buffer: PByte; |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
71 |
cameraFile: File of TFrame; |
7180 | 72 |
audioFile: File; |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
73 |
numPixels: LongWord; |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
74 |
startTime, numFrames, curTime, progress, maxProgress: LongWord; |
7392
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
75 |
soundFilePath: shortstring; |
13589
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
76 |
thumbnailSaved: boolean; |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
77 |
recordAudio: boolean; |
7180 | 78 |
|
79 |
function BeginVideoRecording: Boolean; |
|
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
80 |
var filename, desc: shortstring; |
7180 | 81 |
begin |
82 |
AddFileLog('BeginVideoRecording'); |
|
83 |
||
84 |
{$IOCHECKS OFF} |
|
85 |
// open file with prerecorded camera positions |
|
7392
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
86 |
filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.txtin'; |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
87 |
Assign(cameraFile, filename); |
7180 | 88 |
Reset(cameraFile); |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
89 |
maxProgress:= FileSize(cameraFile); |
7180 | 90 |
if IOResult <> 0 then |
91 |
begin |
|
7392
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
92 |
AddFileLog('Error: Could not read from ' + filename); |
7180 | 93 |
exit(false); |
94 |
end; |
|
95 |
{$IOCHECKS ON} |
|
96 |
||
13226
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12621
diff
changeset
|
97 |
{ Store some description in output file. |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12621
diff
changeset
|
98 |
The comment must follow a particular format and must be in English. |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12621
diff
changeset
|
99 |
This will be parsed by the frontend. |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12621
diff
changeset
|
100 |
The frontend will parse lines of this format: |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12621
diff
changeset
|
101 |
Key: Value |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12621
diff
changeset
|
102 |
The key names will be localized in the frontend. |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12621
diff
changeset
|
103 |
If you add a key/value pair, don't forget to add a localization |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12621
diff
changeset
|
104 |
in the frontend! } |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
105 |
desc:= ''; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
106 |
if UserNick <> '' then |
7804 | 107 |
desc:= desc + 'Player: ' + UserNick + #10; |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
108 |
if recordFileName <> '' then |
7804 | 109 |
desc:= desc + 'Record: ' + recordFileName + #10; |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
110 |
if cMapName <> '' then |
7804 | 111 |
desc:= desc + 'Map: ' + cMapName + #10; |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
112 |
if Theme <> '' then |
7804 | 113 |
desc:= desc + 'Theme: ' + Theme + #10; |
114 |
desc:= desc + 'prefix[' + RecPrefix + ']prefix'; |
|
115 |
||
116 |
filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix; |
|
13589
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
117 |
|
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
118 |
recordAudio:= (cAudioCodec <> 'no'); |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
119 |
if recordAudio then |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
120 |
soundFilePath:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.sw' |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
121 |
else |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
122 |
soundFilePath:= ''; |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
123 |
|
11532 | 124 |
if checkFails(AVWrapper_Init(@AddFileLogRaw |
7804 | 125 |
, PChar(ansistring(filename)) |
126 |
, PChar(ansistring(desc)) |
|
127 |
, PChar(ansistring(soundFilePath)) |
|
128 |
, PChar(ansistring(cAVFormat)) |
|
129 |
, PChar(ansistring(cVideoCodec)) |
|
130 |
, PChar(ansistring(cAudioCodec)) |
|
10309 | 131 |
, cScreenWidth, cScreenHeight, cVideoFramerateNum, cVideoFramerateDen, cVideoQuality) >= 0, |
132 |
'AVWrapper_Init failed', |
|
11532 | 133 |
true) then exit(false); |
7180 | 134 |
|
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
135 |
numPixels:= cScreenWidth*cScreenHeight; |
7180 | 136 |
|
137 |
RGB_Buffer:= GetMem(4*numPixels); |
|
138 |
if RGB_Buffer = nil then |
|
139 |
begin |
|
140 |
AddFileLog('Error: Could not allocate memory for video recording (RGB buffer).'); |
|
141 |
exit(false); |
|
142 |
end; |
|
143 |
||
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
144 |
curTime:= 0; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
145 |
numFrames:= 0; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
146 |
progress:= 0; |
7180 | 147 |
BeginVideoRecording:= true; |
148 |
end; |
|
149 |
||
150 |
procedure StopVideoRecording; |
|
151 |
begin |
|
152 |
AddFileLog('StopVideoRecording'); |
|
153 |
FreeMem(RGB_Buffer, 4*numPixels); |
|
154 |
Close(cameraFile); |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9545
diff
changeset
|
155 |
if AVWrapper_Close() < 0 then |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9545
diff
changeset
|
156 |
halt(-1); |
7392
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
157 |
Erase(cameraFile); |
13589
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
158 |
if recordAudio then |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
159 |
DeleteFile(soundFilePath); |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
160 |
SendIPC(_S'v'); // inform frontend that we finished |
7180 | 161 |
end; |
162 |
||
163 |
procedure EncodeFrame; |
|
11612
b7d5d75469ee
Move pixel format conversion from uVideoRec to AVWrapper
koda
parents:
11532
diff
changeset
|
164 |
var s: shortstring; |
7180 | 165 |
begin |
166 |
// read pixels from OpenGL |
|
167 |
glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, RGB_Buffer); |
|
168 |
||
11612
b7d5d75469ee
Move pixel format conversion from uVideoRec to AVWrapper
koda
parents:
11532
diff
changeset
|
169 |
if AVWrapper_WriteFrame(RGB_Buffer) < 0 then |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9545
diff
changeset
|
170 |
halt(-1); |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
171 |
|
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
172 |
// inform frontend that we have encoded new frame |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
173 |
s[0]:= #3; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
174 |
s[1]:= 'p'; // p for progress |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
175 |
SDLNet_Write16(progress*10000 div maxProgress, @s[2]); |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
176 |
SendIPC(s); |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
177 |
inc(numFrames); |
7180 | 178 |
end; |
179 |
||
7671 | 180 |
function LoadNextCameraPosition(out newRealTicks, newGameTicks: LongInt): Boolean; |
8370 | 181 |
var frame: TFrame = (realTicks: 0; gameTicks: 0; CamX: 0; CamY: 0; zoom: 0); |
7180 | 182 |
begin |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
183 |
// we need to skip or duplicate frames to match target framerate |
7379
aa29a2f16cc7
fix bug with desynced camera positions
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
184 |
while Int64(curTime)*cVideoFramerateNum <= Int64(numFrames)*cVideoFramerateDen*1000 do |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
185 |
begin |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
186 |
{$IOCHECKS OFF} |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
187 |
if eof(cameraFile) then |
7392
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
188 |
exit(false); |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
189 |
BlockRead(cameraFile, frame, 1); |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
190 |
{$IOCHECKS ON} |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
191 |
curTime:= frame.realTicks; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
192 |
WorldDx:= frame.CamX; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
193 |
WorldDy:= frame.CamY + cScreenHeight div 2; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
194 |
zoom:= frame.zoom*cScreenWidth; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
195 |
ZoomValue:= zoom; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
196 |
inc(progress); |
7392
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
197 |
newRealTicks:= frame.realTicks; |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
198 |
newGameTicks:= frame.gameTicks; |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
199 |
end; |
7392
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
200 |
LoadNextCameraPosition:= true; |
7180 | 201 |
end; |
202 |
||
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
203 |
// Callback which records sound. |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
204 |
// This procedure may be called from different thread. |
7180 | 205 |
procedure RecordPostMix(udata: pointer; stream: PByte; len: LongInt); cdecl; |
206 |
begin |
|
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
207 |
udata:= udata; // avoid warning |
7180 | 208 |
{$IOCHECKS OFF} |
209 |
BlockWrite(audioFile, stream^, len); |
|
210 |
{$IOCHECKS ON} |
|
211 |
end; |
|
212 |
||
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
213 |
procedure SaveThumbnail; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
214 |
var thumbpath: shortstring; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
215 |
k: LongInt; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
216 |
begin |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
217 |
thumbpath:= '/VideoTemp/' + RecPrefix; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
218 |
AddFileLog('Saving thumbnail ' + thumbpath); |
7386
e82a076df09b
Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents:
7379
diff
changeset
|
219 |
k:= max(max(cScreenWidth, cScreenHeight) div 400, 1); // here 400 is minimum size of thumbnail |
10633
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10309
diff
changeset
|
220 |
MakeScreenshot(thumbpath, k, 0); |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
221 |
thumbnailSaved:= true; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
222 |
end; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
223 |
|
7392
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
224 |
// copy file (free pascal doesn't have copy file function) |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
225 |
procedure CopyFile(src, dest: shortstring); |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
226 |
var inF, outF: file; |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
227 |
buffer: array[0..1023] of byte; |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
228 |
result: LongInt; |
8370 | 229 |
i: integer; |
7392
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
230 |
begin |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
231 |
{$IOCHECKS OFF} |
8370 | 232 |
result:= 0; // avoid compiler hint and warning |
233 |
for i:= 0 to 1023 do |
|
234 |
buffer[i]:= 0; |
|
7392
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
235 |
|
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
236 |
Assign(inF, src); |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
237 |
Reset(inF, 1); |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
238 |
if IOResult <> 0 then |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
239 |
begin |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
240 |
AddFileLog('Error: Could not read from ' + src); |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
241 |
exit; |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
242 |
end; |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
243 |
|
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
244 |
Assign(outF, dest); |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
245 |
Rewrite(outF, 1); |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
246 |
if IOResult <> 0 then |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
247 |
begin |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
248 |
AddFileLog('Error: Could not write to ' + dest); |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
249 |
exit; |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
250 |
end; |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
251 |
|
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
252 |
repeat |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
253 |
BlockRead(inF, buffer, 1024, result); |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
254 |
BlockWrite(outF, buffer, result); |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
255 |
until result < 1024; |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
256 |
{$IOCHECKS ON} |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
257 |
end; |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
258 |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
259 |
procedure BeginPreRecording; |
7180 | 260 |
var format: word; |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
261 |
filename: shortstring; |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
262 |
frequency, channels: LongInt; |
7180 | 263 |
begin |
264 |
AddFileLog('BeginPreRecording'); |
|
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
265 |
|
7369
46921fbe76d3
Move SDL_GetTicks() to another place, maybe this will fix sound desync.
Stepan777 <stepik-777@mail.ru>
parents:
7363
diff
changeset
|
266 |
thumbnailSaved:= false; |
7386
e82a076df09b
Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents:
7379
diff
changeset
|
267 |
RecPrefix:= 'hw-' + FormatDateTime('YYYY-MM-DD_HH-mm-ss-z', Now()); |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
268 |
|
7392
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
269 |
// If this video is recorded from demo executed directly (without frontend) |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
270 |
// then we need to copy demo so that frontend will be able to find it later. |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
271 |
if recordFileName <> '' then |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
272 |
begin |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
273 |
if GameType <> gmtDemo then // this is save and game demo is not recording, abort |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
274 |
exit; |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
275 |
CopyFile(recordFileName, UserPathPrefix + '/VideoTemp/' + RecPrefix + '.hwd'); |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
276 |
end; |
bc3306c59a08
Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents:
7386
diff
changeset
|
277 |
|
13589
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
278 |
if cIsSoundEnabled then |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
279 |
begin |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
280 |
Mix_QuerySpec(@frequency, @format, @channels); |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
281 |
AddFileLog('sound: frequency = ' + IntToStr(frequency) + ', format = ' + IntToStr(format) + ', channels = ' + IntToStr(channels)); |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
282 |
if format <> $8010 then |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
283 |
begin |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
284 |
// TODO: support any audio format |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
285 |
AddFileLog('Error: Unexpected audio format ' + IntToStr(format)); |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
286 |
exit; |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
287 |
end; |
7180 | 288 |
|
289 |
{$IOCHECKS OFF} |
|
13589
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
290 |
// create sound file |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
291 |
filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.sw'; |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
292 |
Assign(audioFile, filename); |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
293 |
Rewrite(audioFile, 1); |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
294 |
if IOResult <> 0 then |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
295 |
begin |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
296 |
AddFileLog('Error: Could not write to ' + filename); |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
297 |
exit; |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
298 |
end; |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
299 |
end; |
7180 | 300 |
|
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
301 |
// create file with camera positions |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
302 |
filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.txtout'; |
7180 | 303 |
Assign(cameraFile, filename); |
304 |
Rewrite(cameraFile); |
|
305 |
if IOResult <> 0 then |
|
13589
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
306 |
begin |
7180 | 307 |
AddFileLog('Error: Could not write to ' + filename); |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
308 |
exit; |
13589
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
309 |
end; |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
310 |
|
13589
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
311 |
if cIsSoundEnabled then |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
312 |
begin |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
313 |
// save audio parameters in sound file |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
314 |
BlockWrite(audioFile, frequency, 4); |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
315 |
BlockWrite(audioFile, channels, 4); |
7180 | 316 |
{$IOCHECKS ON} |
317 |
||
13589
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
318 |
// register callback for actual audio recording |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
319 |
Mix_SetPostMix(@RecordPostMix, nil); |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
320 |
end; |
7180 | 321 |
|
7369
46921fbe76d3
Move SDL_GetTicks() to another place, maybe this will fix sound desync.
Stepan777 <stepik-777@mail.ru>
parents:
7363
diff
changeset
|
322 |
startTime:= SDL_GetTicks(); |
7180 | 323 |
flagPrerecording:= true; |
324 |
end; |
|
325 |
||
326 |
procedure StopPreRecording; |
|
327 |
begin |
|
328 |
AddFileLog('StopPreRecording'); |
|
329 |
flagPrerecording:= false; |
|
330 |
||
13589
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
331 |
if cIsSoundEnabled then |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
332 |
begin |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
333 |
// call SDL_LockAudio because RecordPostMix may be executing right now |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
334 |
SDL_LockAudio(); |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
335 |
Close(audioFile); |
13590 | 336 |
end; |
7180 | 337 |
Close(cameraFile); |
13589
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
338 |
if cIsSoundEnabled then |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
339 |
begin |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
340 |
Mix_SetPostMix(nil, nil); |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
341 |
SDL_UnlockAudio(); |
4acd189a563e
Fix video recorder not working if sound disabled (fixes bug 200)
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
342 |
end; |
7369
46921fbe76d3
Move SDL_GetTicks() to another place, maybe this will fix sound desync.
Stepan777 <stepik-777@mail.ru>
parents:
7363
diff
changeset
|
343 |
|
46921fbe76d3
Move SDL_GetTicks() to another place, maybe this will fix sound desync.
Stepan777 <stepik-777@mail.ru>
parents:
7363
diff
changeset
|
344 |
if not thumbnailSaved then |
46921fbe76d3
Move SDL_GetTicks() to another place, maybe this will fix sound desync.
Stepan777 <stepik-777@mail.ru>
parents:
7363
diff
changeset
|
345 |
SaveThumbnail(); |
7180 | 346 |
end; |
347 |
||
348 |
procedure SaveCameraPosition; |
|
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
349 |
var frame: TFrame; |
7180 | 350 |
begin |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
351 |
if (not thumbnailSaved) and (ScreenFade = sfNone) then |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
352 |
SaveThumbnail(); |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7286
diff
changeset
|
353 |
|
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
354 |
frame.realTicks:= SDL_GetTicks() - startTime; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
355 |
frame.gameTicks:= GameTicks; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
356 |
frame.CamX:= WorldDx; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
357 |
frame.CamY:= WorldDy - cScreenHeight div 2; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
358 |
frame.zoom:= zoom/cScreenWidth; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7369
diff
changeset
|
359 |
BlockWrite(cameraFile, frame, 1); |
7180 | 360 |
end; |
361 |
||
7850 | 362 |
procedure initModule; |
363 |
begin |
|
9543 | 364 |
// we need to make sure these variables are initialized before the main loop |
365 |
// or the wrapper will keep the default values of preinit |
|
9545 | 366 |
cScreenWidth:= max(cWindowedWidth, 640); |
367 |
cScreenHeight:= max(cWindowedHeight, 480); |
|
7850 | 368 |
end; |
369 |
||
7180 | 370 |
procedure freeModule; |
371 |
begin |
|
372 |
if flagPrerecording then |
|
373 |
StopPreRecording(); |
|
374 |
end; |
|
375 |
||
376 |
end. |
|
7286 | 377 |
|
378 |
{$ENDIF} // USE_VIDEO_RECORDING |