raysan5/raylib

[Question] is Raylib compatible with smooth rendering ranging from 60 to 1.

ayoubelmhamdi opened this issue · 2 comments

Update

create a simple app, will use much CPU usage with Raylib، even when the applications appear to be doing minimal work.

My question is about how to achieve smooth FPS, ranging from 1 to 60, without locking it at 60 FPS every second, the usage of 60 fram per second is inefficient for non-gaming GUI applications.

I haven't found any sources discussing this situation. If there are any resources available, we would be eager to read them, because achieving smooth FPS with Raylib could be a game-changer.

Below is what I envision as an intuitive solution:

#include "raylib.h"

int main(void) {
    InitWindow(400, 2
    InitWindow(400, 200, "Hello, Raylib!");

    SetMaxFPS{60);

    while {!WindowShouldRender()) {
        BeginSmoothFrame();
            DrawCircle(200, 100, 50, RED);
        EndSmoothFrame();
    }

    CloseWindow();
    return 0;
}

@ayoubelmhamdi I'm afraid I don't understand this requirement. In any case, you can omit SetTargetFPS() usage an manage game timing yourself, here it is an example for a custom game loop: https://github.com/raysan5/raylib/blob/master/examples/core/core_custom_frame_control.c

Thank you @raysan5 for the fast response! I appreciate your quick answers regarding the issues in the repository.

I've update the description, and it seems that the example you give me of using the custom frame control might be exactly what i miss and i need.

i will experimenting with the code, to try to create a simple app that doesn't render 60 frames per second but instead moves smoothly based on shapes and events(sometimes 1, 10, 59,60... it's depends).

This approach should help conserve battery and resources.