1al_transform_coordinates_3d_projectivea(l3_)transform_coordinates_3d_projective(3)
2
3
4
6 al_transform_coordinates_3d_projective - Allegro 5 API
7
9 #include <allegro5/allegro.h>
10
11 void al_transform_coordinates_3d_projective(const ALLEGRO_TRANSFORM *trans,
12 float *x, float *y, float *z)
13
15 Transform x, y, z as homogeneous coordinates. This is the same as us‐
16 ing al_transform_coordinates_4d(3) with the w coordinate set to 1, then
17 dividing x, y, z by the resulting w. This will provide the same nor‐
18 malized coordinates Allegro will draw to when a projective transform is
19 in effect as set with al_use_projection_transform(3). To get the actu‐
20 al pixel coordinates from those translate and scale like so (w and h
21 would be the pixel dimensions of the target bitmap):
22
23 x = w / 2 + x * w / 2
24 y = h / 2 - y * h / 2
25
26 Parameters:
27
28 • trans - Transformation to use
29
30 • x, y, z - Pointers to the coordinates
31
32 Example:
33
34 ALLEGRO_TRANSFORM t2;
35 al_copy_transform(&t2, al_get_current_transform());
36 al_compose_transform(&t2, al_get_current_projection_transform());
37
38 ALLEGRO_TRANSFORM t3;
39 al_identity_transform(&t3);
40 al_scale_transform(&t3, 0.5, -0.5);
41 al_translate_transform(&t3, 0.5, 0.5);
42 al_scale_transform(&t3, al_get_bitmap_width(al_get_target_bitmap()),
43 al_get_bitmap_height(al_get_target_bitmap()));
44
45 al_transform_coordinates_3d_projective(&t2, &x, &y, &z);
46 // x, y now contain normalized coordinates
47 al_transform_coordinates(&t3, &x, &y);
48 // x, y now contain pixel coordinates
49
50 Since 5.2.4
51
53 al_use_transform(3), al_transform_coordinates(3), al_transform_coordi‐
54 nates_3d(3), al_use_projection_transform(3)
55
56
57
58Allegro reference manual al_transform_coordinates_3d_projective(3)