Reputation: 31
So I am trying to teach myself opengl and I cant figure out how to zoom in and out. I tried a few different examples and they are not panning out. What I need is the very basics like zooming in and out of a centered cube. i know this is done using some kind of black magic and the glOrtho function but i cant figure in out. Thanks in advance.
Upvotes: 3
Views: 16616
Reputation: 1074
If you are using Orthographic projection then your object looks the same size irrespective of your camera position. So here if you want to zoom you should modify the viewing volume by adjusting the parameters to the glOrtho. Increasing the volume will make the object look smaller and decreasing the volume will make the object look bigger. This is more a natural way. I have seen some people use the glScale too but the previous one is more natural in my opinion.
If you want to do zooming in perspective projection then @David M suggestion of modifying the FOV is fine.
Upvotes: 3