Question

I'm searching how to manage game framerate on mobiles devices, here is my problem:

On a computer with got something like that:

void main()
{
    while(game.isRunning())
    {
        event.handle(eventInfos);
        game.update(dt);
        graphic.render();
    }
}

On a mobile device with got something like that:

void update()
{
    game.update(dt);
}

void render()
{
    game.render(dt);
}

void event()
{
    game.handle(eventInfos);
}

When I search on internet, I found something like that everytime:

-> GameLoop

-> Fix your time step

I'm using IOS (With GLKViewController) and Android (with the NDK), and I've that rendering method is call from another thread

Thanks for your help!

Was it helpful?

Solution

I findthe GameLoop link you have posted is very straight forward, he runs a thread which in its turn check for right time to call update() in these lines

            while (sleepTime < 0 && framesSkipped < MAX_FRAME_SKIPS) {
            // we need to catch up
            // update without rendering
            this.gamePanel.update(); 
            // add frame period to check if in next frame
            sleepTime += FRAME_PERIOD;  
            framesSkipped++;
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top