Constantly updating title bar?
I''ve seen other projects that have a constantly updating title bar (i.e, "NeHe''s OpenGL - FPS 324" and the 324 would change every .5 second). How would one go about this using NeHe''s Core? I''ve only been able to get it to change when switching from fullscreen to windowed.
I do real things with imaginary numbers
There is a function ... to update it, but I forgot the name ...
(you can find me on IRC : #opengl on undernet)
Yes, SetWindowText works,
but how do you make this function write the variable integer (FPS) when it expects const char * as an argument?
thanks,
Quo
but how do you make this function write the variable integer (FPS) when it expects const char * as an argument?
thanks,
Quo
I use:
fps=1000.0/(TimerGetTime()-start2);
sprintf(cOutBuffer, "fps = %0.1f", fps);
start2=TimerGetTime();
SetWindowText(hWnd, cOutBuffer);
But i think it slow the thing down...you could try a quad which changes length placed over a scale - 2 extra quads are very quick to draw. ( plus it works in fullscreen mode)
alistair
fps=1000.0/(TimerGetTime()-start2);
sprintf(cOutBuffer, "fps = %0.1f", fps);
start2=TimerGetTime();
SetWindowText(hWnd, cOutBuffer);
But i think it slow the thing down...you could try a quad which changes length placed over a scale - 2 extra quads are very quick to draw. ( plus it works in fullscreen mode)
alistair
Ali, that''d be a great idea, except how would you judge the scale? I know you''d have to make a BMP of the scale, but how would you figure out that, for example, 0.5f is 1 fps? Would the calculations be in the Draw function, or would you have to draw the bitmap to fit the code?
I do real things with imaginary numbers
September 06, 2000 01:09 PM
ok, I use:
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D, 20);
glColor3f(1.0f, 1.0f, 1.0f);
glTranslatef(0.0f, -3.4f, -8.0f);
glBegin(GL_QUADS);
glTexCoord2i(0, 1); glVertex3f(-4.0f, 0.5f, 0.0f);
glTexCoord2i(0, 0); glVertex3f(-4.0f, -0.5f, 0.0f);
glTexCoord2i(1, 0); glVertex3f(4.0f, -0.5f, 0.0f);
glTexCoord2i(1, 1); glVertex3f(4.0f, 0.5f, 0.0f);
glEnd();
glDisable(GL_TEXTURE_2D);
if(fps<130) glColor4f(1.0f, 1.0f, 0.0f, 0.8f);
else glColor4f(1.0f, 0.0f, 0.0f, 0.8f);
glBegin(GL_QUADS);
glVertex3f(-4.0f, 0.5f, 0.0f);
glVertex3f(-4.0f, 0.2f, 0.0f);
glVertex3f(-4.0f+0.053f*fps, 0.2f, 0.0f);
glVertex3f(-4.0f+0.053f*fps, 0.5f, 0.0f);
glEnd();
glPopMatrix();
which draws a yellow bar, or a red one if greater than 130fps
the above code can obviously be optimized a lot - eg using a list for the first half.
alistair
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D, 20);
glColor3f(1.0f, 1.0f, 1.0f);
glTranslatef(0.0f, -3.4f, -8.0f);
glBegin(GL_QUADS);
glTexCoord2i(0, 1); glVertex3f(-4.0f, 0.5f, 0.0f);
glTexCoord2i(0, 0); glVertex3f(-4.0f, -0.5f, 0.0f);
glTexCoord2i(1, 0); glVertex3f(4.0f, -0.5f, 0.0f);
glTexCoord2i(1, 1); glVertex3f(4.0f, 0.5f, 0.0f);
glEnd();
glDisable(GL_TEXTURE_2D);
if(fps<130) glColor4f(1.0f, 1.0f, 0.0f, 0.8f);
else glColor4f(1.0f, 0.0f, 0.0f, 0.8f);
glBegin(GL_QUADS);
glVertex3f(-4.0f, 0.5f, 0.0f);
glVertex3f(-4.0f, 0.2f, 0.0f);
glVertex3f(-4.0f+0.053f*fps, 0.2f, 0.0f);
glVertex3f(-4.0f+0.053f*fps, 0.5f, 0.0f);
glEnd();
glPopMatrix();
which draws a yellow bar, or a red one if greater than 130fps
the above code can obviously be optimized a lot - eg using a list for the first half.
alistair
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement