I’m creating a very render expensive scene in opengl (using vertex buffer objects) and while all objects stay in place, I want to do something like a ‘smooth pursuit’ of the objects. That is: leave the objects where they are and move the camera / point of view to the left or right with a certain constant speed. Currently I do this by calling glTranslatef in my draw function, followed by code which re-draws all objects. This is however very expensive (lot’s of objects!). Is there a way to just move the camera, without redrawing the entire scene?
I’m creating a very render expensive scene in opengl (using vertex buffer objects) and
Share
There is no camera in OpenGL. Or if you really want to think there is, then you have to realize that the “camera” stays at the origin in OpenGL, always looking in the same direction. The “camera” effect is simulated by moving and rotating all objects in the world, while the “camera” sits at the origin.
So if you want to move the “camera”, you really have to move the world (or all objects in the world). In other words, there really isn’t a way to “move the camera without redrawing all objects”. One option, if you really want, would be to render the scene to a texture that is larger than the screen, and then shift the texture around to simulate the “camera” moving. Note that if you’re using a perspective projection, it’ll look very wrong when you do this. This will only look decent if you’re using an orthographic projection.
However, it sounds like you’re drawing in immediate mode, which is an ancient and slow method. You should be using modern draw calls with shaders and vertex array objects/vertex buffer objects.