* split TglBitmap into TglBitmap and TglBitmapData to be able to handle load, save...
[LazOpenGLCore.git] / examples / GrabScreen / GrabScreen.lpr
index c3b7b77..97acff5 100644 (file)
@@ -14,7 +14,7 @@ var
 
 function WindowProc(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
 var
-  tex: TglBitmap2D;
+  data: TglBitmapData;
 begin
   case Msg of
     WM_DESTROY: begin
@@ -23,13 +23,15 @@ 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;