1How to send vector or matrix to OpenGL like API
2==================================================
3
4*cglm*'s vector and matrix types are arrays. So you can send them directly to a
5function which accepts pointer. But you may got warnings for matrix because it is
6two dimensional array.
7
8Passing / Uniforming Matrix to OpenGL:
9~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10**glUniformMatrix4fv** accepts float pointer, you can pass matrix to that parameter
11and it should work but with warnings. "You can pass" doesn't mean that you must pass like that.
12
13**Correct options:**
14
15Correct doesn't mean correct way to use OpenGL it is just shows correct way to pass cglm type to it.
16
171. Pass first column
18---------------------
19
20The goal is that pass address of matrix, first element of matrix is also address of matrix,
21because it is array of vectors and vector is array of floats.
22
23.. code-block:: c
24
25   mat4 matrix;
26   /* ... */
27   glUniformMatrix4fv(location, 1, GL_FALSE, matrix[0]);
28
29array of matrices:
30
31.. code-block:: c
32
33   mat4 matrix;
34   /* ... */
35   glUniformMatrix4fv(location, count, GL_FALSE, matrix[0][0]);
36
371. Cast matrix to pointer
38--------------------------
39
40.. code-block:: c
41
42   mat4 matrix;
43   /* ... */
44   glUniformMatrix4fv(location, count, GL_FALSE, (float *)matrix);
45
46in this way, passing aray of matrices is same
47
48Passing / Uniforming Vectors to OpenGL:
49~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50
51You don't need to do extra thing when passing cglm vectors to OpengL or other APIs.
52Because a function like **glUniform4fv** accepts vector as pointer. cglm's vectors
53are array of floats. So you can pass it directly ot those functions:
54
55.. code-block:: c
56
57   vec4 vec;
58   /* ... */
59   glUniform4fv(location, 1, vec);
60
61this show how to pass **vec4** others are same.
62