From 3ae7ecaeb388e8d94fef69077908680699312c00 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 17 Jun 2019 08:37:34 +0300 Subject: [PATCH] engine: patched to compile, moved gl_clear to engine --- engine/client/ref_common.c | 2 ++ engine/client/ref_common.h | 1 + engine/common/mod_bmodel.c | 41 -------------------------------------- engine/common/model.c | 6 ++++++ ref_gl/gl_image.c | 2 +- ref_gl/gl_opengl.c | 2 +- ref_gl/gl_rmain.c | 8 ++++---- 7 files changed, 15 insertions(+), 47 deletions(-) diff --git a/engine/client/ref_common.c b/engine/client/ref_common.c index c0fb2920..7f965f1c 100644 --- a/engine/client/ref_common.c +++ b/engine/client/ref_common.c @@ -13,6 +13,7 @@ convar_t *gl_showtextures; convar_t *r_decals; convar_t *r_adjust_fov; convar_t *gl_wgl_msaa_samples; +convar_t *gl_clear; void R_GetTextureParms( int *w, int *h, int texnum ) { @@ -540,6 +541,7 @@ qboolean R_Init( void ) r_adjust_fov = Cvar_Get( "r_adjust_fov", "1", FCVAR_ARCHIVE, "making FOV adjustment for wide-screens" ); r_decals = Cvar_Get( "r_decals", "4096", FCVAR_ARCHIVE, "sets the maximum number of decals" ); gl_wgl_msaa_samples = Cvar_Get( "gl_wgl_msaa_samples", "0", FCVAR_GLCONFIG, "samples number for multisample anti-aliasing" ); + gl_clear = Cvar_Get( "gl_clear", "0", FCVAR_ARCHIVE, "clearing screen after each frame" ); if( !R_LoadProgs( refdll )) { diff --git a/engine/client/ref_common.h b/engine/client/ref_common.h index ea79cb40..19d527a0 100644 --- a/engine/client/ref_common.h +++ b/engine/client/ref_common.h @@ -43,6 +43,7 @@ void GL_RenderFrame( const struct ref_viewpass_s *rvp ); // common engine and renderer cvars extern convar_t *r_decals; extern convar_t *r_adjust_fov; +extern convar_t *gl_clear; qboolean R_Init( void ); void R_Shutdown( void ); diff --git a/engine/common/mod_bmodel.c b/engine/common/mod_bmodel.c index 5ed241f7..a8cf354e 100644 --- a/engine/common/mod_bmodel.c +++ b/engine/common/mod_bmodel.c @@ -2928,47 +2928,6 @@ void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *loaded ) if( loaded ) *loaded = true; // all done } -/* -================= -Mod_UnloadBrushModel - -Release all uploaded textures -================= -*/ -void Mod_UnloadBrushModel( model_t *mod ) -{ - texture_t *tx; - int i; - - Assert( mod != NULL ); - - if( mod->type != mod_brush ) - return; // not a bmodel - - // invalidate pointers - if( FBitSet( mod->flags, MODEL_WORLD )) - { - world.deluxedata = NULL; - world.shadowdata = NULL; - } - - if( mod->name[0] != '*' ) - { - for( i = 0; i < mod->numtextures; i++ ) - { - tx = mod->textures[i]; - if( !tx || tx->gl_texturenum == tr.defaultTexture ) - continue; // free slot - - GL_FreeTexture( tx->gl_texturenum ); // main texture - GL_FreeTexture( tx->fb_texturenum ); // luma texture - } - Mem_FreePool( &mod->mempool ); - } - - memset( mod, 0, sizeof( *mod )); -} - /* ================== Mod_CheckLump diff --git a/engine/common/model.c b/engine/common/model.c index 10915f62..7bf97887 100644 --- a/engine/common/model.c +++ b/engine/common/model.c @@ -110,6 +110,12 @@ void Mod_FreeModel( model_t *mod ) Mem_FreePool( &mod->mempool ); } + if( mod->type == mod_brush && FBitSet( mod->flags, MODEL_WORLD ) ) + { + world.shadowdata = NULL; + world.deluxedata = NULL; + } + memset( mod, 0, sizeof( *mod )); } diff --git a/ref_gl/gl_image.c b/ref_gl/gl_image.c index beb55a65..ace6a441 100644 --- a/ref_gl/gl_image.c +++ b/ref_gl/gl_image.c @@ -75,7 +75,7 @@ void GL_Bind( GLint tmu, GLenum texnum ) if( texnum <= 0 || texnum >= MAX_TEXTURES ) { if( texnum != 0 ) - Con_DPrintf( S_ERROR "GL_Bind: invalid texturenum %d\n", texnum ); + gEngfuncs.Con_DPrintf( S_ERROR "GL_Bind: invalid texturenum %d\n", texnum ); texnum = tr.defaultTexture; } if( tmu != GL_KEEP_UNIT ) diff --git a/ref_gl/gl_opengl.c b/ref_gl/gl_opengl.c index 67a9c865..3f3e2e9a 100644 --- a/ref_gl/gl_opengl.c +++ b/ref_gl/gl_opengl.c @@ -809,7 +809,7 @@ void GL_InitCommands( void ) gl_showtextures = gEngfuncs.pfnGetCvarPointer( "r_showtextures", 0 ); gl_finish = gEngfuncs.Cvar_Get( "gl_finish", "0", FCVAR_ARCHIVE, "use glFinish instead of glFlush" ); gl_nosort = gEngfuncs.Cvar_Get( "gl_nosort", "0", FCVAR_ARCHIVE, "disable sorting of translucent surfaces" ); - gl_clear = gEngfuncs.Cvar_Get( "gl_clear", "0", FCVAR_ARCHIVE, "clearing screen after each frame" ); + gl_clear = gEngfuncs.pfnGetCvarPointer( "gl_clear", 0 ); gl_test = gEngfuncs.Cvar_Get( "gl_test", "0", 0, "engine developer cvar for quick testing new features" ); gl_wireframe = gEngfuncs.Cvar_Get( "gl_wireframe", "0", FCVAR_ARCHIVE|FCVAR_SPONLY, "show wireframe overlay" ); gl_msaa = gEngfuncs.Cvar_Get( "gl_msaa", "1", FCVAR_ARCHIVE, "enable or disable multisample anti-aliasing" ); diff --git a/ref_gl/gl_rmain.c b/ref_gl/gl_rmain.c index 0c2ba1e0..1c3ca878 100644 --- a/ref_gl/gl_rmain.c +++ b/ref_gl/gl_rmain.c @@ -994,15 +994,15 @@ void R_CheckGamma( void ) if( gEngfuncs.R_DoResetGamma( )) { // paranoia cubemaps uses this - BuildGammaTable( 1.8f, 0.0f ); + gEngfuncs.BuildGammaTable( 1.8f, 0.0f ); // paranoia cubemap rendering - if( clgame.drawFuncs.GL_BuildLightmaps ) - clgame.drawFuncs.GL_BuildLightmaps( ); + if( gEngfuncs.drawFuncs->GL_BuildLightmaps ) + gEngfuncs.drawFuncs->GL_BuildLightmaps( ); } else if( FBitSet( vid_gamma->flags, FCVAR_CHANGED ) || FBitSet( vid_brightness->flags, FCVAR_CHANGED )) { - BuildGammaTable( vid_gamma->value, vid_brightness->value ); + gEngfuncs.BuildGammaTable( vid_gamma->value, vid_brightness->value ); glConfig.softwareGammaUpdate = true; GL_RebuildLightmaps(); glConfig.softwareGammaUpdate = false;