File: ALLEGRO_PRIM_ATTR.3

package info (click to toggle)
allegro5 2%3A5.2.6.0-3%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 24,212 kB
  • sloc: ansic: 125,319; cpp: 15,781; objc: 4,579; python: 2,802; java: 2,254; javascript: 1,204; sh: 1,002; makefile: 51; perl: 37; xml: 25; pascal: 24
file content (89 lines) | stat: -rw-r--r-- 2,811 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
.\" Automatically generated by Pandoc 1.19.2.4
.\"
.TH "ALLEGRO_PRIM_ATTR" "3" "" "Allegro reference manual" ""
.hy
.SH NAME
.PP
ALLEGRO_PRIM_ATTR \- Allegro 5 API
.SH SYNOPSIS
.IP
.nf
\f[C]
#include\ <allegro5/allegro_primitives.h>

typedef\ enum\ ALLEGRO_PRIM_ATTR
\f[]
.fi
.SH DESCRIPTION
.PP
Enumerates the types of vertex attributes that a custom vertex may have.
.IP \[bu] 2
ALLEGRO_PRIM_POSITION \- Position information, can be stored only in
ALLEGRO_PRIM_SHORT_2, ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_PRIM_FLOAT_3.
.IP \[bu] 2
ALLEGRO_PRIM_COLOR_ATTR \- Color information, stored in an
ALLEGRO_COLOR(3).
The storage field of ALLEGRO_VERTEX_ELEMENT is ignored
.IP \[bu] 2
ALLEGRO_PRIM_TEX_COORD \- Texture coordinate information, can be stored
only in ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_PRIM_SHORT_2.
These coordinates are normalized by the width and height of the texture,
meaning that the bottom\-right corner has texture coordinates of (1, 1).
.IP \[bu] 2
ALLEGRO_PRIM_TEX_COORD_PIXEL \- Texture coordinate information, can be
stored only in ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_PRIM_SHORT_2.
These coordinates are measured in pixels.
.IP \[bu] 2
ALLEGRO_PRIM_USER_ATTR \- A user specified attribute.
You can use any storage for this attribute.
You may have at most ALLEGRO_PRIM_MAX_USER_ATTR (currently 10) of these
that you can specify by adding an index to the value of
ALLEGRO_PRIM_USER_ATTR, e.g.
the first user attribute is \f[C]ALLEGRO_PRIM_USER_ATTR\ +\ 0\f[], the
second is \f[C]ALLEGRO_PRIM_USER_ATTR\ +\ 1\f[] and so on.
.RS 2
.PP
To access these custom attributes from GLSL shaders you need to declare
attributes that follow this nomenclature: \f[C]al_user_attr_#\f[] where
# is the index of the attribute.
.PP
For example to have a position and a normal vector for each vertex you
could declare it like this:
.IP
.nf
\f[C]
ALLEGRO_VERTEX_ELEMENT\ elements[3]\ =\ {
\ \ \ \ {ALLEGRO_PRIM_POSITION,\ ALLEGRO_PRIM_FLOAT_3,\ 0},
\ \ \ \ {ALLEGRO_PRIM_USER_ATTR\ +\ 0,\ ALLEGRO_PRIM_FLOAT_3,\ 12},
\ \ \ \ {0,\ 0,\ 0}};
\f[]
.fi
.PP
And then in your vertex shader access it like this:
.IP
.nf
\f[C]
attribute\ vec3\ al_pos;\ //\ ALLEGRO_PRIM_POSITION
attribute\ vec3\ al_user_attr_0;\ //\ ALLEGRO_PRIM_USER_ATTR\ +\ 0
varying\ float\ light;
const\ vec3\ light_direction\ =\ vec3(0,\ 0,\ 1);
void\ main()\ {
\ \ \ \ light\ =\ dot(al_user_attr_0,\ light_direction);
\ \ \ \ gl_Position\ =\ al_pos;
}
\f[]
.fi
.PP
To access these custom attributes from HLSL you need to declare a
parameter with the following semantics: \f[C]TEXCOORD{#\ +\ 2}\f[] where
# is the index of the attribute.
E.g.
the first attribute can be accessed via \f[C]TEXCOORD2\f[], second via
\f[C]TEXCOORD3\f[] and so on.
.PP
Since: 5.1.6
.RE
.SH SEE ALSO
.PP
ALLEGRO_VERTEX_DECL(3), ALLEGRO_PRIM_STORAGE(3),
al_attach_shader_source(3)