Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tilengine 2.15 supports variable refresh rate monitors
#1
I've uploaded a new release to GitHub and itch.io, that adds these features to the built-in window:
  • Support for non-60 Hz refresh rates. Auto adjusted when creating the window, or can be manually set
  • V-Sync can be disabled between frames, allowing to setup a target fps different than the monitor refresh rate
  • Window scaling factor can be setup at runtime with ALT-1 to ALT-5
Full post can be read here:
https://megamarc.itch.io/tilengine/devlo...5-released
Reply
#2
(04-23-2023, 04:24 AM)megamarc Wrote: I've uploaded a new release to GitHub and itch.io, that adds these features to the built-in window:
  • Support for non-60 Hz refresh rates. Auto adjusted when creating the window, or can be manually set
  • V-Sync can be disabled between frames, allowing to setup a target fps different than the monitor refresh rate
  • Window scaling factor can be setup at runtime with ALT-1 to ALT-5
Full post can be read here:
https://megamarc.itch.io/tilengine/devlo...5-released

This is very nice! It will solve problems for people that have non-60Hz screens! (Including me and people that have high end setup)
Adjusting scaling factor is also a good idea, but I also suggest to add getters and setters to set the scaling through code. One use case example can be game settings. Most of games today have a setting that let you adjusting the size of the window.
Reply
#3
Hi!

No problem in adding getter/setter for new window scaling factor, thanks for suggesting it.

As I don't have acces to a non-60 Hz display, I'd like you to validate the latest version on your display. I tested it on my 60 Hz display by disabling vsync and manually forcing other target fps like 144 or 240. The test sample runs at the same relative speed no matter what target fps I set, but using different amounts of cpu and gpu, of course.

There's a new test file under test folder, called test_fps.c. I'd like you to build and run it with two configurations:

  1. Run it without using the new features: NOT setting CWF_NOVSYNC flag and NOT calling TLN_SetTargetFps(). This should run natively vsynced at 144 Hz, as it should detect the refresh rate of your monitor and auto adapt to it.
  2. Run it again forcing new features: enable CWF_NOVSYNC flag and explicitly call TLN_SetTagetFps(60) to force 60 fps. This should run at the same apparent speed than the previous run, but you may experience unstable smoothness and/or tearing.

Let me know how does it run in your setup
Reply
#4
(04-23-2023, 03:44 PM)megamarc Wrote: Hi!

No problem in adding getter/setter for new window scaling factor, thanks for suggesting it.

As I don't have acces to a non-60 Hz display, I'd like you to validate the latest version on your display. I tested it on my 60 Hz display by disabling vsync and manually forcing other target fps like 144 or 240. The test sample runs at the same relative speed no matter what target fps I set, but using different amounts of cpu and gpu, of course.

There's a new test file under test folder, called test_fps.c. I'd like you to build and run it with two configurations:

  1. Run it without using the new features: NOT setting CWF_NOVSYNC flag and NOT calling TLN_SetTargetFps(). This should run natively vsynced at 144 Hz, as it should detect the refresh rate of your monitor and auto adapt to it.
  2. Run it again forcing new features: enable CWF_NOVSYNC flag and explicitly call TLN_SetTagetFps(60) to force 60 fps. This should run at the same apparent speed than the previous run, but you may experience unstable smoothness and/or tearing.

Let me know how does it run in your setup

Hi, I compiled the program, and once I disable the NOVSYNC flag, I have a black window. But when I enable it, Green Hill Zone displays properly.

Here is the code :
Code:
#include "Tilengine.h"

#define WIDTH 400
#define HEIGHT 240
#define FPS 60

/* entry point */
int main(int argc, char* argv[])
{
TLN_Init(WIDTH, HEIGHT, 1, 0, 0);
TLN_Tilemap tilemap = TLN_LoadTilemap("assets/sonic/Sonic_md_fg1.tmx", NULL);

TLN_SetLayer(0, NULL, tilemap);
TLN_SetBGColor(32, 32, 128);

/* main loop */
int frame = 0;

/*
* Creates window, will automatically adjust target FPS to monitor Hz.
* Use CWF_NOVSYNC when forcing a different target FPS than monitor rate
*/
TLN_CreateWindow(NULL, CWF_VSYNC);

/* override monitor refresh rate */
//TLN_SetTargetFps(FPS);

int pos = 0;

while (TLN_ProcessWindow())
{
/* adjust game logic pacing to target fps */
//int pos = (frame * 60) / TLN_GetTargetFps();

TLN_SetLayerPosition(0, pos, 0);
TLN_DrawFrame(0);
frame++;
pos++;
}

/* release resources */
TLN_DeleteTilemap(tilemap);
TLN_Deinit();

return 0;
}
Reply
#5
Hi,

Thanks for testing it. I don't know what's going on, as on my tests it runs well in both cases... (native and forced fps). However I don't hava access to a 144 Hz monitor, so I can't check if there's something funny going on with timings. Strangely, the tricky part is handling timing without vsync -that it's working for you-, as enabling vsync is the classic behavior so it should be harmless.

I've pushed an update to GitHub with getter/setter for window scaling factor at runtime, and a new function to return actual fps at runtime. I've reworked a bit test_fps.c and now it prints actual fps to the console.

What OS and graphics card are you using? I use Windows x64 with an Intel GMA500 chipset.
Reply
#6
(04-24-2023, 03:54 AM)megamarc Wrote: Hi,

Thanks for testing it. I don't know what's going on, as on my tests it runs well in both cases... (native and forced fps). However I don't hava access to a 144 Hz monitor, so I can't check if there's something funny going on with timings. Strangely, the tricky part is handling timing without vsync -that it's working for you-, as enabling vsync is the classic behavior so it should be harmless.

I've pushed an update to GitHub with getter/setter for window scaling factor at runtime, and a new function to return actual fps at runtime. I've reworked a bit test_fps.c and now it prints actual fps to the console.

What OS and graphics card are you using? I use Windows x64 with an Intel GMA500 chipset.

I use Windows 11, I also have the Intel Core i7 CPU graphics and an NVidia RTX 3050. I will try the new update and give you feedback.
Reply
#7
Alright so I tested and this is very weird

Target FPS with no vsync works perfectly, but when I go to standard mode, the FPS counter is above 1000 (yes!). And even weirder, if I go to full screen, the picture is displayed, and when I go back to windowed mode, the picture is still here. But when I close the program and open it again, the bug is still here.
Reply
#8
It seems that vsync is being ignored in windowed mode in this setup, so it's running at full throttle
  • How did the samples ran in previous releases? In both fullscreen and windowed
  • When you say the picture is displayed in fullscreen, you mean that the app is running correctly at expected speed?
Reply
#9
(04-24-2023, 09:22 PM)megamarc Wrote: It seems that vsync is being ignored in windowed mode in this setup, so it's running at full throttle
  • How did the samples ran in previous releases? In both fullscreen and windowed
  • When you say the picture is displayed in fullscreen, you mean that the app is running correctly at expected speed?

In previous releases (like Tilengine 2.14 for example), they ran faster because of 144Hz. But they displays properly in both full screen and windowed.
When I meant that, I meant you can see the picture, it is not black. And it runs at 144 FPS.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)