-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDXGame.cpp
More file actions
149 lines (125 loc) · 3.73 KB
/
Copy pathDXGame.cpp
File metadata and controls
149 lines (125 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "Common.h"
#ifdef _DIRECTX
#include "Game.h"
#include "Camera.h"
#include "Engine.h"
#include "Profile.h"
#include "Map.h"
#include "EventManager.h"
#include "SoundManager.h"
#include "debuglog.h"
#include "console.h"
#include "debris.h"
#include "scheduledevent.h"
#include "DebugText.h"
#include "music.h"
#include "spriterenderer.h"
#include "renderinfo.h"
#include "Player.h"
#include "World.h"
#include "CLIParams.h"
#include "text.h"
//*******************************************************************************
CDXGame GAME;
void CDXGame::DumpTimeRecords()
{
#ifdef DEBUG_TIMERECORDS
FILE *f=fopen("c:\\timerec.txt","wt");
int r=mCurrentTR;
int oldr=mCurrentTR;
char buffer[1024],tbuf[1024];
sprintf(buffer,"Base time\tStart offset\tTime taken\tRenders\tRender 1f\tRender 2f\tRender 3f\tRender 4f\tFrame length\tFPS rate\tStatus\n");
fwrite(buffer,strlen(buffer),1,f);
for (int i=0;i<TIMERECORDS;i++)
{
sprintf(buffer,"%f\t%f\t%f\t%d\t",
mTimeRecord[r].basetime,
mTimeRecord[r].starttimeoffset,mTimeRecord[r].timetaken,
mTimeRecord[r].renders);
if (mTimeRecord[r].renders>0)
sprintf(tbuf,"%f\t",mTimeRecord[r].renderfraction[0]+(1-mTimeRecord[oldr].renderfraction[mTimeRecord[oldr].renders-1]));
else
sprintf(tbuf,"-\t\t");
strcat(buffer,tbuf);
if (mTimeRecord[r].renders>1)
sprintf(tbuf,"%f\t",mTimeRecord[r].renderfraction[1]-mTimeRecord[r].renderfraction[0]);
else
sprintf(tbuf,"-\t\t");
strcat(buffer,tbuf);
if (mTimeRecord[r].renders>2)
sprintf(tbuf,"%f\t",mTimeRecord[r].renderfraction[2]-mTimeRecord[r].renderfraction[1]);
else
sprintf(tbuf,"-\t\t");
strcat(buffer,tbuf);
if (mTimeRecord[r].renders>3)
sprintf(tbuf,"%f\t",mTimeRecord[r].renderfraction[3]-mTimeRecord[r].renderfraction[2]);
else
sprintf(tbuf,"-\t\t");
strcat(buffer,tbuf);
sprintf(tbuf,"%f\t%f\t%s\n",
mTimeRecord[r].framelength,
mTimeRecord[r].fps,mTimeRecord[r].status);
strcat(buffer,tbuf);
fwrite(buffer,strlen(buffer),1,f);
oldr=r;
r++;
if (r>=TIMERECORDS)
r=0;
}
fclose(f);
f=fopen("c:\\renderrec.txt","wt");
r=mCurrentRR;
oldr=mCurrentRR;
sprintf(buffer,"End time\tEnd time delta\tTime taken\tFrame code\tRender number\tDelta ratio\tIdeal DR\n");
fwrite(buffer,strlen(buffer),1,f);
for (i=0;i<TIMERECORDS;i++)
{
sprintf(buffer,"%f\t%f\t%f\t%f\t%d\t%f\t%f\n",
mRenderRecord[r].renderendtime,
mRenderRecord[r].renderendtime-mRenderRecord[oldr].renderendtime,
mRenderRecord[r].renderlength,
mRenderRecord[r].renderframetime,
mRenderRecord[r].rendernumber,
(mRenderRecord[r].renderendtime-mRenderRecord[oldr].renderendtime)/(mRenderRecord[r].renderframetime-mRenderRecord[oldr].renderframetime),
(mRenderRecord[r].renderstarttime-mRenderRecord[oldr].renderstarttime)/(mRenderRecord[r].renderframetime-mRenderRecord[oldr].renderframetime));
fwrite(buffer,strlen(buffer),1,f);
oldr=r;
r++;
if (r>=TIMERECORDS)
r=0;
}
fclose(f);
#endif
}
void CDXGame::AddTimeStatus(char *s)
{
#ifdef DEBUG_TIMERECORDS
if ((strlen(mTimeRecord[mCurrentTR].status)+strlen(s))<255)
{
strcat(mTimeRecord[mCurrentTR].status,s);
strcat(mTimeRecord[mCurrentTR].status," ");
}
else
{
if (strlen(mTimeRecord[mCurrentTR].status)<250)
strcat(mTimeRecord[mCurrentTR].status,"...");
}
#endif
}
//*******************************************************************************
/*
if (mFixedFrameRate)
{
float time = (float)timeGetTime() * 0.001f;
if (time - mLastUpdateTime > MAX_UPDATE_TIME)
{
mLastUpdateTime = time ;
GAME.Update() ;
}
}
else
{
GAME.Update() ;
}
*/
#endif