You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I am playing around with raylib and have copied the example from raysan5 on a social media platform for loading and rendering a .glb file (just the default 3d cube from Blender).
Now I have questions about how to implement a vsync toggle and also displaying frames per second.
Here is the modified code, still using the basics from the example:
I am a beginner in both C programming and 3d graphics so just having simple code for displaying a cube with a rotating camera is a nice start. Now I have questions about how to toggle vsync and also how it interacts with the operating system. I am running a X11 window manager and have the compositor off running the program, but it still only displays 60(59.9...) FPS. Running the program with vblank_mode=0 environment variable changes this to extreme amounts of FPS.
The pressing of the V key also does not seem to impact anything regarding FPS (shown in the second DrawText() function), no matter if running with the environment variable or not. How can I possibly better my code to toggle vsync at runtime to enable the discrepancy of the 60 FPS (monitors refresh rate) and the ~15k FPS when running with vblank_mode=0 in the program at runtime? I know it would cause tearing etc. so I am just wondering how to enable this feature as simple as possible.
I used a LLM which provided the (complex?) conditional operator, so it may be that I don't yet understand SetConfigFlags() and how to use the vsync boolean correctly with it. I also have questions if the first SetConfigFlags() which provides 2 different values is setup correctly for initializing the program since I just added the vsync thing to the existing example code looking at other examples using SetConfigFlags().
Sorry if this is made clear in the documentation, I have only read the cheatsheet and seen some examples regarding frame limitations and/or FPS counters. I tried searching the discussions regarding this topic and found some useful information, but not really a simple answer.
Thanks in advance.
Update: Deeper searching made me find the example which provides the answer to my question.
Works as expected with ClearWindowState() and SetWindowState() and no more need for the boolean and conditional operator.
Great library. Remove or archive thread or however it works on github.
Update 2: Forcing disabled vsync with vblank_mode=0 results in the programs internal vsync settings not being respected. Not sure if this is just something that is supposed to happen or if it can be combined with the X11-backend implementation. As I said I am only a beginner at C programming and have no experience with graphics programming on either higher or lower level.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi. I am playing around with raylib and have copied the example from raysan5 on a social media platform for loading and rendering a .glb file (just the default 3d cube from Blender).
Now I have questions about how to implement a vsync toggle and also displaying frames per second.
Here is the modified code, still using the basics from the example:
`
#include <stdint.h>
#include <math.h>
#include <inttypes.h>
#include <raylib.h>
int main(int argc, char *argv[]) {
const int_least64_t screen_width = 1366;
const int_least64_t screen_height = 768;
}
`
I am a beginner in both C programming and 3d graphics so just having simple code for displaying a cube with a rotating camera is a nice start. Now I have questions about how to toggle vsync and also how it interacts with the operating system. I am running a X11 window manager and have the compositor off running the program, but it still only displays 60(59.9...) FPS. Running the program with vblank_mode=0 environment variable changes this to extreme amounts of FPS.
The pressing of the V key also does not seem to impact anything regarding FPS (shown in the second DrawText() function), no matter if running with the environment variable or not. How can I possibly better my code to toggle vsync at runtime to enable the discrepancy of the 60 FPS (monitors refresh rate) and the ~15k FPS when running with vblank_mode=0 in the program at runtime? I know it would cause tearing etc. so I am just wondering how to enable this feature as simple as possible.
I used a LLM which provided the (complex?) conditional operator, so it may be that I don't yet understand SetConfigFlags() and how to use the vsync boolean correctly with it. I also have questions if the first SetConfigFlags() which provides 2 different values is setup correctly for initializing the program since I just added the vsync thing to the existing example code looking at other examples using SetConfigFlags().
Sorry if this is made clear in the documentation, I have only read the cheatsheet and seen some examples regarding frame limitations and/or FPS counters. I tried searching the discussions regarding this topic and found some useful information, but not really a simple answer.
Thanks in advance.
Update: Deeper searching made me find the example which provides the answer to my question.
https://www.raylib.com/examples/core/loader.html?name=core_window_flags
Works as expected with ClearWindowState() and SetWindowState() and no more need for the boolean and conditional operator.
Great library. Remove or archive thread or however it works on github.
Update 2: Forcing disabled vsync with vblank_mode=0 results in the programs internal vsync settings not being respected. Not sure if this is just something that is supposed to happen or if it can be combined with the X11-backend implementation. As I said I am only a beginner at C programming and have no experience with graphics programming on either higher or lower level.
Beta Was this translation helpful? Give feedback.
All reactions