Comments (5)
Hi!
By default TLN_CreateWindow() sets vsync flag. If it's not working for you, you should modify Window.c and remove CWF_VSYNC from line 426:
https://github.com/megamarc/Tilengine/blob/master/src/Window.c#L426
Then you'll have to do frame throttling on your game loop to adjust to your target frame rate, for example using SDL_Delay() + SDL_GetTicks() if you're using libSDL.
from tilengine.
Thanks Marc,
Please take a look here :
Today 144hz screens are common things under gaming scene, so, ther is my two cents :
- Why VSync is not working? It's quite strange.
- That code will do the job?
int32_t tickInteval = 1000/FPS; // frequency in Hz to period in ms
uint32_t lastUpdateTime = 0;
int32_t deltaTime = 0;
while (running) { // running condition
uint32_t currentTime = SDL_GetTicks();
deltaTime = currentTime - lastUpdateTime;
int32_t timeToSleep = tickInteval - deltaTime;
if(timeToSleep > 0)
{
SDL_Delay(timeToSleep); // energy saving
}
update(deltaTime); // game logic
lastUpdateTime = currentTime;
}
from tilengine.
Hi again,
Your frame throttling should work, the basic idea is measuring the time it takes to process one frame (game logic, render, etc) and delay/sleep until the time to next frame at your target FPS.
Why is vsync not working for you? I don't know as I don't have such 144 Hz monitor, mine is standard 60 Hz. But I guess is more related to G-sync and adaptive refresh rates than to a fixed 60/144 Hz issue. SDL2 just asks the underlying graphics API to enable vsync, but it's ultimately graphics driver and hardware to do the job.
from tilengine.
Hi again,
Your frame throttling should work, the basic idea is measuring the time it takes to process one frame (game logic, render, etc) and delay/sleep until the time to next frame at your target FPS.
Why is vsync not working for you? I don't know as I don't have such 144 Hz monitor, mine is standard 60 Hz. But I guess is more related to G-sync and adaptive refresh rates than to a fixed 60/144 Hz issue. SDL2 just asks the underlying graphics API to enable vsync, but it's ultimately graphics driver and hardware to do the job.
Thanks Mark, I will take a look over Nvidia low level things like GSync and how affect to SDL2 Window handling.
Because Tilengine demos are affected too, we need to think about maintaining compatibility with more screen refresh frequencies before making serious projects.
Greetings
from tilengine.
Maybe this article on how SDL2 handles adaptive sync may help:
https://wiki.libsdl.org/SDL_GL_SetSwapInterval
However this is not a tilengine issue, but a general windowing/vsync one on modern monitors.
from tilengine.
Related Issues (20)
- Sprite rotation capabilities HOT 1
- Memory corruption in "shooter" example HOT 3
- Crash when resuming animation HOT 1
- Unable to build on MacOS HOT 1
- non-initialized blinking borders when switching to fullscreen HOT 2
- V bindings HOT 1
- Tileset ordering in tmx file causing exception HOT 1
- Get tile returns incorrect tiles info type HOT 1
- Unable to build Tilengine HOT 1
- Actor.c from Samples dir, doesn't work HOT 1
- libretro port HOT 2
- Sprite not drawn after calling TLN_SetNextSprite HOT 2
- Tiled integration HOT 2
- real game source code HOT 1
- Getter for Layers, Tilemaps, Sprites, Tiles, ..., user data for callbacks, palette tile attribute, multiple tilesets per tilemap, and bug with TLN_SetTilemapTile()
- Pausing Specific Animations HOT 3
- Issues with custom overlay HOT 5
- Steps to reproduce the crash on exit in TLN_DeleteTileset
- Map layer with multiple .tsx files causes memory issues HOT 1
- TLN_GetTilemapTileset2 returns None/NULL HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tilengine.