# Camera vs Viewport

I'm don't have a clear understanding of what precisely is the difference between the camera coordinates and the viewport coordinates. Can anyone please clarify?

Camera is like a camera with which Batman movie is filmed. It exists in a virtual world and can be moved around, targeting different scenes, changing focal length and other camera properties. You can have many cameras and switch between them. You can even film on several cameras at once.

Typical camera coordinates are: position in virtual world, facing direction, up-vector, field-of-view, etc.

Viewport is a cinema screen. It is a place where image recorded by camera is shown. In PC world that is an area in the screen within some window or a full-screen image. You can show feeds from several cameras at once (like in those console racing games between 2-4 players).

Typical viewport coordinates are: position on display, height and width.

The viewport coordinates are the coordinated where it is placed on the screen. (For example inside a win32 window).

The camera coordinates are the position of the camera INSIDE the viewport, that is inside the 2D/3D space you set in your OpenGL application. The camera can't go outside that viewport because it is in the space you set where opengl can do its work, inside a Win32 window.

• That is not entirely accurate. The viewport defines the mapping from NDC space to window-space for vertex transformation. In older versions of GL, that mapping applied to raster position transformation as well (but that has been removed). Nevertheless, there are many GL operations that are not restricted by vertex transformation and thus you can do things like clear the color buffer outside of the viewport. In fact, the only way to restrict a buffer clear to a specific region of the framebuffer is to use a different thing altogether, called a scissor box (glScissor (...)). – Andon M. Coleman Jun 12 '14 at 1:11