author | koda |
Thu, 04 Apr 2013 01:38:30 +0200 | |
branch | webgl |
changeset 8850 | ae8a957c69fd |
parent 8026 | 4a4f21070479 |
child 9127 | e350500c4edb |
permissions | -rw-r--r-- |
4 | 1 |
(* |
6952 | 2 |
* Hedgewars, a free turn based strategy game |
3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
|
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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
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 |
|
3169
c8c6ac44f51b
prophylactic removal of some Integer references, raise a few of the template islands up a bit so they work inverted without triggering border
nemo
parents:
3165
diff
changeset
|
29 |
procedure movecursor(dx, dy: LongInt); |
2670 | 30 |
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface; |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
31 |
function MakeScreenshot(filename: shortstring; k: LongInt): boolean; |
4413 | 32 |
function GetTeamStatString(p: PTeam): shortstring; |
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6267
diff
changeset
|
33 |
{$IFDEF SDL13} |
6992 | 34 |
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
|
35 |
{$ELSE} |
6992 | 36 |
function SDL_RectMake(x, y: SmallInt; width, height: Word): 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
|
37 |
{$ENDIF} |
4 | 38 |
|
39 |
implementation |
|
7043
7c080e5ac8d0
Some work to make more units compile after conversion to c
unc0rr
parents:
6992
diff
changeset
|
40 |
uses SysUtils, uVariables, uUtils |
6881 | 41 |
{$IFDEF PNG_SCREENSHOTS}, PNGh, png {$ENDIF} |
42 |
{$IFNDEF USE_SDLTHREADS} {$IFDEF UNIX}, cthreads{$ENDIF} {$ENDIF}; |
|
43 |
||
44 |
type PScreenshot = ^TScreenshot; |
|
45 |
TScreenshot = record |
|
46 |
buffer: PByte; |
|
47 |
filename: shortstring; |
|
48 |
width, height: LongInt; |
|
49 |
size: QWord; |
|
50 |
end; |
|
3756 | 51 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7848
diff
changeset
|
52 |
var conversionFormat : PSDL_PixelFormat; |
7049 | 53 |
|
3169
c8c6ac44f51b
prophylactic removal of some Integer references, raise a few of the template islands up a bit so they work inverted without triggering border
nemo
parents:
3165
diff
changeset
|
54 |
procedure movecursor(dx, dy: LongInt); |
2428 | 55 |
var x, y: LongInt; |
56 |
begin |
|
57 |
if (dx = 0) and (dy = 0) then exit; |
|
2671
7e0f88013fe8
smaller patches, one missing Sky-lowres, IMG_Init and Mix_Init (might require newer libraries), updates to SDL bindings, code cleanup, new compile flags
koda
parents:
2670
diff
changeset
|
58 |
|
2428 | 59 |
SDL_GetMouseState(@x, @y); |
60 |
Inc(x, dx); |
|
61 |
Inc(y, dy); |
|
62 |
SDL_WarpMouse(x, y); |
|
63 |
end; |
|
64 |
||
6881 | 65 |
{$IFDEF PNG_SCREENSHOTS} |
66 |
// this funtion will be executed in separate thread |
|
67 |
function SaveScreenshot(screenshot: pointer): PtrInt; |
|
68 |
var i: LongInt; |
|
69 |
png_ptr: ^png_struct; |
|
70 |
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
|
71 |
f: File; |
6881 | 72 |
image: PScreenshot; |
73 |
begin |
|
74 |
image:= PScreenshot(screenshot); |
|
75 |
||
76 |
png_ptr := png_create_write_struct(png_get_libpng_ver(nil), nil, nil, nil); |
|
77 |
if png_ptr = nil then |
|
78 |
begin |
|
79 |
// 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
|
80 |
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
|
81 |
exit; |
6881 | 82 |
end; |
83 |
||
84 |
info_ptr := png_create_info_struct(png_ptr); |
|
85 |
if info_ptr = nil then |
|
86 |
begin |
|
87 |
png_destroy_write_struct(@png_ptr, nil); |
|
88 |
// 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
|
89 |
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
|
90 |
exit; |
6881 | 91 |
end; |
92 |
||
93 |
{$IOCHECKS OFF} |
|
94 |
Assign(f, image^.filename); |
|
95 |
Rewrite(f, 1); |
|
96 |
if IOResult = 0 then |
|
97 |
begin |
|
98 |
png_init_pascal_io(png_ptr,@f); |
|
99 |
png_set_IHDR(png_ptr, info_ptr, image^.width, image^.height, |
|
100 |
8, // bit depth |
|
101 |
PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, |
|
102 |
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); |
|
103 |
png_write_info(png_ptr, info_ptr); |
|
104 |
// glReadPixels and libpng number rows in different order |
|
105 |
for i:= image^.height-1 downto 0 do |
|
106 |
png_write_row(png_ptr, image^.buffer + i*4*image^.width); |
|
107 |
png_write_end(png_ptr, info_ptr); |
|
108 |
Close(f); |
|
109 |
end; |
|
110 |
{$IOCHECKS ON} |
|
111 |
||
112 |
// free everything |
|
113 |
png_destroy_write_struct(@png_ptr, @info_ptr); |
|
114 |
FreeMem(image^.buffer, image^.size); |
|
115 |
Dispose(image); |
|
116 |
SaveScreenshot:= 0; |
|
117 |
end; |
|
118 |
||
119 |
{$ELSE} // no PNG_SCREENSHOTS |
|
120 |
||
121 |
// this funtion will be executed in separate thread |
|
122 |
function SaveScreenshot(screenshot: pointer): PtrInt; |
|
123 |
var f: file; |
|
2947 | 124 |
// Windows Bitmap Header |
125 |
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
|
126 |
$42, $4D, // identifier ("BM") |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
127 |
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
|
128 |
0, 0, 0, 0, // reserved |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
129 |
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
|
130 |
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
|
131 |
0, 0, 0, 0, // width |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
132 |
0, 0, 0, 0, // height |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
133 |
1, 0, // color planes |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
134 |
32, 0, // bit depth |
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
135 |
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
|
136 |
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
|
137 |
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
|
138 |
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
|
139 |
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
|
140 |
0, 0, 0, 0 // number of important colors |
2947 | 141 |
); |
6881 | 142 |
image: PScreenshot; |
143 |
size: QWord; |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7848
diff
changeset
|
144 |
writeResult:LongInt; |
6881 | 145 |
begin |
146 |
image:= PScreenshot(screenshot); |
|
147 |
||
148 |
size:= image^.Width*image^.Height*4; |
|
149 |
||
150 |
head[$02]:= (size + 54) and $ff; |
|
151 |
head[$03]:= ((size + 54) shr 8) and $ff; |
|
152 |
head[$04]:= ((size + 54) shr 16) and $ff; |
|
153 |
head[$05]:= ((size + 54) shr 24) and $ff; |
|
154 |
head[$12]:= image^.Width and $ff; |
|
155 |
head[$13]:= (image^.Width shr 8) and $ff; |
|
156 |
head[$14]:= (image^.Width shr 16) and $ff; |
|
157 |
head[$15]:= (image^.Width shr 24) and $ff; |
|
158 |
head[$16]:= image^.Height and $ff; |
|
159 |
head[$17]:= (image^.Height shr 8) and $ff; |
|
160 |
head[$18]:= (image^.Height shr 16) and $ff; |
|
161 |
head[$19]:= (image^.Height shr 24) and $ff; |
|
162 |
head[$22]:= size and $ff; |
|
163 |
head[$23]:= (size shr 8) and $ff; |
|
164 |
head[$24]:= (size shr 16) and $ff; |
|
165 |
head[$25]:= (size shr 24) and $ff; |
|
166 |
||
167 |
{$IOCHECKS OFF} |
|
168 |
Assign(f, image^.filename); |
|
169 |
Rewrite(f, 1); |
|
170 |
if IOResult = 0 then |
|
171 |
begin |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7848
diff
changeset
|
172 |
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
|
173 |
BlockWrite(f, image^.buffer^, size, writeResult); |
6881 | 174 |
Close(f); |
175 |
end |
|
176 |
else |
|
177 |
begin |
|
178 |
//AddFileLog('Error: Could not write to ' + filename); |
|
179 |
end; |
|
180 |
{$IOCHECKS ON} |
|
181 |
||
182 |
// free everything |
|
183 |
FreeMem(image^.buffer, image^.size); |
|
184 |
Dispose(image); |
|
185 |
SaveScreenshot:= 0; |
|
186 |
end; |
|
187 |
||
188 |
{$ENDIF} // no PNG_SCREENSHOTS |
|
189 |
||
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
190 |
{$IFDEF USE_VIDEO_RECORDING} |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
191 |
// make image k times smaller (useful for saving thumbnails) |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
192 |
procedure ReduceImage(img: PByte; width, height, k: LongInt); |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
193 |
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
|
194 |
begin |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
195 |
w:= width div k; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
196 |
h:= height div k; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
197 |
|
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
198 |
// rescale inplace |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
199 |
if k <> 1 then |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
200 |
begin |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
201 |
for i:= 0 to h-1 do |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
202 |
for j:= 0 to w-1 do |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
203 |
begin |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
204 |
r:= 0; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
205 |
g:= 0; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
206 |
b:= 0; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
207 |
for i0:= 0 to k-1 do |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
208 |
for j0:= 0 to k-1 do |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
209 |
begin |
7804 | 210 |
inc(r, img[4*(width*(i*k+i0) + j*k+j0)+0]); |
211 |
inc(g, img[4*(width*(i*k+i0) + j*k+j0)+1]); |
|
212 |
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
|
213 |
end; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
214 |
img[4*(w*i + j)+0]:= r div (k*k); |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
215 |
img[4*(w*i + j)+1]:= g div (k*k); |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
216 |
img[4*(w*i + j)+2]:= b div (k*k); |
7365
26df99967963
fix alpha channel in image rescaling
Stepan777 <stepik-777@mail.ru>
parents:
7306
diff
changeset
|
217 |
img[4*(w*i + j)+3]:= 255; |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
218 |
end; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
219 |
end; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
220 |
end; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
221 |
{$ENDIF} |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
222 |
|
6881 | 223 |
// captures and saves the screen. returns true on success. |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
224 |
// saved image will be k times smaller than original (useful for saving thumbnails). |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
225 |
function MakeScreenshot(filename: shortstring; k: LongInt): Boolean; |
6881 | 226 |
var p: Pointer; |
227 |
size: QWord; |
|
228 |
image: PScreenshot; |
|
229 |
format: GLenum; |
|
230 |
ext: string[4]; |
|
1080 | 231 |
begin |
6881 | 232 |
{$IFDEF PNG_SCREENSHOTS} |
233 |
format:= GL_RGBA; |
|
234 |
ext:= '.png'; |
|
235 |
{$ELSE} |
|
236 |
format:= GL_BGRA; |
|
237 |
ext:= '.bmp'; |
|
238 |
{$ENDIF} |
|
239 |
||
6267
be5d40bb1e86
make screenshots with 32bits of depths, so that they are more opengles friendly
koda
parents:
5912
diff
changeset
|
240 |
size:= toPowerOf2(cScreenWidth) * toPowerOf2(cScreenHeight) * 4; |
6881 | 241 |
p:= GetMem(size); // will be freed in SaveScreenshot() |
1080 | 242 |
|
5910 | 243 |
// memory could not be allocated |
244 |
if p = nil then |
|
5912
d31eba29e706
screenshots: display a msg on failure and log causative error
sheepluva
parents:
5911
diff
changeset
|
245 |
begin |
d31eba29e706
screenshots: display a msg on failure and log causative error
sheepluva
parents:
5911
diff
changeset
|
246 |
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
|
247 |
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
|
248 |
exit; |
5912
d31eba29e706
screenshots: display a msg on failure and log causative error
sheepluva
parents:
5911
diff
changeset
|
249 |
end; |
5910 | 250 |
|
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
251 |
// read pixels from the front buffer |
6881 | 252 |
glReadPixels(0, 0, cScreenWidth, cScreenHeight, format, GL_UNSIGNED_BYTE, p); |
2163
12730f5e79b9
koda's patch fixing some iphone port troubles (color, mouse)
unc0rr
parents:
2162
diff
changeset
|
253 |
|
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
254 |
{$IFDEF USE_VIDEO_RECORDING} |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
255 |
ReduceImage(p, cScreenWidth, cScreenHeight, k); |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
256 |
{$ENDIF} |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
257 |
|
6881 | 258 |
// allocate and fill structure that will be passed to new thread |
259 |
New(image); // will be disposed in SaveScreenshot() |
|
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
260 |
image^.filename:= UserPathPrefix + filename + ext; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
261 |
image^.width:= cScreenWidth div k; |
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7049
diff
changeset
|
262 |
image^.height:= cScreenHeight div k; |
6881 | 263 |
image^.size:= size; |
264 |
image^.buffer:= p; |
|
1080 | 265 |
|
6881 | 266 |
{$IFDEF USE_SDLTHREADS} |
267 |
SDL_CreateThread(@SaveScreenshot{$IFDEF SDL13}, nil{$ENDIF}, image); |
|
268 |
{$ELSE} |
|
269 |
BeginThread(@SaveScreenshot, image); |
|
270 |
{$ENDIF} |
|
271 |
MakeScreenshot:= true; // possibly it is not true but we will not wait for thread to terminate |
|
1080 | 272 |
end; |
273 |
||
5004
2efa6a414518
update some sdl-1.3 bindings (working up to rev 5296)
koda
parents:
4976
diff
changeset
|
274 |
// http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860 |
2619 | 275 |
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
|
276 |
var convertedSurf: PSDL_Surface; |
2619 | 277 |
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
|
278 |
doSurfaceConversion:= tmpsurf; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7848
diff
changeset
|
279 |
{$IFNDEF WEBGL} |
5004
2efa6a414518
update some sdl-1.3 bindings (working up to rev 5296)
koda
parents:
4976
diff
changeset
|
280 |
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
|
281 |
(tmpsurf^.format^.bitsperpixel = 24) then |
7049 | 282 |
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
|
283 |
convertedSurf:= SDL_ConvertSurface(tmpsurf, conversionFormat, SDL_SWSURFACE); |
2947 | 284 |
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
|
285 |
doSurfaceConversion:= convertedSurf; |
7049 | 286 |
end; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7848
diff
changeset
|
287 |
{$ENDIF} |
2619 | 288 |
end; |
289 |
||
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6267
diff
changeset
|
290 |
{$IFDEF SDL13} |
6992 | 291 |
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
|
292 |
{$ELSE} |
6992 | 293 |
function SDL_RectMake(x, y: SmallInt; width, height: Word): 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
|
294 |
{$ENDIF} |
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6267
diff
changeset
|
295 |
begin |
6857 | 296 |
SDL_RectMake.x:= x; |
297 |
SDL_RectMake.y:= y; |
|
298 |
SDL_RectMake.w:= width; |
|
299 |
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
|
300 |
end; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
301 |
|
4413 | 302 |
function GetTeamStatString(p: PTeam): shortstring; |
303 |
var s: ansistring; |
|
2670 | 304 |
begin |
4413 | 305 |
s:= p^.TeamName + ':' + IntToStr(p^.TeamHealth) + ':'; |
306 |
GetTeamStatString:= s; |
|
2670 | 307 |
end; |
2630 | 308 |
|
3038 | 309 |
procedure initModule; |
6843
59da15acb2f2
Finally fix the bug with pointer declarations polluting namespace with bad records
unc0rr
parents:
6700
diff
changeset
|
310 |
const SDL_PIXELFORMAT_ABGR8888 = (1 shl 31) 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
|
311 |
begin |
5052 | 312 |
conversionFormat:= SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888); |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
313 |
end; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
314 |
|
3038 | 315 |
procedure freeModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
316 |
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
|
317 |
SDL_FreeFormat(conversionFormat); |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
318 |
end; |
4 | 319 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7848
diff
changeset
|
320 |
end. |