node-raylib icon indicating copy to clipboard operation
node-raylib copied to clipboard

Raylib setTargetFPS

Open qarasina opened this issue 5 years ago • 6 comments

The targetfps function doesn't work my fps are blocked at 60

qarasina avatar Jun 05 '20 19:06 qarasina

Thanks for the report! :+1:

RobLoach avatar Jun 05 '20 20:06 RobLoach

Does the following work? I'm getting 30 FPS...

const r = require('raylib')

// Initialization
//--------------------------------------------------------------------------------------
var screenWidth = 800
var screenHeight = 450

r.InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window")

r.SetTargetFPS(30)

//--------------------------------------------------------------------------------------

// Main game loop
while (!r.WindowShouldClose())    // Detect window close button or ESC key
{
    // Update
    //----------------------------------------------------------------------------------
    // TODO: Update your variables here
    //----------------------------------------------------------------------------------

    // Draw
    //----------------------------------------------------------------------------------
    r.BeginDrawing()

        r.ClearBackground(r.RAYWHITE)

        r.DrawText("Congrats! You created your first window!", 190, 200, 20, r.LIGHTGRAY)

    r.EndDrawing()

    console.log('FPS:' + r.GetFPS())
    //----------------------------------------------------------------------------------
}

// De-Initialization
//--------------------------------------------------------------------------------------
r.CloseWindow()        // Close window and OpenGL context
//--------------------------------------------------------------------------------------

RobLoach avatar Jun 06 '20 15:06 RobLoach

Yes but it not work with r.setTargetFps(120)

qarasina avatar Jun 06 '20 19:06 qarasina

That must be a thing with GLFW or raylib. Very strange. Does the C++ one work?

RobLoach avatar Jun 08 '20 00:06 RobLoach

The C version work :)

qarasina avatar Jun 08 '20 09:06 qarasina

Does your monitor support it? Perhaps vsync is taking over.

RobLoach avatar Jan 02 '21 17:01 RobLoach