Browse Source

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

pull/2/head
Alibek Omarov 5 years ago
parent
commit
f48335f2f2
  1. 2
      engine/client/cl_gameui.c
  2. 3
      engine/client/cl_main.c
  3. 3
      engine/client/cl_parse.c
  4. 2
      engine/client/cl_view.c
  5. 8
      engine/client/input.c
  6. 14
      engine/client/ref_common.c
  7. 2
      engine/client/ref_common.h
  8. 6
      engine/ref_api.h

2
engine/client/cl_gameui.c

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

3
engine/client/cl_main.c

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

3
engine/client/cl_parse.c

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

2
engine/client/cl_view.c

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

8
engine/client/input.c

@ -550,15 +550,15 @@ void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active )
if( 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_CollectInput( &forward, &side, &pitch, &yaw, in_mouseinitialized, m_enginemouse->value );
IN_JoyAppendMove( cmd, forward, side ); IN_JoyAppendMove( cmd, forward, side );
refState.viewangles[YAW] += yaw * sensitivity; cmd->viewangles[YAW] += yaw * sensitivity;
refState.viewangles[PITCH] += pitch * sensitivity; cmd->viewangles[PITCH] += pitch * sensitivity;
refState.viewangles[PITCH] = bound( -90, refState.viewangles[PITCH], 90 ); cmd->viewangles[PITCH] = bound( -90, cmd->viewangles[PITCH], 90 );
} }
} }

14
engine/client/ref_common.c

@ -35,6 +35,20 @@ void GL_FreeImage( const char *name )
ref.dllFuncs.GL_FreeTexture( texnum ); 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 ) static int pfnEngineGetParm( int parm, int arg )
{ {
return CL_RenderGetParm( parm, arg, false ); // prevent recursion return CL_RenderGetParm( parm, arg, false ); // prevent recursion

2
engine/client/ref_common.h

@ -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_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 ) #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 // common engine and renderer cvars
extern convar_t *r_decals; extern convar_t *r_decals;
extern convar_t *r_adjust_fov; extern convar_t *r_adjust_fov;

6
engine/ref_api.h

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

Loading…
Cancel
Save