OpenGL calculation FPS

xiaoxiao2021-03-06  69

Find a method of calculating FPS online, feeling more accurate, attacked here for use. (Note: The source of this code is http://www.gametutorials.com/tutorials/opengl/opengl_pg1.htm example code, reposted, I delete all of the comments. Code copyright belongs to code . All writers) void CalculateFrameRate () {static float framesPerSecond = 0.0f; // This will store our fps static float lastTime = 0.0f; // This will hold the time from the last frame float currentTime = GetTickCount () * 0.001f; framesPerSecond; if (currentTime - lastTime> 1.0f) {lastTime = currentTime; sprintf (strFrameRate, "Current Frames Per Second:% d", int (framesPerSecond)); SetWindowText (g_hWnd, strFrameRate); framesPerSecond = 0;}} CalculateFramerate () can be called at each rendering. Note: 1. To see detailed code and comments, you can go to http://www.gametutorials.com/tutorials/opENGL/opENGL_PG1.HTM download example code slowly study. 2. The getTickCount () function is used in the function. This function is Win32 API. When you use, you need to include the header file "Windows.h".

转载请注明原文地址:https://www.9cbs.com/read-109418.html

New Post(0)