---
name: "set_projection_viewport"
section: "3alleg"
platform: "linux"
package: "liballegro-doc"
version: "2:4.2.2-2.2"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/set_projection_viewport"
---

# set\_projection\_viewport(3alleg)

Sets the viewport used to scale the output of persp\_project(). Allegro game programming library.

## NAME

set\_projection\_viewport - Sets the viewport used to scale the output of persp\_project(). Allegro game programming library.

## SYNOPSIS

**#include \<allegro.h\>**

**void set\_projection\_viewport(int x, int y, int w, int h);**

## DESCRIPTION

Sets the viewport used to scale the output of the persp\_project() function. Pass the dimensions of the screen area you want to draw onto, which will typically be 0, 0, SCREEN\_W, and SCREEN\_H. Also don't forget to pass an appropriate aspect ratio to get\_camera\_matrix later. The width and height you specify here will determine how big your viewport is in 3d space. So if an object in your 3D space is w units wide, it will fill the complete screen when you run into it (i.e., if it has a distance of 1.0 after the camera matrix was applied. The fov and aspect-ratio parameters to get\_camera\_matrix also apply some scaling though, so this isn't always completely true). If you pass -1/-1/2/2 as parameters, no extra scaling will be performed by the projection.

## SEE ALSO

[**persp\_project**(3alleg)](/persp_project/3alleg.md), [**get\_camera\_matrix**(3alleg)](/get_camera_matrix/3alleg.md), [**ex3d**(3alleg)](/ex3d/3alleg.md), [**excamera**(3alleg)](/excamera/3alleg.md), [**exquat**(3alleg)](/exquat/3alleg.md), [**exscn3d**(3alleg)](/exscn3d/3alleg.md), [**exstars**(3alleg)](/exstars/3alleg.md), [**exzbuf**(3alleg)](/exzbuf/3alleg.md)
