In my android NDK OpenGL C++ project, I have a render method which executes every frame on draw event so this is the algorithm:
void Engine::render() {
deltaTime = GetCurrentTime() - lastFrame;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
update();
renderDepthMaps();
renderMeshes();
if (skybox != nullptr)
shaders.drawSkyBox(skybox, camera, width, height);
lastFrame = GetCurrentTime();
}
first I calculate the delta time between the last frame and the current frame, then I update all transformation and view matrices from input then render the scene so the game loop depends on the android draw frames, I have an object which moves over a terrain and a third person camera moves with it and rotates around it, so after the object moves for some distance it begins to flicker forward and backward, the update function for the object is:
double& delta = engine.getDeltaTime();
GLfloat velocity = delta * movementSpeed;
glm::vec3 t(glm::vec3(0, 0, 1) * velocity * 3.0f);
matrix = glm::translate(matrix, t);
glm::vec3 f(matrix[2][0], matrix[2][1], matrix[2][2]);
f = -glm::normalize(f) * velocity * 3.0f;
camera->translate(f);
If it is an interpolation issue I don't know how to make interpolation with using translate matrix to its forward vector.