Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9214413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:58:08+00:00 2026-06-18T01:58:08+00:00

For FPS calculation, I use some code I found on the web and it’s

  • 0

For FPS calculation, I use some code I found on the web and it’s working well. However, I don’t really understand it. Here’s the function I use:

void computeFPS()
{
  numberOfFramesSinceLastComputation++;
  currentTime = glutGet(GLUT_ELAPSED_TIME);

  if(currentTime - timeSinceLastFPSComputation > 1000)
  {
    char fps[256];
    sprintf(fps, "FPS: %.2f", numberOfFramesSinceLastFPSComputation * 1000.0 / (currentTime . timeSinceLastFPSComputation));
    glutSetWindowTitle(fps);
    timeSinceLastFPSComputation = currentTime;
    numberOfFramesSinceLastComputation = 0;
  }
 }

My question is, how is the value that is calculated in the sprint call stored in the fps array, since I don’t really assign it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:58:09+00:00Added an answer on June 18, 2026 at 1:58 am

    This is not a question about OpenGL, but the C standard library. Reading the reference documentation of s(n)printf helps:

    man s(n)printf: http://linux.die.net/man/3/sprintf

    In short snprintf takes a pointer to a user supplied buffer and a format string and fills the buffer according to the format string and the values given in the additional parameters.


    Here’s my suggestion: If you have to ask about things like that, don’t tackle OpenGL yet. You need to be fluent in the use of pointers and buffers when it comes to supplying buffer object data and shader sources. If you plan on using C for this, get a book on C and thoroughly learn that first. And unlike C++ you can actually learn C to some good degree over the course of a few months.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an online FPS written in C# which will use P2P
I am currently working on designing my first FPS game using JOGL. (Java bindings
I am debugging some Linux C code in a signal handler for floating point
I am working on an FPS game. You can see it deployed on Heroku
If I'm going for fps, is it faster to use one larger canvas and
I'm looking to get some additional performance (FPS) increases on my iPhone App. I'm
I am working on a MFC project with Kinect that uses a FPS counter.
I'm messing around with Pygame, making some simple games just to learn it. However,
I am trying to print some debugging info (FPS, camera location and rotation, etc)
I am working on integrating Amazon FPS into my company's website but seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.