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;
    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;

If it is an interpolation issue I don't know how to make interpolation with using translate matrix to its forward vector.


2 Answers 2


Try this:

F = glm:vec3(f[0], f[1], f[2] + velocity);

I am suggesting not to do normalization in code as down the graphics pipeline your transformed vertices will be normalized.


the problem was in the shader precision once I set it to high it solve the problem

  • \$\begingroup\$ Hey, thanks for coming back to answer your question and mark it as accepted, I'm sure this will help future users! \$\endgroup\$
    – Vaillancourt
    Commented Oct 16, 2017 at 12:06
  • 1
    \$\begingroup\$ it takes me 7 days to find the solution :( so I hope it may help any person \$\endgroup\$ Commented Oct 16, 2017 at 12:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .