0
\$\begingroup\$

So basically my problem is that the camera is stuttering and seems to just completely stop updating when moving. It's not exactly a stutter because the camera slows and and also stops for split seconds and does not jolt to where it is supposed to be looking after the freeze. It more or less stops updating entirely.

I have the camera updating in a loop in one thread, lets call it the GAME thread, and I have an OpenGL thread, lets call this the RENDER thread, which accesses the camera to use to get a view matrix. The camera seems to just stop moving and won't update for some reason and I don't really understand why. I know something is up with moving the camera in the GAME thread as when I moved the camera update method to be called from the RENDER thread, it works much more smoothly. I know the rendering thread is not impacted as the FPS is not dropping but the camera just failing to move.

I would just like an explanation of why this may happen? And if possible how to fix this

All thats happening in the camera.move() method is just calculating values and the render method just gets the values of the rotation and position of the camera

GAME thread loop:

    private void init() {
        windows.createWindow();
        camera = new Camera();
        startGameLoop();
        while(!GLFW.glfwWindowShouldClose(windows.getWindowNum())) {
            camera.move();
            GLFW.glfwWaitEvents();
        }
        isRunning = false;
        windows.destroy();
    }

RENDER thread loop

    private void gameLoop() {
        setup();
        while(GameEngine.isRunning) {
            windows.update();
        }
        cleanUp();
    }
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.