mirror of
https://github.com/recp/cglm.git
synced 2025-12-25 12:55:04 +00:00
Update README.md
This commit is contained in:
22
README.md
22
README.md
@@ -76,6 +76,7 @@ Currently *cglm* uses default clip space configuration (-1, 1) for camera functi
|
||||
- inline or pre-compiled function call
|
||||
- frustum (extract view frustum planes, corners...)
|
||||
- bounding box (AABB in Frustum (culling), crop, merge...)
|
||||
- project, unproject
|
||||
|
||||
<hr />
|
||||
|
||||
@@ -227,6 +228,27 @@ glm_mat4_mul(m1, m1, m1);
|
||||
```
|
||||
the first two parameter are **[in]** and the last one is **[out]** parameter. After multiplied *m1* and *m2* the result is stored in *m1*. This is why we send *m1* twice. You may store result in different matrix, this just an example.
|
||||
|
||||
### Example: Computing MVP matrix
|
||||
|
||||
#### Option 1
|
||||
```C
|
||||
mat4 proj, view, model, mvp;
|
||||
|
||||
/* init proj, view and model ... */
|
||||
|
||||
glm_mat4_mul(proj, view, viewProj);
|
||||
glm_mat4_mul(viewProj, model, mvp);
|
||||
```
|
||||
|
||||
#### Option 2
|
||||
```C
|
||||
mat4 proj, view, model, mvp;
|
||||
|
||||
/* init proj, view and model ... */
|
||||
|
||||
glm_mat4_mulN((mat4 *[]){&proj, &view, &model}, 3, mvp);
|
||||
```
|
||||
|
||||
## How to send matrix to OpenGL
|
||||
|
||||
mat4 is array of vec4 and vec4 is array of floats. `glUniformMatrix4fv` functions accecpts `float*` as `value` (last param), so you can cast mat4 to float* or you can pass first column of matrix as beginning of memory of matrix:
|
||||
|
||||
Reference in New Issue
Block a user