---
name: "al_transform_coordinates_3d_projective"
section: "3"
platform: "linux"
package: "allegro"
version: "5.2.11.3-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/al_transform_coordinates_3d_projective"
---

# al\_transform\_coordinates\_3d\_projective(3)

Allegro 5 API

## NAME

al\_transform\_coordinates\_3d\_projective - Allegro 5 API

## SYNOPSIS

-

  ```
  #include <allegro5/allegro.h>
  void al_transform_coordinates_3d_projective(const ALLEGRO_TRANSFORM *trans,
     float *x, float *y, float *z)
  ```

## DESCRIPTION

Transform x, y, z as homogeneous coordinates. This is the same as using [al\_transform\_coordinates\_4d(3)](/al_transform_coordinates_4d/3.md) with the w coordinate set to 1, then dividing x, y, z by the resulting w. This will provide the same normalized coordinates Allegro will draw to when a projective transform is in effect as set with [al\_use\_projection\_transform(3)](/al_use_projection_transform/3.md). To get the actual pixel coordinates from those translate and scale like so (w and h would be the pixel dimensions of the target bitmap):

-

  ```
  x = w / 2 + x * w / 2
  y = h / 2 - y * h / 2
  ```

*Parameters:*

- •

  trans - Transformation to use

- •

  x, y, z - Pointers to the coordinates

Example:

-

  ```
  ALLEGRO_TRANSFORM t2;
  al_copy_transform(&t2, al_get_current_transform());
  al_compose_transform(&t2, al_get_current_projection_transform());
  ALLEGRO_TRANSFORM t3;
  al_identity_transform(&t3);
  al_scale_transform(&t3, 0.5, -0.5);
  al_translate_transform(&t3, 0.5, 0.5);
  al_scale_transform(&t3, al_get_bitmap_width(al_get_target_bitmap()),
                     al_get_bitmap_height(al_get_target_bitmap()));
  al_transform_coordinates_3d_projective(&t2, &x, &y, &z);
  // x, y now contain normalized coordinates
  al_transform_coordinates(&t3, &x, &y);
  // x, y now contain pixel coordinates
  ```

Since 5.2.4

## SEE ALSO

[al\_use\_transform(3)](/al_use_transform/3.md), [al\_transform\_coordinates(3)](/al_transform_coordinates/3.md), [al\_transform\_coordinates\_3d(3)](/al_transform_coordinates_3d/3.md), [al\_use\_projection\_transform(3)](/al_use_projection_transform/3.md)
