opengl

Sample code from LearnOpenGL.com
Log | Files | Refs

commit 308b64833daaec450691c9e37f33f58b9786eb7a
parent 71547d6ff6ccd939d7f4a6d138ed0ddae1a68efb
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Tue, 27 Jun 2023 08:46:27 +0900

add math library

Diffstat:
Aglm.c | 22++++++++++++++++++++++
Aglm.h | 22++++++++++++++++++++++
Mmain.c | 1+
3 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/glm.c b/glm.c @@ -0,0 +1,22 @@ +#include <stdlib.h> + +#include "glm.h" + +vec3 +*makeVec3(float *vals) +{ + return (vec3 *)vals; +} + +vec4 +*makeVec4(float *vals) +{ + return (vec4 *)vals; +} + + +mat4 +*makeMat4(float *vals) +{ + return (mat4 *)vals; +} diff --git a/glm.h b/glm.h @@ -0,0 +1,21 @@ +typedef float vec3[3]; + +vec3 *makeVec3(float *); + +typedef float vec4[4]; + +vec4 *makeVec4(float *); +void freeVec4(vec4 *); + + +typedef float mat4[16]; +// column major: +// | 0 4 8 12 | +// | 1 5 9 13 | +// | 2 6 10 14 | +// | 3 7 11 15 | + +mat4 *makeMat4(float *); +void freeMat4(mat4 *); + +mat4 *translate(mat4 *, vec3 *); +\ No newline at end of file diff --git a/main.c b/main.c @@ -7,6 +7,7 @@ #include <GLFW/glfw3.h> #include "main.h" +#include "glm.h" #define STB_IMAGE_IMPLEMENTATION #define STBI_NO_SIMD // TODO: confirm this workaround. #include "stb_image.h"