04-24-2023, 02:37 AM
(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:
- 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.
- 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;
}