@@ -1347,24 +1347,37 @@ void WW3D::Make_Screen_Shot( const char * filename_base , const float gamma, con
13471347 gamma_lut[i] = (unsigned char ) (256 .0f * powf (i / 256 .0f , recip));
13481348 }
13491349
1350- // Lock front buffer and copy
1350+ // TheSuperHackers @bugfix xezon 21/05/2025 Get the back buffer and create a copy of the surface.
1351+ // Originally this code took the front buffer and tried to lock it. This does not work when the
1352+ // render view clips outside the desktop boundaries. It crashed the game.
1353+ SurfaceClass* surface = DX8Wrapper::_Get_DX8_Back_Buffer ();
13511354
1352- IDirect3DSurface8 *fb;
1353- fb=DX8Wrapper::_Get_DX8_Front_Buffer ();
1354- D3DSURFACE_DESC desc;
1355- fb->GetDesc (&desc);
1355+ SurfaceClass::SurfaceDescription surfaceDesc;
1356+ surface->Get_Description (surfaceDesc);
13561357
1357- RECT bounds;
1358- GetWindowRect (_Hwnd,&bounds);
1358+ SurfaceClass* surfaceCopy = NEW_REF (SurfaceClass, (DX8Wrapper::_Create_DX8_Surface (surfaceDesc.Width , surfaceDesc.Height , surfaceDesc.Format )));
1359+ DX8Wrapper::_Copy_DX8_Rects (surface->Peek_D3D_Surface (), NULL , 0 , surfaceCopy->Peek_D3D_Surface (), NULL );
1360+
1361+ surface->Release_Ref ();
1362+ surface = NULL ;
13591363
1360- D3DLOCKED_RECT lrect;
1364+ struct Rect
1365+ {
1366+ int Pitch;
1367+ void * pBits;
1368+ } lrect;
13611369
1362- DX8_ErrorCode (fb->LockRect (&lrect,&bounds,D3DLOCK_READONLY));
1370+ lrect.pBits = surfaceCopy->Lock (&lrect.Pitch );
1371+ if (lrect.pBits == NULL )
1372+ {
1373+ surfaceCopy->Release_Ref ();
1374+ return ;
1375+ }
13631376
13641377 unsigned int x,y,index,index2,width,height;
13651378
1366- width=bounds. right -bounds. left ;
1367- height=bounds. bottom -bounds. top ;
1379+ width = surfaceDesc. Width ;
1380+ height = surfaceDesc. Height ;
13681381
13691382 unsigned char *image=W3DNEWARRAY unsigned char [3 *width*height];
13701383
@@ -1383,7 +1396,9 @@ void WW3D::Make_Screen_Shot( const char * filename_base , const float gamma, con
13831396 }
13841397 }
13851398
1386- fb->Release ();
1399+ surfaceCopy->Unlock ();
1400+ surfaceCopy->Release_Ref ();
1401+ surfaceCopy = NULL ;
13871402
13881403 switch (format) {
13891404 case TGA:
@@ -1682,24 +1697,37 @@ void WW3D::Update_Movie_Capture( void )
16821697 WWPROFILE (" WW3D::Update_Movie_Capture" );
16831698 WWDEBUG_SAY (( " Updating\n " ));
16841699
1685- // Lock front buffer and copy
1700+ // TheSuperHackers @bugfix xezon 21/05/2025 Get the back buffer and create a copy of the surface.
1701+ // Originally this code took the front buffer and tried to lock it. This does not work when the
1702+ // render view clips outside the desktop boundaries. It crashed the game.
1703+ SurfaceClass* surface = DX8Wrapper::_Get_DX8_Back_Buffer ();
16861704
1687- IDirect3DSurface8 *fb;
1688- fb=DX8Wrapper::_Get_DX8_Front_Buffer ();
1689- D3DSURFACE_DESC desc;
1690- fb->GetDesc (&desc);
1705+ SurfaceClass::SurfaceDescription surfaceDesc;
1706+ surface->Get_Description (surfaceDesc);
16911707
1692- RECT bounds;
1693- GetWindowRect (_Hwnd,&bounds);
1708+ SurfaceClass* surfaceCopy = NEW_REF (SurfaceClass, (DX8Wrapper::_Create_DX8_Surface (surfaceDesc.Width , surfaceDesc.Height , surfaceDesc.Format )));
1709+ DX8Wrapper::_Copy_DX8_Rects (surface->Peek_D3D_Surface (), NULL , 0 , surfaceCopy->Peek_D3D_Surface (), NULL );
1710+
1711+ surface->Release_Ref ();
1712+ surface = NULL ;
16941713
1695- D3DLOCKED_RECT lrect;
1714+ struct Rect
1715+ {
1716+ int Pitch;
1717+ void * pBits;
1718+ } lrect;
16961719
1697- DX8_ErrorCode (fb->LockRect (&lrect,&bounds,D3DLOCK_READONLY));
1720+ lrect.pBits = surfaceCopy->Lock (&lrect.Pitch );
1721+ if (lrect.pBits == NULL )
1722+ {
1723+ surfaceCopy->Release_Ref ();
1724+ return ;
1725+ }
16981726
16991727 unsigned int x,y,index,index2,width,height;
17001728
1701- width=bounds. right -bounds. left ;
1702- height=bounds. bottom -bounds. top ;
1729+ width = surfaceDesc. Width ;
1730+ height = surfaceDesc. Height ;
17031731
17041732 char *image=(char *)Movie->GetBuffer ();
17051733
@@ -1718,7 +1746,9 @@ void WW3D::Update_Movie_Capture( void )
17181746 }
17191747 }
17201748
1721- fb->Release ();
1749+ surfaceCopy->Unlock ();
1750+ surfaceCopy->Release_Ref ();
1751+ surfaceCopy = NULL ;
17221752
17231753 Movie->Grab (image);
17241754#endif
0 commit comments