How to implement Interpolation in the following loop?

I’m actually making this in C# with OpenTK. Here is my [icode]GameLoop()[/icode] method.


private void GameLoop()
{
    // Initialize GL
    InitGL();

    // Gameloop variables
    long now = GetCurrentTime();
    long gameTime = GetCurrentTime();

    int frames = 0;
    int updates = 0;

    int frameSkip = 1;
    long frameTime = 1000 / Global.STEPS_FOR_SECOND;

    int skippedFrames = 0;

    long lastUpdateCount = GetCurrentTime();
    long lastFramesCount = GetCurrentTime();

    // The Game Loop
    while (Exists)
    {
        CheckEnginePrefs();

        now = GetCurrentTime();

        // Update loop
        while (now + frameTime > gameTime && skippedFrames < frameSkip)
        {
            Update(frameTime);
            updates++;
            gameTime += frameTime;

            // Check for UPS

            if (now - lastUpdateCount >= 1000)
            {
                Global.ACTUAL_STEPS_FOR_SECOND = updates;
                updates = 0;
                lastUpdateCount = now;
            }
        }

        // render

        GL.Clear(ClearBufferMask.ColorBufferBit);
        Render();

        frames++;

        // Check for FPS

        if (now - lastFramesCount >= 1000)
        {
            Global.FRAMES_PER_SECOND = frames;
            frames = 0;
            lastFramesCount = now;
        }

        SwapBuffers();

        // Do the System Events
        ProcessEvents();
    }
}

This plays up nicely but I can see some stuttering i.e., non smooth movement of the character even though the game achieves 175 fps and 30 ups constantly. Now I’m thinking of implementing interpolation. I’ve read the GameLoops article but can’t understand it. How can I implement this in my loop?

Thanks.

There is no need for 175 fps if your game run 30 UPS. I mean, you still see change of 30 UPS. With 30 fps you won’t see smooth movement unless it’s very slow. You need 60.

This might help:

www.games.freebasic.net/BASICGaming/Issue9/index.html#tutorial1

@Relminator Thanks for the link. However I had looked into the DeWitters GameLoops article which included a version of GameLoop with interpolation.