# HG changeset patch # User unc0rr # Date 1216067069 0 # Node ID 8735046fc6987577939a65a1b2101ff7153fb1af # Parent 2a4a8a5ca3926de097499dacaac9d93f450d0c5b Repair screenshots capture on 'C' key press diff -r 2a4a8a5ca392 -r 8735046fc698 hedgewars/hwengine.dpr --- a/hedgewars/hwengine.dpr Sun Jul 13 17:58:05 2008 +0000 +++ b/hedgewars/hwengine.dpr Mon Jul 14 20:24:29 2008 +0000 @@ -67,7 +67,7 @@ //////////////////////////////// procedure DoTimer(Lag: LongInt); const MusicTimerTicks: Longword = 0; -//var s: string; +var s: string; begin inc(RealTicks, Lag); @@ -119,11 +119,12 @@ SDL_GL_SwapBuffers(); if flagMakeCapture then begin -{ flagMakeCapture:= false; - s:= 'hw_' + cSeed + '_' + inttostr(GameTicks) + '.bmp'; + flagMakeCapture:= false; + s:= 'hw_' + cSeed + '_' + inttostr(GameTicks) + '.tga'; WriteLnToConsole('Saving ' + s); - SDL_SaveBMP_RW(SDLPrimSurface, SDL_RWFromFile(Str2PChar(s), 'wb'), 1) -} end; + MakeScreenshot(s); +// SDL_SaveBMP_RW(SDLPrimSurface, SDL_RWFromFile(Str2PChar(s), 'wb'), 1) + end; end; //////////////////// diff -r 2a4a8a5ca392 -r 8735046fc698 hedgewars/uMisc.pas --- a/hedgewars/uMisc.pas Sun Jul 13 17:58:05 2008 +0000 +++ b/hedgewars/uMisc.pas Mon Jul 14 20:24:29 2008 +0000 @@ -121,6 +121,7 @@ procedure FreeTexture(tex: PTexture); function toPowerOf2(i: Longword): Longword; function DecodeBase64(s: shortstring): shortstring; +procedure MakeScreenshot(s: shortstring); var CursorPoint: TPoint; TargetPoint: TPoint = (X: NoPointX; Y: 0); @@ -345,6 +346,36 @@ byte(DecodeBase64[0]):= t - 1 end; +const GL_BGR = $80E0; // some opengl headers don't have that const (?) +procedure MakeScreenshot(s: shortstring); +const head: array[0..8] of Word = (0, 2, 0, 0, 0, 0, 0, 0, 24); +var p: Pointer; + size: Longword; + f: file; +begin +head[6]:= cScreenWidth; +head[7]:= cScreenHeight; + +size:= cScreenWidth * cScreenHeight * 3; +p:= GetMem(size); + +glReadBuffer(GL_FRONT); +glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_BGR, GL_UNSIGNED_BYTE, p); + +{$I-} +Assign(f, s); +Rewrite(f, 1); +if IOResult = 0 then + begin + BlockWrite(f, head, sizeof(head)); + BlockWrite(f, p^, size); + Close(f); + end; +{$I+} + +FreeMem(p) +end; + {$IFDEF DEBUGFILE} procedure AddFileLog(s: shortstring); begin