<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[FPS Counter problem]]></title><description><![CDATA[<p>Hallo,</p>
<p>mein fps code: <a href="http://www.badworld-crew.com/nopaste/?6" rel="nofollow">http://www.badworld-crew.com/nopaste/?6</a></p>
<p>ich habe einen fps counter für mein prog geschrieben, im prinzip ist es ja kein großes problem aber ich scheitere trotzdem.<br />
Da kommen einfach falsche werte raus. Ich habe schon gegoogelt und boardsuche benutzen, aber alle fps counter sind imprinzip genauso wie meiner mit dem unterschied, dass sie funktionieren :).</p>
<p>Ich finde einfach den fehler nicht. Vll findet ihr das problem</p>
<p>THX für die hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/213452/fps-counter-problem</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 06:26:27 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/213452.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 18 May 2008 10:48:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to FPS Counter problem on Sun, 18 May 2008 10:51:45 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>mein fps code: <a href="http://www.badworld-crew.com/nopaste/?6" rel="nofollow">http://www.badworld-crew.com/nopaste/?6</a></p>
<p>ich habe einen fps counter für mein prog geschrieben, im prinzip ist es ja kein großes problem aber ich scheitere trotzdem.<br />
Da kommen einfach falsche werte raus. Ich habe schon gegoogelt und boardsuche benutzen, aber alle fps counter sind imprinzip genauso wie meiner mit dem unterschied, dass sie funktionieren :).</p>
<p>Ich finde einfach den fehler nicht. Vll findet ihr das problem</p>
<p>THX für die hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1511408</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511408</guid><dc:creator><![CDATA[oxigen_c]]></dc:creator><pubDate>Sun, 18 May 2008 10:51:45 GMT</pubDate></item><item><title><![CDATA[Reply to FPS Counter problem on Sun, 18 May 2008 11:06:37 GMT]]></title><description><![CDATA[<p>So wie ich das seh wird &quot;static float fps&quot; nicht mehr genullt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1511420</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511420</guid><dc:creator><![CDATA[__deprecated]]></dc:creator><pubDate>Sun, 18 May 2008 11:06:37 GMT</pubDate></item><item><title><![CDATA[Reply to FPS Counter problem on Sun, 18 May 2008 11:12:56 GMT]]></title><description><![CDATA[<p>Um noch etwas zu meckern ^^:<br />
- vergiss das inline<br />
- warum ist fps ein float? es wird immer wie ein int benutzt.<br />
- statt dem ganzen static könnte man das alles auch als Klasse schreiben.<br />
- wenn man schon mal dabei ist kann man auch die ausgabe von fps vom zählvorgang entkoppeln.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1511427</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511427</guid><dc:creator><![CDATA[__deprecated]]></dc:creator><pubDate>Sun, 18 May 2008 11:12:56 GMT</pubDate></item><item><title><![CDATA[Reply to FPS Counter problem on Sun, 18 May 2008 11:16:39 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void CalculateFrameRate()
{
	// Below we create a bunch of static variables because we want to keep the information
	// in these variables after the function quits.  We could make these global but that would
	// be somewhat messy and superfluous.  Note, that normally you don't want to display this to
	// the window title bar.  This is because it's slow and doesn't work in full screen.
	// Try using the 3D/2D font's.  You can check out the tutorials at www.gametutorials.com.

	static float framesPerSecond    = 0.0f;							// This will store our fps
    static float lastTime			= 0.0f;							// This will hold the time from the last frame
	static char strFrameRate[50] = {0};								// We will store the string here for the window title

	// Here we get the current tick count and multiply it by 0.001 to convert it from milliseconds to seconds.
	// GetTickCount() returns milliseconds (1000 ms = 1 second) so we want something more intuitive to work with.
    float currentTime = GetTickCount() * 0.001f;				

	// Increase the frame counter
    ++framesPerSecond;

	// Now we want to subtract the current time by the last time that was stored.  If it is greater than 1
	// that means a second has passed and we need to display the new frame rate.  Of course, the first time
	// will always be greater than 1 because lastTime = 0.  The first second will NOT be true, but the remaining
	// ones will.  The 1.0 represents 1 second.  Let's say we got 12031 (12.031) from GetTickCount for the currentTime,
	// and the lastTime had 11230 (11.230).  Well, 12.031 - 11.230 = 0.801, which is NOT a full second.  So we try again
	// the next frame.  Once the currentTime - lastTime comes out to be greater than a second (&gt; 1), we calculate the
	// frames for this last second.
    if( currentTime - lastTime &gt; 1.0f )
    {
		// Here we set the lastTime to the currentTime.  This will be used as the starting point for the next second.
		// This is because GetTickCount() counts up, so we need to create a delta that subtract the current time from.
	    lastTime = currentTime;

		// Copy the frames per second into a string to display in the window title bar
		sprintf(strFrameRate, &quot;Current Frames Per Second: %d&quot;, int(framesPerSecond));

		// Set the window title bar to our string
		SetWindowText(g_hWnd, strFrameRate);

		// Reset the frames per second
        framesPerSecond = 0;
    }
}
</code></pre>
<p>(Nicht von mir)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1511429</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511429</guid><dc:creator><![CDATA[WiredCoder]]></dc:creator><pubDate>Sun, 18 May 2008 11:16:39 GMT</pubDate></item><item><title><![CDATA[Reply to FPS Counter problem on Sun, 18 May 2008 11:22:55 GMT]]></title><description><![CDATA[<p>danke für den beitrag. und codeposting.</p>
<p>Logisch gesehen sind beide codeteile equivalent, aber trotzdem funktioniert meiner nicht und deiner(von dir gepostet) schon.</p>
<p>Wo kann das problem oder der Grund liegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1511440</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511440</guid><dc:creator><![CDATA[oxigen_c]]></dc:creator><pubDate>Sun, 18 May 2008 11:22:55 GMT</pubDate></item><item><title><![CDATA[Reply to FPS Counter problem on Sun, 18 May 2008 11:37:19 GMT]]></title><description><![CDATA[<p>bin ich unsichtbar? ^^<br />
fps wird nichtmehr genullt.<br />
Dein Code müsste lauten:</p>
<pre><code class="language-cpp">inline void FPS(HWND hwnd)
{
    static float fps = 0.0f;
    static float prevTime = 0.0f;
    static char strFPS[200] = {0};

    float currentTime = (GetTickCount() * 0.01f);

    if(currentTime-prevTime &gt; 1.0f)
    {
        prevTime = currentTime;
        sprintf(strFPS,&quot;FPS: %c &quot;,(int)fps);
        SetWindowText(hwnd, strFPS);
        // Hier muss fps genullt werden, sonst steigt es ja immer weiter
        fps = 0;
    }

       fps+=1;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1511456</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511456</guid><dc:creator><![CDATA[__deprecated]]></dc:creator><pubDate>Sun, 18 May 2008 11:37:19 GMT</pubDate></item><item><title><![CDATA[Reply to FPS Counter problem on Sun, 18 May 2008 11:49:20 GMT]]></title><description><![CDATA[<p>und currentTime wird mit 0.001f multipliziert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1511464</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511464</guid><dc:creator><![CDATA[__deprecated]]></dc:creator><pubDate>Sun, 18 May 2008 11:49:20 GMT</pubDate></item></channel></rss>