GLFW - VSync On/Off
Monkey Forums/Monkey Code/GLFW - VSync On/Off
| ||
NO LONGER REQUIRED - FUNCTIONALITY HAS BEEN IMPLEMENTED INTO v77c (see SetSwapInterval) This code will allow you to enable/disable VSync in GLFW. Works in v72 or better. Create the following in your modules\<modulename> folder: graphics.monkey Strict Import mojo #if TARGET = "glfw" Import "native/graphics.${TARGET}.${LANG}" Extern Function VSyncOn:Void() Function VSyncOff:Void() Public #end native\graphics.glfw.cpp static void VSyncOn() { glfwSwapInterval(1); } static void VSyncOff() { glfwSwapInterval(0); } |
| ||
You could make this a lot more efficient by doing this: [monkeycode] Extern Function SetVSync:Void(Value:Bool)="glfwSwapInterval" Function VSyncOn:Void()="glfwSwapInterval(1)" Function VSyncOff:Void()="glfwSwapInterval(0)" Public [/monkeycode] You don't even need a separate module, let alone an external 'cpp' file. But wait a minute, am I missing something? This doesn't really do anything for me. |
| ||
Thanks, this is exactly what I was looking for! (Sonickidnextgen, it does make a difference when you are running your game fullscreen at +60fps. fast movement looks choppy if graphic updates are not in sync with your monitor's refresh cycle) |
| ||
there is a new monkey config setting in v76a: Added #GLFW_SWAP_INTERVAL app config setting for glfw target, set to -1 to not set swap interval at all (ie: use driver default). Defaults to -1 for BW compatiblity. |
| ||
Mr_twister, I was referring to the fact that it literally did nothing for me. Fraps reported the same 60 frames per-second (16ms per-frame). I haven't tried it in fullscreen, is it any different? I thought the GLFW version of Mojo/BBGame capped (Slept, delayed, etc) everything based on the update-rate, and didn't care if it was rendering or not; I could be wrong though. |