0 votes

get the label text to be the FPS with GDnative or C++ "frames per secons"
I see that you cannot do OS.getframespersecond () when you are using C ++ with Gdnative.
Lastly, how can I concatenate the text with the result of the OS.get
framespersecond () 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!
}
Godot version Godot Engine version 3.3.3 stable.Oficial
in Engine by (143 points)
edited by

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() ) );
}

1 Answer

+1 vote
Best answer
float fps = Engine::get_singleton()->get_frames_per_second(); // Now it's not in OS anymore
label->set_text( String("FPS:  {0}").format( Array::make(fps) ) );
// or
label->set_text( "FPS: " + String::num(fps) );
by (1,646 points)
selected by

I work this way, although it converts from "real_t" to "double"

String::num_real( Engine::get_singleton()->get_frames_per_second() )

Console message from godot ..

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() ) );
}
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.