ref: get rid of fov in globals, add RenderFrame wrapper, which correctly initialize shared global values

This commit is contained in:
Alibek Omarov 2019-03-28 18:17:26 +03:00
parent 8b5926f9b1
commit f48335f2f2
8 changed files with 24 additions and 16 deletions

View File

@ -727,7 +727,7 @@ static void pfnRenderScene( const ref_viewpass_t *rvp )
copy.flags = 0;
ref.dllFuncs.R_Set2DMode( false );
ref.dllFuncs.GL_RenderFrame( &copy );
GL_RenderFrame( &copy );
ref.dllFuncs.R_Set2DMode( true );
ref.dllFuncs.R_PopScene();
}

View File

@ -293,7 +293,6 @@ static float CL_LerpPoint( void )
frac = ( cl.time - cl.mtime[1] ) / f;
}
#endif
refState.time = cl.time;
return frac;
}
@ -2868,8 +2867,6 @@ void CL_AdjustClock( void )
if( cl.oldtime > cl.time )
cl.oldtime = cl.time;
}
refState.oldtime = cl.oldtime;
refState.time = cl.time;
}
/*

View File

@ -208,9 +208,6 @@ void CL_ParseServerTime( sizebuf_t *msg )
if( cl.oldtime > cl.time )
cl.oldtime = cl.time;
refState.oldtime = cl.oldtime;
refState.time = cl.time;
}
/*

View File

@ -335,7 +335,7 @@ void V_RenderView( void )
ref.dllFuncs.R_ClearScreen();
}
ref.dllFuncs.GL_RenderFrame( &rvp );
GL_RenderFrame( &rvp );
S_UpdateFrame( &rvp );
viewnum++;

View File

@ -550,15 +550,15 @@ void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active )
if( active )
{
float sensitivity = ( (float)refState.fov_x / (float)90.0f );
float sensitivity = ( (float)cl.local.scr_fov / (float)90.0f );
IN_CollectInput( &forward, &side, &pitch, &yaw, in_mouseinitialized, m_enginemouse->value );
IN_JoyAppendMove( cmd, forward, side );
refState.viewangles[YAW] += yaw * sensitivity;
refState.viewangles[PITCH] += pitch * sensitivity;
refState.viewangles[PITCH] = bound( -90, refState.viewangles[PITCH], 90 );
cmd->viewangles[YAW] += yaw * sensitivity;
cmd->viewangles[PITCH] += pitch * sensitivity;
cmd->viewangles[PITCH] = bound( -90, cmd->viewangles[PITCH], 90 );
}
}

View File

@ -35,6 +35,20 @@ void GL_FreeImage( const char *name )
ref.dllFuncs.GL_FreeTexture( texnum );
}
int GL_RenderFrame( const ref_viewpass_t *rvp )
{
refState.time = cl.time;
refState.oldtime = cl.oldtime;
refState.realtime = host.realtime;
refState.frametime = host.frametime;
VectorCopy( rvp->vieworigin, refState.vieworg );
VectorCopy( rvp->viewangles, refState.viewangles );
AngleVectors( refState.viewangles, refState.vforward, refState.vright, refState.vup );
ref.dllFuncs.GL_RenderFrame( rvp );
}
static int pfnEngineGetParm( int parm, int arg )
{
return CL_RenderGetParm( parm, arg, false ); // prevent recursion

View File

@ -37,6 +37,8 @@ void R_GetTextureParms( int *w, int *h, int texnum );
#define GL_LoadTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( name, pic, flags, false )
#define GL_UpdateTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( name, pic, flags, true )
int GL_RenderFrame( const struct ref_viewpass_s *rvp );
// common engine and renderer cvars
extern convar_t *r_decals;
extern convar_t *r_adjust_fov;

View File

@ -99,8 +99,6 @@ typedef struct ref_globals_s
cl_entity_t *currententity;
model_t *currentmodel;
float fov_x, fov_y;
// todo: fill this without engine help
// move to local
@ -592,8 +590,8 @@ typedef struct ref_interface_s
void (*TriRenderMode)( int mode );
void (*Begin)( int primitiveCode );
void (*End)( void );
void (*Color4f)( float r, float g, float b, float a );
void (*Color4ub)( unsigned char r, unsigned char g, unsigned char b, unsigned char a );
void (*Color4f)( float r, float g, float b, float a ); // real glColor4f
void (*Color4ub)( unsigned char r, unsigned char g, unsigned char b, unsigned char a ); // real glColor4ub
void (*TexCoord2f)( float u, float v );
void (*Vertex3fv)( const float *worldPnt );
void (*Vertex3f)( float x, float y, float z );