Giter VIP home page Giter VIP logo

Comments (2)

DelinWorks avatar DelinWorks commented on June 14, 2024

Thanks for asking! You can use the setAnimationInterval function, this function takes a frametime value, so If you want to have 120 fps then you have to pass a float fraction of 1.0 / 120.0 and that will make the game render at that framerate.

// this will render the game at 30 fps, cool for cinematic experiences
Director::getInstance()->setAnimationInterval(1.0f / 30);

For desktop computers (Windows, linux) If you don't know the refresh rate of the GPU the user is running you can get that value using glfwGetVideoMode(glfwGetPrimaryMonitor())->refreshRate This will give you the speed at which the GPU updates the monitor NOT the monitor's hertz.

This is good for limiting the framerate but causes stuttering because a 144hz display on a 144fps can cause stuttering and horizontal lines because there is no vertical sync. To enable VSYNC you can tell glfw to do so by calling glfwSwapInterval(1); this will enable VSYNC and the display won't have jittery lines (It would also cap the framerate to the GPU's refresh rate) and glfwSwapInterval(0); to turn off VSYNC.

for mobile phones that support 120fps you unfortunately can't get the information about update rate, but you can run the game at 120fps in mobile devices by just setting the interval to 0.

// The phone's OS will cap the fps by the displays refresh rate so setting this value to 0
// will tell the OS to update the context as fast as the display of the phone can go.
// or what the user has set the refresh rate of the phone in the settings.
Director::getInstance()->setAnimationInterval(0);

Hope that helps <3 Feel free to ask!

from rebound.

aismann avatar aismann commented on June 14, 2024

@DelinWorks
Maybe a Q&A for axmol?

from rebound.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.