RobLoach / node-raylib

Node.js bindings for Raylib
https://robloach.github.io/node-raylib/
Other
245 stars 20 forks source link

Raylib setTargetFPS #72

Open qarasina opened 4 years ago

qarasina commented 4 years ago

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

RobLoach commented 4 years ago

Thanks for the report! :+1:

RobLoach commented 4 years ago

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
//--------------------------------------------------------------------------------------
qarasina commented 4 years ago

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

RobLoach commented 4 years ago

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

qarasina commented 4 years ago

The C version work :)

RobLoach commented 3 years ago

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