diff --git a/ref/soft/r_glblit.c b/ref/soft/r_glblit.c index 174c6ede..54dcbfa1 100644 --- a/ref/soft/r_glblit.c +++ b/ref/soft/r_glblit.c @@ -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 ) diff --git a/ref/soft/r_local.h b/ref/soft/r_local.h index cd56b720..1cb47656 100644 --- a/ref/soft/r_local.h +++ b/ref/soft/r_local.h @@ -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 ); // diff --git a/ref/soft/r_main.c b/ref/soft/r_main.c index da557f33..594de007 100644 --- a/ref/soft/r_main.c +++ b/ref/soft/r_main.c @@ -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