c++ - Displaying FPS in GLFW window title? -


im trying fps display in window title program not having it.

my fps code

    void showfps() {      // measure speed      double currenttime = glfwgettime();      nbframes++;      if ( currenttime - lasttime >= 1.0 ){ // if last cout more 1 sec ago          cout << 1000.0/double(nbframes) << endl;          nbframes = 0;          lasttime += 1.0;      } } 

and want go after version here

window = glfwcreatewindow(640, 480, game_name " " version " ", null, null); 

but cant call void i have convert char ? or ?

there's istringstream trick:

template< typename t > std::string tostring( const t& val ) {     std::istringstream iss;     iss << val;     return iss.str(); } 

or boost.lexical_cast.

you can use std::string::c_str() null-terminated string pass in glfwsetwindowtitle().


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -