本文整理汇总了C++中Sys_FloatTime函数的典型用法代码示例。如果您正苦于以下问题:C++ Sys_FloatTime函数的具体用法?C++ Sys_FloatTime怎么用?C++ Sys_FloatTime使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sys_FloatTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char **argv)
{
static quakeparms_t parms;
float time, oldtime, newtime;
parms.memsize = 16*1024*1024;
parms.membase = malloc (parms.memsize);
parms.basedir = ".";
parms.cachedir = NULL;
COM_InitArgv (argc, argv);
parms.argc = com_argc;
parms.argv = com_argv;
printf ("Host_Init\n");
Host_Init (&parms);
Sys_Init();
// unroll the simulation loop to give the video side a chance to see _vid_default_mode
Host_Frame( 0.1 );
VID_SetDefaultMode();
oldtime = Sys_FloatTime();
while (1)
{
newtime = Sys_FloatTime();
Host_Frame (newtime - oldtime);
oldtime = newtime;
}
return 0;
}
示例2: R_TimeRefresh_f
/*
====================
R_TimeRefresh_f
For program optimization
====================
*/
void R_TimeRefresh_f (void)
{
int i;
float start, stop, time;
int startangle;
vrect_t vr;
startangle = r_refdef.viewangles[1];
start = Sys_FloatTime ();
for (i=0 ; i<128 ; i++)
{
r_refdef.viewangles[1] = i/128.0*360.0;
VID_LockBuffer ();
R_RenderView ();
VID_UnlockBuffer ();
vr.x = r_refdef.vrect.x;
vr.y = r_refdef.vrect.y;
vr.width = r_refdef.vrect.width;
vr.height = r_refdef.vrect.height;
vr.pnext = NULL;
VID_Update (&vr);
}
stop = Sys_FloatTime ();
time = stop-start;
Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
r_refdef.viewangles[1] = startangle;
}
示例3: Host_Frame
void Host_Frame (float time)
{
double time1, time2;
static double timetotal;
static int timecount;
int i, c, m;
if (!serverprofile.value)
{
_Host_Frame (time);
return;
}
time1 = Sys_FloatTime ();
_Host_Frame (time);
time2 = Sys_FloatTime ();
timetotal += time2 - time1;
timecount++;
if (timecount < 1000)
return;
m = timetotal*1000/timecount;
timecount = 0;
timetotal = 0;
c = 0;
for (i=0 ; i<svs.maxclients ; i++)
{
if (svs.clients[i].active)
c++;
}
Con_Printf ("serverprofile: %2i clients %2i msec\n", c, m);
}
示例4: Host_ShutdownServer
/*
==================
Host_ShutdownServer
This only happens at the end of a game, not between levels
==================
*/
void Host_ShutdownServer(qboolean crash)
{
int i;
int count;
sizebuf_t buf;
char message[4];
double start;
if (!sv.active)
return;
sv.active = false;
// flush any pending messages - like the score!!!
start = Sys_FloatTime();
do
{
count = 0;
for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
{
if (host_client->active && host_client->message.cursize)
{
if (NET_CanSendMessage (host_client->netconnection))
{
NET_SendMessage(host_client->netconnection, &host_client->message);
SZ_Clear (&host_client->message);
}
else
{
NET_GetMessage(host_client->netconnection);
count++;
}
}
}
if ((Sys_FloatTime() - start) > 3.0)
break;
}
while (count);
// make sure all the clients know we're disconnecting
buf.data = message;
buf.maxsize = 4;
buf.cursize = 0;
MSG_WriteByte(&buf, svc_disconnect);
count = NET_SendToAll(&buf, 5);
if (count)
Con_Printf("Host_ShutdownServer: NET_SendToAll failed for %u clients\n", count);
for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
if (host_client->active)
SV_DropClient(crash);
//
// clear structures
//
memset (&sv, 0, sizeof(sv));
memset (svs.clients, 0, svs.maxclientslimit*sizeof(client_t));
}
示例5: R_RenderView
/*
================
R_RenderView
r_refdef must be set before the first call
================
*/
void R_RenderView (void)
{
double time1 = 0.0;
double time2;
GLfloat colors[4] = {(GLfloat) 0.0, (GLfloat) 0.0, (GLfloat) 1, (GLfloat) 0.20};
if (r_norefresh.value)
return;
if (!r_worldentity.model || !cl.worldmodel)
Sys_Error ("R_RenderView: NULL worldmodel");
if (r_speeds.value)
{
glFinish ();
time1 = Sys_FloatTime ();
c_brush_polys = 0;
c_alias_polys = 0;
}
mirror = false;
if (gl_finish.value)
glFinish ();
R_Clear ();
// render normal view
/***** Experimental silly looking fog ******
****** Use r_fullbright if you enable ******
glFogi(GL_FOG_MODE, GL_LINEAR);
glFogfv(GL_FOG_COLOR, colors);
glFogf(GL_FOG_END, 512.0);
glEnable(GL_FOG);
********************************************/
R_RenderScene ();
R_DrawViewModel ();
R_DrawWaterSurfaces ();
// More fog right here :)
// glDisable(GL_FOG);
// End of all fog code...
// render mirror view
R_Mirror ();
R_PolyBlend ();
if (r_speeds.value)
{
// glFinish ();
time2 = Sys_FloatTime ();
Con_Printf ("%3i ms %4i wpoly %4i epoly\n", (int)((time2-time1)*1000), c_brush_polys, c_alias_polys);
}
}
示例6: main
int main (int argc, char **argv)
{
MSG msg;
quakeparms_t parms;
double time, oldtime;
static char cwd[1024];
memset (&parms, 0, sizeof(parms));
parms.memsize = 16384*1024;
parms.membase = malloc (parms.memsize);
_getcwd (cwd, sizeof(cwd));
if (cwd[Q_strlen(cwd)-1] == '\\')
cwd[Q_strlen(cwd)-1] = 0;
parms.basedir = cwd; //"f:/quake";
// parms.basedir = "f:\\quake";
COM_InitArgv (argc, argv);
// dedicated server ONLY!
if (!COM_CheckParm ("-dedicated"))
{
memcpy (newargv, argv, argc*4);
newargv[argc] = "-dedicated";
argc++;
argv = newargv;
COM_InitArgv (argc, argv);
}
parms.argc = argc;
parms.argv = argv;
printf ("Host_Init\n");
Host_Init (&parms);
oldtime = Sys_FloatTime ();
/* main window message loop */
while (1)
{
time = Sys_FloatTime();
if (time - oldtime < sys_ticrate.value )
{
Sleep(1);
continue;
}
Host_Frame ( time - oldtime );
oldtime = time;
}
/* return success of application */
return TRUE;
}
示例7: main
int main (int c, char **v)
{
quakeparms_t parms;
enableCrunLoop = c > 0;
// signal(SIGFPE, floating_point_exception_handler);
signal(SIGFPE, SIG_IGN);
parms.memsize = 16*1024*1024;
parms.membase = malloc (parms.memsize);
parms.basedir = basedir;
parms.cachedir = cachedir;
COM_InitArgv(c, v);
parms.argc = com_argc;
parms.argv = com_argv;
Sys_Init();
Host_Init(&parms);
Cvar_RegisterVariable (&sys_nostdout);
oldtime = Sys_FloatTime () - 0.1;
if(enableCrunLoop) {
while(true) {
engineTick();
}
} else {
AS3_GoAsync();
}
}
示例8: SCR_DrawFPS
void SCR_DrawFPS(void) {
extern CVar show_fps;
static double lastframetime;
double t;
extern int fps_count;
static int lastfps;
static int totalfps;
static int lastsecond;
int x, y;
char st[80];
if (!show_fps.getBool())
return;
t = Sys_FloatTime();
lastfps = 1 / (t - lastframetime);
if (((int) (t) % 100) > ((int) (lastframetime) % 100)) {
lastsecond = totalfps;
totalfps = 0;
}
lastframetime = t;
totalfps += 1;
sprintf(st, "%3d FPS", lastfps);
x = vid.conwidth - strlen(st) * 8 - 16;
y = 0;
Draw_String(x, y, st);
sprintf(st, "%3d Last second", lastsecond);
x = vid.conwidth - strlen(st) * 8 - 16;
y = 8;
Draw_String(x, y, st);
}
示例9: R_PrintDSpeeds
/*
=============
R_PrintDSpeeds
=============
*/
void R_PrintDSpeeds (void)
{
float ms, dp_time, r_time2, rw_time, db_time, se_time, de_time, dv_time;
r_time2 = Sys_FloatTime ();
dp_time = (dp_time2 - dp_time1) * 1000;
rw_time = (rw_time2 - rw_time1) * 1000;
db_time = (db_time2 - db_time1) * 1000;
se_time = (se_time2 - se_time1) * 1000;
de_time = (de_time2 - de_time1) * 1000;
#ifndef VMTOC
dv_time = (dv_time2 - dv_time1) * 1000;
ms = (r_time2 - r_time1) * 1000;
Con_Printf ("%3i %4.1fp %3iw %4.1fb %3is %4.1fe %4.1fv\n",
(int)ms, dp_time, (int)rw_time, db_time, (int)se_time, de_time,
dv_time);
#else
ms = (r_time2 - r_time1) * 1000;
Con_Printf ("%3i %4.1fp %3iw %4.1fb %3is %4.1fe %4.1fv\n", (int)ms, dp_time, (int)rw_time, db_time, (int)se_time, de_time);
#endif
}
示例10: BlockingHook
BOOL PASCAL FAR BlockingHook(void)
{
#ifdef ID_PC
MSG msg;
BOOL ret;
if ((Sys_FloatTime() - blocktime) > 2.0)
{
WSACancelBlockingCall();
return FALSE;
}
/* get the next message, if any */
ret = (BOOL) PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
/* if we got one, process it */
if (ret) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
/* TRUE if we got a message */
return ret;
#endif
return false;
}
示例11: WINS_GetLocalAddress
void WINS_GetLocalAddress()
{
struct hostent *local = NULL;
char buff[MAXHOSTNAMELEN];
unsigned long addr;
if (myAddr != INADDR_ANY) {
return;
}
if (pgethostname(buff, MAXHOSTNAMELEN) == SOCKET_ERROR) {
return;
}
blocktime = Sys_FloatTime();
WSASetBlockingHook(BlockingHook);
local = pgethostbyname(buff);
WSAUnhookBlockingHook();
if (local == NULL) {
return;
}
myAddr = *(int *)local->h_addr_list[0];
addr = ntohl(myAddr);
sprintf(my_tcpip_address, "%d.%d.%d.%d", (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff);
}
示例12: R_AnimateLight
void CRender::FrameBegin( void )
{
if ( !host_state.worldmodel )
return;
// don't allow cheats in multiplayer
#if !defined( _DEBUG )
if (cl.maxclients > 1)
{
// mat_fullbright.SetValue( 0 );
// mat_drawflat.SetValue( 0 );
mat_reversedepth.SetValue( 0 );
mat_luxels.SetValue( 0 );
mat_normals.SetValue( 0 );
}
#endif
// This has to be before R_AnimateLight because it uses it to
// set the frame number of changed lightstyles
r_framecount++;
R_AnimateLight ();
R_PushDlights();
if (!r_norefresh.GetInt())
{
m_frameStartTime = Sys_FloatTime ();
}
UpdateStudioRenderConfig();
materialSystemInterface->BeginFrame();
g_pStudioRender->BeginFrame();
}
示例13: SCR_DrawFPS
//muff - hacked out of SourceForge implementation + modified
void SCR_DrawFPS (void)
{
static double lastframetime;
double t;
static int lastfps;
int x, y;
char st[80];
if (!cl_showfps->value)
return;
t = Sys_FloatTime ();
if ((t - lastframetime) >= 1.0) {
lastfps = fps_count;
fps_count = 0;
lastframetime = t;
}
sprintf(st, "%3d FPS", lastfps);
x = vid.width - strlen(st) * 16 - 16;
y = 0 ; //vid.height - (sb_lines * (vid.height/240) )- 16;
// Draw_TileClear(x, y, strlen(st)*16, 16);
Draw_String(x, y, st);
}
示例14: Slist_Poll
static void Slist_Poll(void)
{
for (net_driverlevel=0; net_driverlevel < net_numdrivers; net_driverlevel++)
{
if (!slistLocal && net_driverlevel == 0)
continue;
if (net_drivers[net_driverlevel].initialized == false)
continue;
dfunc.SearchForHosts (false);
}
if (! slistSilent)
PrintSlist();
if ((Sys_FloatTime() - slistStartTime) < 1.5)
{
SchedulePollProcedure(&slistPollProcedure, 0.1);
return;
}
if (! slistSilent)
PrintSlistTrailer();
slistInProgress = false;
slistSilent = false;
slistLocal = true;
}
示例15: MCI_MAKE_TMSF
//-----------------------------------------------------------------------------
// Purpose: Resume playing cd
//-----------------------------------------------------------------------------
void CCDAudio::_Resume( int, int )
{
double curTime;
DWORD dwReturn;
MCI_PLAY_PARMS mciPlayParms;
if (!m_bEnabled)
return;
if (!m_bIsValid)
return;
if (!m_bWasPlaying)
return;
mciPlayParms.dwFrom = MCI_MAKE_TMSF(m_nPlayTrack, 0, 0, 0);
mciPlayParms.dwTo = MCI_MAKE_TMSF(m_nPlayTrack + 1, 0, 0, 0);
mciPlayParms.dwCallback = (DWORD)game->GetMainWindow();
dwReturn = mciSendCommand(m_uiDeviceID, MCI_PLAY, MCI_TO | MCI_NOTIFY, (DWORD)(LPVOID) &mciPlayParms);
if (dwReturn)
{
ResetCDTimes();
return;
}
m_bIsPlaying = true;
curTime = Sys_FloatTime();
// Subtract the elapsed time from the current playback time. (i.e., add it to the start time).
m_dStartTime += (curTime - m_dPauseTime);
m_dPauseTime = 0.0;
}