Patrice,
FPS should be always drawn in textured mode, try with wireframe and/or point cloud.
Ah yes, that's a good catch! Please use this in
mobj.h:
void printFPS(int x, char* str) {
static bool fpsInited = false;
char* s = str;
int i, j, idx = 0;
if (!fpsInited)
fpsInit(&fpsInited);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glTranslatef(0.0f, gP.glHeight - 1.0f, 0.0f);
glScalef(1.0f, -1.0f, 1.0f);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0, gP.glWidth, 0.0, gP.glHeight, -1.0, 1.0);
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glScalef(1.0f / float(g_digitW * 10), 1.0f / float(g_digitH), 1.0f);
glMatrixMode(GL_MODELVIEW);
glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_MODE);
glEnable(GL_BLEND);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, gM.glFpsTexture);
x += 1;
while (*s) {
i = x + g_digitW;
idx = (*s++) - 48;
j = idx * g_digitW;//(idx << 5) / 2;
glBegin(GL_QUADS);
glTexCoord2i(j, 0); glVertex2i(x, g_digitH);
glTexCoord2i(j + g_digitW, 0); glVertex2i(i, g_digitH);
glTexCoord2i(j + g_digitW, g_digitH); glVertex2i(i, 0);
glTexCoord2i(j, g_digitH); glVertex2i(x, 0);
glEnd();
x += g_digitW;
}
glBindTexture(GL_TEXTURE_2D, 0);
glPopAttrib();
glMatrixMode(GL_TEXTURE);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
... this one runs my FPS very close to FRAPS ...
I hope you understand that you're using some obscure side effect of
Sleep(1) because strictly speaking, without
timeBegin|EndPeriod(1) your
Sleep(1) is effectively the same as
Sleep(USER_TIMER_MINIMUM), or
Sleep(15.6).
Contrary to their deceptive names, the matching
timeBeginPeriod() and
timeEndPeriod() APIs set/reset the minimum resolution not of timers but rather of process
wait state timeouts, like e.g.
WaitForSingleObject() or
WaitOnAddress(),
and of the
Sleep() API.
In fact, what you're doing is forcing the process to sleep some extra ticks in addition to the "timer" loop delay. But what I'd rather like to do is understand why such extra sleep is needed at all, because your funny 998+1+1 ticks jugglery seems logical (though somewhat weird) to me.
But OK, let's stick to your solution temporarily until the logically correct solution dawns on us sooner or later.
Ideally the FPS should be drawn in composited mode...
I'd rather see everything drawn in
gl_DrawScene() than buried somewhere in your GDImage I have no access to, Patrice.
Ideally, the
printFPS() routine should be reduced to a
glCallList() call but that requires some experimentation to avoid yet more rather than less stress on the renderer.