51 p: Pointer; |
51 p: Pointer; |
52 size: QWord; |
52 size: QWord; |
53 f: file; |
53 f: file; |
54 // Windows Bitmap Header |
54 // Windows Bitmap Header |
55 head: array[0..53] of Byte = ( |
55 head: array[0..53] of Byte = ( |
56 $42, $4D, // identifier ("BM") |
56 $42, $4D, // identifier ("BM") |
57 0, 0, 0, 0, // file size |
57 0, 0, 0, 0, // file size |
58 0, 0, 0, 0, // reserved |
58 0, 0, 0, 0, // reserved |
59 54, 0, 0, 0, // starting offset |
59 54, 0, 0, 0, // starting offset |
60 40, 0, 0, 0, // header size |
60 40, 0, 0, 0, // header size |
61 0, 0, 0, 0, // width |
61 0, 0, 0, 0, // width |
62 0, 0, 0, 0, // height |
62 0, 0, 0, 0, // height |
63 1, 0, // color planes |
63 1, 0, // color planes |
64 24, 0, // bit depth |
64 32, 0, // bit depth |
65 0, 0, 0, 0, // compression method (uncompressed) |
65 0, 0, 0, 0, // compression method (uncompressed) |
66 0, 0, 0, 0, // image size |
66 0, 0, 0, 0, // image size |
67 96, 0, 0, 0, // horizontal resolution |
67 96, 0, 0, 0, // horizontal resolution |
68 96, 0, 0, 0, // vertical resolution |
68 96, 0, 0, 0, // vertical resolution |
69 0, 0, 0, 0, // number of colors (all) |
69 0, 0, 0, 0, // number of colors (all) |
70 0, 0, 0, 0 // number of important colors |
70 0, 0, 0, 0 // number of important colors |
71 ); |
71 ); |
72 begin |
72 begin |
73 // flash |
73 // flash |
74 ScreenFade:= sfFromWhite; |
74 ScreenFade:= sfFromWhite; |
75 ScreenFadeValue:= sfMax; |
75 ScreenFadeValue:= sfMax; |
76 ScreenFadeSpeed:= 5; |
76 ScreenFadeSpeed:= 5; |
77 |
77 |
78 size:= toPowerOf2(cScreenWidth) * toPowerOf2(cScreenHeight) * 3; |
78 size:= toPowerOf2(cScreenWidth) * toPowerOf2(cScreenHeight) * 4; |
79 p:= GetMem(size); |
79 p:= GetMem(size); |
80 |
80 |
81 // memory could not be allocated |
81 // memory could not be allocated |
82 if p = nil then |
82 if p = nil then |
83 begin |
83 begin |
84 AddFileLog('Error: Could not allocate memory for screenshot.'); |
84 AddFileLog('Error: Could not allocate memory for screenshot.'); |
85 exit(false); |
85 exit(false); |
86 end; |
86 end; |
87 |
87 |
88 // update header information and file name |
88 // update header information and file name |
89 |
|
90 filename:= UserPathPrefix + '/Screenshots/' + filename + '.bmp'; |
89 filename:= UserPathPrefix + '/Screenshots/' + filename + '.bmp'; |
91 |
90 |
92 head[$02]:= (size + 54) and $ff; |
91 head[$02]:= (size + 54) and $ff; |
93 head[$03]:= ((size + 54) shr 8) and $ff; |
92 head[$03]:= ((size + 54) shr 8) and $ff; |
94 head[$04]:= ((size + 54) shr 16) and $ff; |
93 head[$04]:= ((size + 54) shr 16) and $ff; |
104 head[$22]:= size and $ff; |
103 head[$22]:= size and $ff; |
105 head[$23]:= (size shr 8) and $ff; |
104 head[$23]:= (size shr 8) and $ff; |
106 head[$24]:= (size shr 16) and $ff; |
105 head[$24]:= (size shr 16) and $ff; |
107 head[$25]:= (size shr 24) and $ff; |
106 head[$25]:= (size shr 24) and $ff; |
108 |
107 |
109 //remember that opengles operates on a single surface, so GL_FRONT *should* be implied |
108 // read pixel from the front buffer |
110 //glReadBuffer(GL_FRONT); |
109 glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_BGRA, GL_UNSIGNED_BYTE, p); |
111 glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_BGR, GL_UNSIGNED_BYTE, p); |
|
112 |
110 |
113 {$IOCHECKS OFF} |
111 {$IOCHECKS OFF} |
114 Assign(f, filename); |
112 Assign(f, filename); |
115 Rewrite(f, 1); |
113 Rewrite(f, 1); |
116 if IOResult = 0 then |
114 if IOResult = 0 then |