ref: add R_GammaChanged function that engine calls on every gamma change

This commit is contained in:
Alibek Omarov 2024-01-06 18:38:53 +03:00
parent c0757bd84c
commit a0c31120d9
7 changed files with 29 additions and 1 deletions

View File

@ -463,6 +463,7 @@ typedef struct ref_interface_s
void (*GL_ClearExtensions)( void ); void (*GL_ClearExtensions)( void );
// scene rendering // scene rendering
void (*R_GammaChanged)( qboolean do_reset_gamma );
void (*R_BeginFrame)( qboolean clearScene ); void (*R_BeginFrame)( qboolean clearScene );
void (*R_RenderScene)( void ); void (*R_RenderScene)( void );
void (*R_EndFrame)( void ); void (*R_EndFrame)( void );

View File

@ -372,6 +372,7 @@ ref_interface_t gReffuncs =
GL_InitExtensions, GL_InitExtensions,
GL_ClearExtensions, GL_ClearExtensions,
R_GammaChanged,
R_BeginFrame, R_BeginFrame,
R_RenderScene, R_RenderScene,
R_EndFrame, R_EndFrame,

View File

@ -402,7 +402,6 @@ void R_AllowFog( qboolean allowed );
qboolean R_OpaqueEntity( cl_entity_t *ent ); qboolean R_OpaqueEntity( cl_entity_t *ent );
void R_SetupFrustum( void ); void R_SetupFrustum( void );
void R_FindViewLeaf( void ); void R_FindViewLeaf( void );
void R_CheckGamma( void );
void R_PushScene( void ); void R_PushScene( void );
void R_PopScene( void ); void R_PopScene( void );
void R_DrawFog( void ); void R_DrawFog( void );
@ -534,6 +533,7 @@ int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags );
void GL_FreeImage( const char *name ); void GL_FreeImage( const char *name );
qboolean VID_ScreenShot( const char *filename, int shot_type ); qboolean VID_ScreenShot( const char *filename, int shot_type );
qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qboolean skyshot ); qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qboolean skyshot );
void R_GammaChanged( qboolean do_reset_gamma );
void R_BeginFrame( qboolean clearScene ); void R_BeginFrame( qboolean clearScene );
void R_RenderFrame( const struct ref_viewpass_s *vp ); void R_RenderFrame( const struct ref_viewpass_s *vp );
void R_EndFrame( void ); void R_EndFrame( void );

View File

@ -985,6 +985,22 @@ void R_RenderScene( void )
R_EndGL(); R_EndGL();
} }
void R_GammaChanged( qboolean do_reset_gamma )
{
if( do_reset_gamma )
{
// paranoia cubemap rendering
if( gEngfuncs.drawFuncs->GL_BuildLightmaps )
gEngfuncs.drawFuncs->GL_BuildLightmaps( );
}
else
{
glConfig.softwareGammaUpdate = true;
GL_RebuildLightmaps();
glConfig.softwareGammaUpdate = false;
}
}
/* /*
=============== ===============
R_BeginFrame R_BeginFrame

View File

@ -418,6 +418,7 @@ ref_interface_t gReffuncs =
GL_InitExtensions, GL_InitExtensions,
GL_ClearExtensions, GL_ClearExtensions,
R_GammaChanged,
R_BeginFrame, R_BeginFrame,
R_RenderScene, R_RenderScene,
R_EndFrame, R_EndFrame,

View File

@ -607,6 +607,7 @@ int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags );
void GL_FreeImage( const char *name ); void GL_FreeImage( const char *name );
qboolean VID_ScreenShot( const char *filename, int shot_type ); qboolean VID_ScreenShot( const char *filename, int shot_type );
qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qboolean skyshot ); qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qboolean skyshot );
void R_GammaChanged( qboolean do_reset_gamma );
void R_BeginFrame( qboolean clearScene ); void R_BeginFrame( qboolean clearScene );
void R_RenderFrame( const struct ref_viewpass_s *vp ); void R_RenderFrame( const struct ref_viewpass_s *vp );
void R_EndFrame( void ); void R_EndFrame( void );

View File

@ -1636,6 +1636,14 @@ qboolean R_DoResetGamma( void )
#endif #endif
} }
void R_GammaChanged( qboolean do_reset_gamma )
{
if( do_reset_gamma ) // unused
return;
D_FlushCaches( );
}
/* /*
=============== ===============
R_BeginFrame R_BeginFrame