author | alfadur |
Thu, 25 Jul 2019 23:02:02 +0300 | |
changeset 15280 | 66c987015f2d |
parent 14894 | 9b292184d793 |
child 15319 | fe705efbfc52 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
6952 | 2 |
* Hedgewars, a free turn based strategy game |
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
6952 | 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:
10015
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
6952 | 17 |
*) |
4 | 18 |
|
2630 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
4 | 21 |
unit uMisc; |
22 |
interface |
|
2630 | 23 |
|
5004
2efa6a414518
update some sdl-1.3 bindings (working up to rev 5296)
koda
parents:
4976
diff
changeset
|
24 |
uses SDLh, uConsts, GLunit, uTypes; |
1054 | 25 |
|
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6952
diff
changeset
|
26 |
procedure initModule; |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6952
diff
changeset
|
27 |
procedure freeModule; |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6952
diff
changeset
|
28 |
|
2670 | 29 |
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface; |
10633
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
30 |
function MakeScreenshot(filename: shortstring; k: LongInt; dump: LongWord): boolean; |
4413 | 31 |
function GetTeamStatString(p: PTeam): shortstring; |
6992 | 32 |
function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline; |
4 | 33 |
|
34 |
implementation |
|
11828
0fba6cb098a1
drop SysUtils inclusion from 5 files where it is not needed anymore
sheepluva
parents:
11358
diff
changeset
|
35 |
uses uVariables, uUtils |
8865 | 36 |
{$IFDEF PNG_SCREENSHOTS}, PNGh, png {$ENDIF}; |
6881 | 37 |
|
38 |
type PScreenshot = ^TScreenshot; |
|
39 |
TScreenshot = record |
|
40 |
buffer: PByte; |
|
41 |
filename: shortstring; |
|
42 |
width, height: LongInt; |
|
43 |
size: QWord; |
|
44 |
end; |
|
3756 | 45 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7848
diff
changeset
|
46 |
var conversionFormat : PSDL_PixelFormat; |
7049 | 47 |
|
6881 | 48 |
{$IFDEF PNG_SCREENSHOTS} |
49 |
// this funtion will be executed in separate thread |
|
8865 | 50 |
function SaveScreenshot(screenshot: pointer): LongInt; cdecl; export; |
6881 | 51 |
var i: LongInt; |
52 |
png_ptr: ^png_struct; |
|
53 |
info_ptr: ^png_info; |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7848
diff
changeset
|
54 |
f: File; |
6881 | 55 |
image: PScreenshot; |
56 |
begin |
|
57 |
image:= PScreenshot(screenshot); |
|
58 |
||
59 |
png_ptr := png_create_write_struct(png_get_libpng_ver(nil), nil, nil, nil); |
|
60 |
if png_ptr = nil then |
|
61 |
begin |
|
62 |
// AddFileLog('Error: Could not create png write struct.'); |
|
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6952
diff
changeset
|
63 |
SaveScreenshot:= 0; |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6952
diff
changeset
|
64 |
exit; |
6881 | 65 |
end; |
66 |
||
67 |
info_ptr := png_create_info_struct(png_ptr); |
|
68 |
if info_ptr = nil then |
|
69 |
begin |
|
70 |
png_destroy_write_struct(@png_ptr, nil); |
|
71 |
// AddFileLog('Error: Could not create png info struct.'); |
|
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6952
diff
changeset
|
72 |
SaveScreenshot:= 0; |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6952
diff
changeset
|
73 |
exit; |
6881 | 74 |
end; |
75 |
||
76 |
{$IOCHECKS OFF} |
|
77 |
Assign(f, image^.filename); |
|
78 |
Rewrite(f, 1); |
|
79 |
if IOResult = 0 then |
|
80 |
begin |
|
81 |
png_init_pascal_io(png_ptr,@f); |
|
82 |
png_set_IHDR(png_ptr, info_ptr, image^.width, image^.height, |
|
83 |
8, // bit depth |
|
84 |
PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, |
|
85 |
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); |
|
86 |
png_write_info(png_ptr, info_ptr); |
|
87 |
// glReadPixels and libpng number rows in different order |
|
88 |
for i:= image^.height-1 downto 0 do |
|
89 |
png_write_row(png_ptr, image^.buffer + i*4*image^.width); |
|
90 |
png_write_end(png_ptr, info_ptr); |
|
91 |
Close(f); |
|
92 |
end; |
|
93 |
{$IOCHECKS ON} |
|
94 |
||
95 |
// free everything |
|
96 |
png_destroy_write_struct(@png_ptr, @info_ptr); |
|
97 |
FreeMem(image^.buffer, image^.size); |
|
98 |
Dispose(image); |
|
99 |
SaveScreenshot:= 0; |
|
100 |
end; |
|
101 |
||
102 |
{$ELSE} // no PNG_SCREENSHOTS |
|
103 |
||
104 |
// this funtion will be executed in separate thread |
|
8865 | 105 |
function SaveScreenshot(screenshot: pointer): LongInt; cdecl; export; |
6881 | 106 |
var f: file; |
2947 | 107 |
// Windows Bitmap Header |
108 |
head: array[0..53] of Byte = ( |
|
6267
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
109 |
$42, $4D, // identifier ("BM") |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
110 |
0, 0, 0, 0, // file size |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
111 |
0, 0, 0, 0, // reserved |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
112 |
54, 0, 0, 0, // starting offset |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
113 |
40, 0, 0, 0, // header size |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
114 |
0, 0, 0, 0, // width |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
115 |
0, 0, 0, 0, // height |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
116 |
1, 0, // color planes |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
117 |
32, 0, // bit depth |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
118 |
0, 0, 0, 0, // compression method (uncompressed) |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
119 |
0, 0, 0, 0, // image size |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
120 |
96, 0, 0, 0, // horizontal resolution |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
121 |
96, 0, 0, 0, // vertical resolution |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
122 |
0, 0, 0, 0, // number of colors (all) |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
123 |
0, 0, 0, 0 // number of important colors |
2947 | 124 |
); |
6881 | 125 |
image: PScreenshot; |
126 |
size: QWord; |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7848
diff
changeset
|
127 |
writeResult:LongInt; |
6881 | 128 |
begin |
129 |
image:= PScreenshot(screenshot); |
|
130 |
||
131 |
size:= image^.Width*image^.Height*4; |
|
132 |
||
133 |
head[$02]:= (size + 54) and $ff; |
|
134 |
head[$03]:= ((size + 54) shr 8) and $ff; |
|
135 |
head[$04]:= ((size + 54) shr 16) and $ff; |
|
136 |
head[$05]:= ((size + 54) shr 24) and $ff; |
|
137 |
head[$12]:= image^.Width and $ff; |
|
138 |
head[$13]:= (image^.Width shr 8) and $ff; |
|
139 |
head[$14]:= (image^.Width shr 16) and $ff; |
|
140 |
head[$15]:= (image^.Width shr 24) and $ff; |
|
141 |
head[$16]:= image^.Height and $ff; |
|
142 |
head[$17]:= (image^.Height shr 8) and $ff; |
|
143 |
head[$18]:= (image^.Height shr 16) and $ff; |
|
144 |
head[$19]:= (image^.Height shr 24) and $ff; |
|
145 |
head[$22]:= size and $ff; |
|
146 |
head[$23]:= (size shr 8) and $ff; |
|
147 |
head[$24]:= (size shr 16) and $ff; |
|
148 |
head[$25]:= (size shr 24) and $ff; |
|
149 |
||
150 |
{$IOCHECKS OFF} |
|
151 |
Assign(f, image^.filename); |
|
152 |
Rewrite(f, 1); |
|
153 |
if IOResult = 0 then |
|
154 |
begin |
|
12626 | 155 |
writeResult:= 0; // suppress fpc hint |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7848
diff
changeset
|
156 |
BlockWrite(f, head, sizeof(head), writeResult); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7848
diff
changeset
|
157 |
BlockWrite(f, image^.buffer^, size, writeResult); |
6881 | 158 |
Close(f); |
159 |
end |
|
160 |
else |
|
161 |
begin |
|
162 |
//AddFileLog('Error: Could not write to ' + filename); |
|
163 |
end; |
|
164 |
{$IOCHECKS ON} |
|
165 |
||
166 |
// free everything |
|
167 |
FreeMem(image^.buffer, image^.size); |
|
168 |
Dispose(image); |
|
169 |
SaveScreenshot:= 0; |
|
170 |
end; |
|
171 |
||
172 |
{$ENDIF} // no PNG_SCREENSHOTS |
|
173 |
||
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
174 |
{$IFDEF USE_VIDEO_RECORDING} |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
175 |
// make image k times smaller (useful for saving thumbnails) |
14894 | 176 |
procedure ReduceImage(img: PByteArray; width, height, k: LongInt); |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
177 |
var i, j, i0, j0, w, h, r, g, b: LongInt; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
178 |
begin |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
179 |
w:= width div k; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
180 |
h:= height div k; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
181 |
|
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
182 |
// rescale inplace |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
183 |
if k <> 1 then |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
184 |
begin |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
185 |
for i:= 0 to h-1 do |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
186 |
for j:= 0 to w-1 do |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
187 |
begin |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
188 |
r:= 0; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
189 |
g:= 0; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
190 |
b:= 0; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
191 |
for i0:= 0 to k-1 do |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
192 |
for j0:= 0 to k-1 do |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
193 |
begin |
14894 | 194 |
inc(r, img^[4*(width*(i*k+i0) + j*k + j0)+0]); |
195 |
inc(g, img^[4*(width*(i*k+i0) + j*k + j0)+1]); |
|
196 |
inc(b, img^[4*(width*(i*k+i0) + j*k + j0)+2]); |
|
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
197 |
end; |
14894 | 198 |
img^[4*(w*i + j)+0]:= r div (k*k); |
199 |
img^[4*(w*i + j)+1]:= g div (k*k); |
|
200 |
img^[4*(w*i + j)+2]:= b div (k*k); |
|
201 |
img^[4*(w*i + j)+3]:= 255; |
|
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
202 |
end; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
203 |
end; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
204 |
end; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
205 |
{$ENDIF} |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
206 |
|
6881 | 207 |
// captures and saves the screen. returns true on success. |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
208 |
// saved image will be k times smaller than original (useful for saving thumbnails). |
10633
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
209 |
function MakeScreenshot(filename: shortstring; k: LongInt; dump: LongWord): boolean; |
6881 | 210 |
var p: Pointer; |
211 |
size: QWord; |
|
212 |
image: PScreenshot; |
|
213 |
format: GLenum; |
|
214 |
ext: string[4]; |
|
10633
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
215 |
x,y: LongWord; |
1080 | 216 |
begin |
6881 | 217 |
{$IFDEF PNG_SCREENSHOTS} |
218 |
format:= GL_RGBA; |
|
219 |
ext:= '.png'; |
|
220 |
{$ELSE} |
|
221 |
format:= GL_BGRA; |
|
222 |
ext:= '.bmp'; |
|
223 |
{$ENDIF} |
|
224 |
||
10633
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
225 |
if dump > 0 then |
10693 | 226 |
size:= LAND_WIDTH*LAND_HEIGHT*4 |
227 |
else size:= toPowerOf2(cScreenWidth) * toPowerOf2(cScreenHeight) * 4; |
|
6881 | 228 |
p:= GetMem(size); // will be freed in SaveScreenshot() |
1080 | 229 |
|
5910 | 230 |
// memory could not be allocated |
231 |
if p = nil then |
|
5912
d31eba29e706
screenshots: display a msg on failure and log causative error
sheepluva
parents:
5911
diff
changeset
|
232 |
begin |
d31eba29e706
screenshots: display a msg on failure and log causative error
sheepluva
parents:
5911
diff
changeset
|
233 |
AddFileLog('Error: Could not allocate memory for screenshot.'); |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6952
diff
changeset
|
234 |
MakeScreenshot:= false; |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6952
diff
changeset
|
235 |
exit; |
5912
d31eba29e706
screenshots: display a msg on failure and log causative error
sheepluva
parents:
5911
diff
changeset
|
236 |
end; |
5910 | 237 |
|
11041 | 238 |
// read pixels from land array |
10633
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
239 |
if dump > 0 then |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
240 |
begin |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
241 |
for y:= 0 to LAND_HEIGHT-1 do |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
242 |
for x:= 0 to LAND_WIDTH-1 do |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
243 |
if dump = 2 then |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
244 |
PLongWordArray(p)^[y*LAND_WIDTH+x]:= LandPixels[LAND_HEIGHT-1-y, x] |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
245 |
else |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
246 |
begin |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
247 |
if Land[LAND_HEIGHT-1-y, x] and lfIndestructible = lfIndestructible then |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
248 |
PLongWordArray(p)^[y*LAND_WIDTH+x]:= (AMask or RMask) |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
249 |
else if Land[LAND_HEIGHT-1-y, x] and lfIce = lfIce then |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
250 |
PLongWordArray(p)^[y*LAND_WIDTH+x]:= (AMask or BMask) |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
251 |
else if Land[LAND_HEIGHT-1-y, x] and lfBouncy = lfBouncy then |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
252 |
PLongWordArray(p)^[y*LAND_WIDTH+x]:= (AMask or GMask) |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
253 |
else if Land[LAND_HEIGHT-1-y, x] and lfObject = lfObject then |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
254 |
PLongWordArray(p)^[y*LAND_WIDTH+x]:= $FFFFFFFF |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
255 |
else if Land[LAND_HEIGHT-1-y, x] and lfBasic = lfBasic then |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
256 |
PLongWordArray(p)^[y*LAND_WIDTH+x]:= AMask |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
257 |
else |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
258 |
PLongWordArray(p)^[y*LAND_WIDTH+x]:= 0 |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
259 |
end |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
260 |
end |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
261 |
else |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
262 |
// read pixels from the front buffer |
10633
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
263 |
begin |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
264 |
glReadPixels(0, 0, cScreenWidth, cScreenHeight, format, GL_UNSIGNED_BYTE, p); |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
265 |
{$IFDEF USE_VIDEO_RECORDING} |
10693 | 266 |
ReduceImage(p, cScreenWidth, cScreenHeight, k) |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
267 |
{$ENDIF} |
10633
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
268 |
end; |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
269 |
|
6881 | 270 |
// allocate and fill structure that will be passed to new thread |
271 |
New(image); // will be disposed in SaveScreenshot() |
|
10633
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
272 |
if dump = 2 then |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
273 |
image^.filename:= shortstring(UserPathPrefix) + filename + '_landpixels' + ext |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
274 |
else if dump = 1 then |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
275 |
image^.filename:= shortstring(UserPathPrefix) + filename + '_land' + ext |
10658 | 276 |
else image^.filename:= shortstring(UserPathPrefix) + filename + ext; |
10633
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
277 |
|
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
278 |
if dump <> 0 then |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
279 |
begin |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
280 |
image^.width:= LAND_WIDTH; |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
281 |
image^.height:= LAND_HEIGHT |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
282 |
end |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
283 |
else |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
284 |
begin |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
285 |
image^.width:= cScreenWidth div k; |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
286 |
image^.height:= cScreenHeight div k |
2f062fac5791
Add that "make screenshots of Land/LandPixels" thing for map creators
nemo
parents:
10150
diff
changeset
|
287 |
end; |
6881 | 288 |
image^.size:= size; |
289 |
image^.buffer:= p; |
|
1080 | 290 |
|
11358 | 291 |
SDL_CreateThread(@SaveScreenshot, PChar('snapshot'), image); |
6881 | 292 |
MakeScreenshot:= true; // possibly it is not true but we will not wait for thread to terminate |
1080 | 293 |
end; |
294 |
||
5004
2efa6a414518
update some sdl-1.3 bindings (working up to rev 5296)
koda
parents:
4976
diff
changeset
|
295 |
// http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860 |
2619 | 296 |
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface; |
5004
2efa6a414518
update some sdl-1.3 bindings (working up to rev 5296)
koda
parents:
4976
diff
changeset
|
297 |
var convertedSurf: PSDL_Surface; |
2619 | 298 |
begin |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6952
diff
changeset
|
299 |
doSurfaceConversion:= tmpsurf; |
5004
2efa6a414518
update some sdl-1.3 bindings (working up to rev 5296)
koda
parents:
4976
diff
changeset
|
300 |
if ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) or |
2efa6a414518
update some sdl-1.3 bindings (working up to rev 5296)
koda
parents:
4976
diff
changeset
|
301 |
(tmpsurf^.format^.bitsperpixel = 24) then |
7049 | 302 |
begin |
5046
fc6639d56799
this brings compatibility up with SDL HEAD (5504), but maybe breaks compatibility with sdl 1.2 so please test! still has problems with keyboard input and rendered ttf textures
koda
parents:
5004
diff
changeset
|
303 |
convertedSurf:= SDL_ConvertSurface(tmpsurf, conversionFormat, SDL_SWSURFACE); |
2947 | 304 |
SDL_FreeSurface(tmpsurf); |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6952
diff
changeset
|
305 |
doSurfaceConversion:= convertedSurf; |
7049 | 306 |
end; |
2619 | 307 |
end; |
308 |
||
6992 | 309 |
function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline; |
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6267
diff
changeset
|
310 |
begin |
6857 | 311 |
SDL_RectMake.x:= x; |
312 |
SDL_RectMake.y:= y; |
|
313 |
SDL_RectMake.w:= width; |
|
314 |
SDL_RectMake.h:= height; |
|
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6267
diff
changeset
|
315 |
end; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
316 |
|
4413 | 317 |
function GetTeamStatString(p: PTeam): shortstring; |
10124
aabd1b75d5a3
Even more explicit type conversions and other stuff to help pas2c use ansistrings
unc0rr
parents:
10108
diff
changeset
|
318 |
var s: shortstring; |
2670 | 319 |
begin |
4413 | 320 |
s:= p^.TeamName + ':' + IntToStr(p^.TeamHealth) + ':'; |
321 |
GetTeamStatString:= s; |
|
2670 | 322 |
end; |
2630 | 323 |
|
3038 | 324 |
procedure initModule; |
9311
5baf10a52f43
engine uses final (?) SDL 2 APIs, new events and types added. Touch input broke by the way, and system events should be handled differently
koda
parents:
9080
diff
changeset
|
325 |
const SDL_PIXELFORMAT_ABGR8888 = (1 shl 28) or (6 shl 24) or (7 shl 20) or (6 shl 16) or (32 shl 8) or 4; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
326 |
begin |
5052 | 327 |
conversionFormat:= SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888); |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
328 |
end; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
329 |
|
3038 | 330 |
procedure freeModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
331 |
begin |
5046
fc6639d56799
this brings compatibility up with SDL HEAD (5504), but maybe breaks compatibility with sdl 1.2 so please test! still has problems with keyboard input and rendered ttf textures
koda
parents:
5004
diff
changeset
|
332 |
SDL_FreeFormat(conversionFormat); |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
333 |
end; |
4 | 334 |
|
335 |
end. |