function WindowProc(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
var
- tex: TglBitmap2D;
+ data: TglBitmapData;
begin
case Msg of
WM_DESTROY: begin
WM_KEYDOWN: begin
if wParam = VK_RETURN then begin
- tex := TglBitmap2D.Create; // create empty texture
+ data := TglBitmapData.Create; // create texture data object
try
- tex.GrabScreen(0, 0, 800, 600, tfRGB8ub3); // copy current framebuffer content to texture
- tex.SaveToFile(ExtractFilePath(ApplicationName) + 'screen.bmp', ftBMP); // save texture to file
+ TglBitmap2D.GrabScreen(0, 0, 800, 600, tfRGBA8ui1, data); // read pixels from frame buffer
+ data.SaveToFile( // save data to file
+ ExtractFilePath(ApplicationName) +
+ 'screen.bmp', ftBMP);
WriteLn('screen saved to screen.bmp');
finally
- FreeAndNil(tex);
+ FreeAndNil(data); // free texture data object when done
end;
end;
end;