From 967fb1afad7edea14a7b29eeeb22c80ec7497f93 Mon Sep 17 00:00:00 2001 From: Recep Aslantas Date: Tue, 3 Apr 2018 17:32:10 +0300 Subject: [PATCH] Update README.md --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 4e7c4ef..dc9f736 100644 --- a/README.md +++ b/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
@@ -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: