We’re rewarding the question askers & reputations are being recalculated! Read more.
3 Edited tags.
source | link

Guys really hopeinghoping for some help here. My game loop is based on code from Fix Your Timestep!.

So, maybe in 'normal curcumstances'circumstances', I would expect this to happen occasionally).

So, what am I missing or not understanding? I would think it should (certianlycertainly with no rendering or logic updating to create a bottleneck):

Guys really hopeing for some help here. My game loop is based on code from Fix Your Timestep!.

So, maybe in 'normal curcumstances', I would expect this to happen occasionally).

So, what am I missing or not understanding? I would think it should (certianly with no rendering or logic updating to create a bottleneck):

Guys really hoping for some help here. My game loop is based on code from Fix Your Timestep!.

So, maybe in 'normal circumstances', I would expect this to happen occasionally).

So, what am I missing or not understanding? I would think it should (certainly with no rendering or logic updating to create a bottleneck):

2 added 211 characters in body
source | link

However, I've tried removing all rendering and logic updating and just running a skeleton loop and I'm still getting caught regularly and constantly inwithin the 'while-loops'loop'.

Therefore, when I'm running my game (with rendering and logic), I'm getting a lot of stuttering because I knowknow the loop is going to skip frames. The logic updates are however*however being capped at 60 which is exactly what I want.

Obviously whether or not my rendering or physics update could be more efficient is not the issue here and is a question for another day as I've already removed that from the equation.

@Override
public void onDrawFrame(GL10 gl) {

    newTime = System.currentTimeMillis()*0.001;
    frameTime = newTime - currentTime; //Amount of time this entire frame took
            if ( frameTime > (0.25))
                frameTime = (0.25);

            currentTime = newTime;
            accumulator += frameTime;

            //Update logic
            while (accumulator >= dt){
  //              saveGameState();
   //Removed for testing
//              updateLogic(dt);  //Removed for testing
                accumulator -= dt;
            }

            //Get the amount to interpolate by
//              interpolation = (float) (accumulator / dt);  //Removed for testing
//              render(interpolate);                         //Removed for testing

}  

However, I've tried removing all rendering and logic updating and just running a skeleton loop and I'm still getting caught regularly and constantly in the 'while-loops'.

Therefore, when I'm running my game, I'm getting a lot of stuttering because I know the loop is going to skip frames. The logic updates are however* being capped at 60 which is exactly what I want

Obviously whether or not my rendering or physics update could be more efficient is not the issue as I've removed that from the equation.

@Override
public void onDrawFrame(GL10 gl) {

    newTime = System.currentTimeMillis()*0.001;
    frameTime = newTime - currentTime; //Amount of time this entire frame took
            if ( frameTime > (0.25))
                frameTime = (0.25);

            currentTime = newTime;
            accumulator += frameTime;

            //Update logic
            while (accumulator >= dt){
                saveGameState();
                 updateLogic(dt);
                accumulator -= dt;
            }

            //Get the amount to interpolate by
            interpolation = (float) (accumulator / dt);  
            render(interpolate);

}  

However, I've tried removing all rendering and logic updating and just running a skeleton loop and I'm still getting caught regularly and constantly within the 'while-loop'.

Therefore, when I'm running my game (with rendering and logic), I'm getting a lot of stuttering because I know the loop is going to skip frames. The logic updates are however being capped at 60 which is exactly what I want.

Obviously whether or not my rendering or physics update could be more efficient is not the issue here and is a question for another day as I've already removed that from the equation.

@Override
public void onDrawFrame(GL10 gl) {

    newTime = System.currentTimeMillis()*0.001;
    frameTime = newTime - currentTime; //Amount of time this entire frame took
            if ( frameTime > (0.25))
                frameTime = (0.25);

            currentTime = newTime;
            accumulator += frameTime;

            //Update logic
            while (accumulator >= dt){
//              saveGameState();  //Removed for testing
//              updateLogic(dt);  //Removed for testing
                accumulator -= dt;
            }

            //Get the amount to interpolate by
//              interpolation = (float) (accumulator / dt);  //Removed for testing
//              render(interpolate);                         //Removed for testing

}  
1
source | link

Android Game-Loop (rendering & logic removed, but still 'skipping frames')

Overview

Guys really hopeing for some help here. My game loop is based on code from Fix Your Timestep!.

I've read the article more than a few times, but I can't quite work out what exactly is supposed to be going on within the loop.

I'm running my code on a Nexus 10 tablet which has VSync set to 60fps.

Playing catch up

When I run my code, I'm getting caught quite often in the while loop, ie it runs my logic more than once - so runs logic twice in a row before rendering).

With my understanding of the loop, this should happen when rending takes too long to fit into the time slice (which is 16.66666666666667ms).

So, maybe in 'normal curcumstances', I would expect this to happen occasionally).

However, I've tried removing all rendering and logic updating and just running a skeleton loop and I'm still getting caught regularly and constantly in the 'while-loops'.

Therefore, when I'm running my game, I'm getting a lot of stuttering because I know the loop is going to skip frames. The logic updates are however* being capped at 60 which is exactly what I want

Obviously whether or not my rendering or physics update could be more efficient is not the issue as I've removed that from the equation.

I can smooth things out somewhat with interpolation and it really does make a difference, however, it's not as smooth as some of the games I download from the Play Store and I really need to make it better.

So, what am I missing or not understanding? I would think it should (certianly with no rendering or logic updating to create a bottleneck):

  • Enter the while-loop
  • Exit the while-loop
  • Wait for next VSync
  • And repeat

Here is the loop I'm testing with:

@Override
public void onDrawFrame(GL10 gl) {

    newTime = System.currentTimeMillis()*0.001;
    frameTime = newTime - currentTime; //Amount of time this entire frame took
            if ( frameTime > (0.25))
                frameTime = (0.25);

            currentTime = newTime;
            accumulator += frameTime;

            //Update logic
            while (accumulator >= dt){
                saveGameState();
                updateLogic(dt);
                accumulator -= dt;
            }

            //Get the amount to interpolate by
            interpolation = (float) (accumulator / dt);  
            render(interpolate);

}