![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | ariel |
get the label text to be the FPS with GDnative or C++ “frames per secons”
I see that you cannot do OS.get_frames_per_second () when you are using C ++ with Gdnative.
Lastly, how can I concatenate the text with the result of the OS.get_frames_per_second () in Gdnative using C ++
void InstanciarCubos::_process(const double p_delta)
{
// Godot::print( String::num_real( p_delta ) );
// measure average frames per second
ContadorText->set_text( "FPS" + OS.get_frames_per_second() ); // <--no work!
}
I work this way, although it converts from "real_t" to "double"
String::num_real( Engine::get_singleton()->get_frames_per_second() )
Godot::print( String::num_real( Engine::get_singleton()->get_frames_per_second() ) );
Thanks for the Engine tip Engine::get_singleton()->get_frames_per_second()
, I didn’t even imagine it.
I leave the complete code where I do the casting in the Node of type Label.
void InstanciarCubos::_process(const double p_delta)
{
if(FpsText == nullptr) return;
FpsText->set_text("FPS= " + String::num_real( Engine::get_singleton()->get_frames_per_second() ) );
Godot::print( String::num_real( Engine::get_singleton()->get_frames_per_second() ) );
}
ariel | 2021-08-26 22:03
For the record, this question was cross-posted on the Godot forums: https://godotforums.org/discussion/27279/how-can-i-get-the-frames-per-second-fps-of-the-game-with-gdnative-c
Calinou | 2021-08-27 20:04