2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-12-22 17:01:14 +01:00

ref: soft: fail to the engine if CreateBuffer has failed (otherwise it sits in infinite loop)

This commit is contained in:
Alibek Omarov 2024-08-11 18:27:45 +03:00
parent ab499d5095
commit e222a74960
3 changed files with 26 additions and 11 deletions

View File

@ -622,9 +622,9 @@ static void R_BuildBlendMaps( void )
#endif
}
void R_AllocScreen( void );
static qboolean R_AllocScreen( void );
void R_InitBlit( qboolean glblit )
qboolean R_InitBlit( qboolean glblit )
{
R_BuildBlendMaps();
@ -646,10 +646,11 @@ void R_InitBlit( qboolean glblit )
swblit.pUnlockBuffer = gEngfuncs.SW_UnlockBuffer;
swblit.pCreateBuffer = gEngfuncs.SW_CreateBuffer;
}
R_AllocScreen();
return R_AllocScreen();
}
void R_AllocScreen( void )
static qboolean R_AllocScreen( void )
{
int w, h;
@ -661,12 +662,20 @@ void R_AllocScreen( void )
R_InitCaches();
if( swblit.rotate )
w = gpGlobals->height, h = gpGlobals->width;
{
w = gpGlobals->height;
h = gpGlobals->width;
}
else
h = gpGlobals->height, w = gpGlobals->width;
{
w = gpGlobals->width;
h = gpGlobals->height;
}
if( !swblit.pCreateBuffer( w, h, &swblit.stride, &swblit.bpp,
&swblit.rmask, &swblit.gmask, &swblit.bmask ))
return false;
swblit.pCreateBuffer( w, h, &swblit.stride, &swblit.bpp,
&swblit.rmask, &swblit.gmask, &swblit.bmask);
R_BuildScreenMap();
vid.width = gpGlobals->width;
vid.height = gpGlobals->height;
@ -674,10 +683,12 @@ void R_AllocScreen( void )
if( d_pzbuffer )
free( d_pzbuffer );
d_pzbuffer = malloc( vid.width*vid.height*2 + 64 );
if( vid.buffer )
free( vid.buffer );
vid.buffer = malloc( vid.width * vid.height*sizeof( pixel_t ) );
return true;
}
void R_BlitScreen( void )

View File

@ -1173,7 +1173,7 @@ void R_DrawBrushModel(cl_entity_t *pent);
//
void R_InitCaches (void);
void R_BlitScreen( void );
void R_InitBlit( qboolean gl );
qboolean R_InitBlit( qboolean gl );
qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int offset_y, float scale_x, float scale_y );
//

View File

@ -1898,7 +1898,11 @@ qboolean GAME_EXPORT R_Init( void )
tr.palette = (color24 *)ENGINE_GET_PARM( PARM_GET_PALETTE_PTR );
tr.viewent = (cl_entity_t *)ENGINE_GET_PARM( PARM_GET_VIEWENT_PTR );
R_InitBlit( glblit );
if( !R_InitBlit( glblit ))
{
gEngfuncs.R_Free_Video();
return false;
}
R_InitImages();
// init draw stack